Skip to Content
MailerSend
SMS API

Inbound routing

Learn how to efficiently create and manage SMS inbound routes with MailerSend's API documentation and the SMS inbounds endpoint.

Get a list of SMS inbound routes

If you want to retrieve information about multiple SMS inbound routes, use this GET request:

GET https://api.mailersend.com/v1/sms-inbounds

Request parameters

Query parameterTypeRequiredLimitationsDetails
sms_number_idstringno
enabledbooleanno
pageintno
limitintnoMin: 10, Max: 100Default: 15
use MailerSend\MailerSend;

$mailersend = new MailerSend(['api_key' => 'key']);

$smsRecipients = $mailersend->smsInbound->getAll($smsNumberId = 'sms_number_id', $enabled = true, $page = 3, $limit = 15);

More examples

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": [
    {
      "id": "7z3m5jgrogdpyo6n",
      "name": "Inbound",
      "filter": {
        "value": "START",
        "comparer": "equal"
      },
      "forward_url": "https://yourapp.com/hook",
      "enabled": true,
      "secret": "jYhafGtTiZgw0qWxlkUA7cbqTG3Zfh2j",
      "created_at": "2022-01-01T12:00:00.000000Z"
    }
  ],
  "links": {
    "first": "https://api.mailersend.com/v1/sms-inbounds?page=1",
    "last": "https://api.mailersend.com/v1/sms-inbounds?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "path": "https://api.mailersend.com/v1/sms-inbounds",
    "per_page": 15,
    "to": 1,
    "total": 1
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Get a single SMS inbound route

If you want to retrieve a single SMS inbound route, use this GET request:

GET https://api.mailersend.com/v1/sms-inbounds/{sms_inbound_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
sms_inbound_idstringyes
use MailerSend\MailerSend;

$mailersend = new MailerSend(['api_key' => 'key']);

$smsRecipients = $mailersend->smsInbound->find('sms_inbound_id');

More examples

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "7z3m5jgrogdpyo6n",
    "name": "Inbound",
    "filter": {
      "value": "START",
      "comparer": "equal"
    },
    "forward_url": "https://yourapp.com/hook",
    "enabled": true,
    "secret": "jYhafGtTiZgw0qWxlkUA7cbqTG3Zfh2j",
    "created_at": "2022-01-13T12:00:00.000000Z",
    "sms_number": {
      "id": "7z3m5jgrogdpyo6n",
      "telephone_number": "+19199876543",
      "paused": false,
      "created_at": "2022-01-13T12:00:00.000000Z"
    }
  }
}

Error

Response Code: 404 Not Found

Add an SMS inbound route

If you want to add a new SMS inbound route to a domain, use this POST request:

POST https://api.mailersend.com/v1/sms-inbounds

Request body

{
    "sms_number_id": "7z3m5jgrogdpyo6n",
    "name": "Inbound",
    "forward_url": "https://yourapp.com/hook",
    "filter": {
      "comparer": "equal",
      "value": "START"
    },
    "enabled": true
  }

Request Parameters

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
sms_number_idstringYes
namestringYesMax 191 characters.
forward_urlstringYesMust be a valid, publicly reachable URL.MailerSend sends a test request to this URL. It must return a 2xx response within 3 seconds.
filterobjectNo
filter.comparerstringYes*Must be one of the comparers: equal, not-equal, contains, not-contains, starts-with, ends-with, not-starts-with, not-ends-with.
filter.valuestringYes*Min: 1, Max 255 characters.
enabledbooleanNo
* Required when filter object is provided.

Responses

Response KeyTypeDetails
dataobjectSMS Inbound object created.

Valid

Response Code: 201 CREATED
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "7z3m5jgrogdpyo6n",
    "name": "Inbound",
    "filter": {
      "value": "START",
      "comparer": "equal"
    },
    "forward_url": "https://yourapp.com/hook",
    "enabled": true,
    "secret": "jYhafGtTiZgw0qWxlkUA7cbqTG3Zfh2j",
    "created_at": "2022-01-01T12:00:00.000000Z"
  }
}

Invalid

Response Code: 422 Unprocessable Entity

See - Validation errors

Update an inbound route

If you want to update the information of an existing inbound route, use this PUT request:

PUT https://api.mailersend.com/v1/sms-inbounds/{sms_inbound_id}

Request body

{
    "sms_number_id": "7z3m5jgrogdpyo6n",
    "name": "Inbound",
    "forward_url": "https://yourapp.com/hook",
    "filter": {
      "comparer": "equal",
      "value": "START"
    },
    "enabled": true
}

Request Parameters

URL parameterTypeRequiredLimitationsDetails
sms_inbound_idstringyes

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
sms_number_idstringNo
namestringNoMax 191 characters.
forward_urlstringNoMust be a valid, publicly reachable URL.MailerSend sends a test request to this URL. It must return a 2xx response within 3 seconds.
filterobjectNo
filter.comparerstringYes*Must be one of the comparers: equal, not-equal, contains, not-contains, starts-with, ends-with, not-starts-with, not-ends-with.
filter.valuestringYes*Min: 1, Max 255 characters.
enabledbooleanNo
* Required when filter object is provided.

Responses

Response KeyTypeDetails
dataobjectSMS Inbound object created.

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "7z3m5jgrogdpyo6n",
    "name": "Inbound",
    "filter": {
      "value": "START",
      "comparer": "equal"
    },
    "forward_url": "https://yourapp.com/hook",
    "enabled": true,
    "secret": "jYhafGtTiZgw0qWxlkUA7cbqTG3Zfh2j",
    "created_at": "2022-01-01T12:00:00.000000Z"
  }
}

Invalid

Response Code: 422 Unprocessable Entity

See - Validation errors

Delete an SMS inbound route

If you want to delete an SMS inbound route, use this DELETE request:

DELETE https://api.mailersend.com/v1/sms-inbounds/{sms_inbound_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
sms_inbound_idstringyes
use MailerSend\MailerSend;

$mailersend = new MailerSend(['api_key' => 'key']);

$smsRecipients = $mailersend->smsInbound->delete('sms_inbound_id');

More examples

Responses

Valid

Response Code: 204 No Content
Response Body: [EMPTY]

Error

Response Code: 404 Not Found

On this page