# Initial setup and connection

In this section, you will learn how to configure your application and establish a connection with the SMPP API.

## Create or sign in to your Twilio account

* Account Setup: If you don't already have a Twilio account, create one on the [Twilio Sign Up page](https://www.twilio.com/try-twilio).
* Sign In: Access your Twilio account through the [Twilio Console](https://console.twilio.com).

> \[!NOTE]
>
> Note your Account SID and Auth Token, as you will need them in future steps.

## Get your Account SID enabled for using SMPP

1. Contact your dedicated Account Manager to express interest in the SMPP API.
2. Set up an SMPP dedicated Account SID in the [Console](https://console.twilio.com/user/unified-account/details?source=account-switcher).
3. Complete the questionnaire:

   * Your account manager will send you an onboarding questionnaire.
   * Complete the questionnaire and notify your account manager. Once this is done, your account manager will create a support ticket on your behalf.
4. Receive your credentials: Twilio provides you with the necessary credentials and an integration guide. The information will come via a secure email. Only the "technical contact" specified in the onboarding questionnaire will be able to complete the secure email flow.

   Your SMPP API credentials will be provided in the following format (note that the values shown below are examples):

   * Account SID: `ACXXXXXXXXXXXXXXXX`
   * System ID: `user123456789123`
   * Password: `A1b2C3d4`
   * Inbound Routing URL: `https://smpp-mo.twilio.com/mo-groups/{YMXXXXXXXX}`
   * Number of Binds allowed per system\_id: `5` (default value)
   * Segments per second per bind allowed: `20` (default value)
5. Once you've obtained your credentials, you can start using them to establish connection between your client and the SMSC and begin sending messages.

## Set up your inventory and configure inbound messages

Next, you need to obtain and set up your phone numbers for sending and receiving messages in the Twilio Console. This process involves two steps:

### Provision inventory

* To get a new phone number, you can buy one using either the [Console](https://console.twilio.com/us1/develop/phone-numbers/manage/search?isoCountry=US\&types\[]=Local\&types\[]=Tollfree\&capabilities\[]=Sms\&capabilities\[]=Mms\&capabilities\[]=Voice\&capabilities\[]=Fax\&searchTerm=\&searchFilter=left\&searchType=number) or the [API](/docs/phone-numbers/api/availablephonenumber-resource).
* To use an existing phone number, you can port it through the [Console](https://console.twilio.com/us1/develop/phone-numbers/port-host/porting-requests?frameUrl=%2Fconsole%2Fphone-numbers%2Fporting-requests%3F_gl%3D1*4jc634*_gcl_aw*R0NMLjE3MzEwNjE5NzUuQ2owS0NRaUFpcmU1QmhDTkFSSXNBTTUzSzFqTkFpVnpQdThJVHV5anpfWnZ4TnRSRmJwdEVWc3NnNjFOdVBYakVpRFFQYzdPMnNibW5OTWFBbjhNRUFMd193Y0I.*_gcl_au*MTMxMDAyNjAyMy4xNzMwNDc3MzU2*_ga*MjA1NDAzNzg0MC4xNzMwNzI5MDc0*_ga_RRP8K4M4F3*MTczMTA3MzU4Ni4xMS4xLjE3MzEwNzM2NDUuMC4wLjA.%253F_gl%253D1*4jc634*_gcl_aw*R0NMLjE3MzEwNjE5NzUuQ2owS0NRaUFpcmU1QmhDTkFSSXNBTTUzSzFqTkFpVnpQdThJVHV5anpfWnZ4TnRSRmJwdEVWc3NnNjFOdVBYakVpRFFQYzdPMnNibW5OTWFBbjhNRUFMd193Y0I.*_gcl_au*MTMxMDAyNjAyMy4xNzMwNDc3MzU2*_ga*MjA1NDAzNzg0MC4xNzMwNzI5MDc0*_ga_RRP8K4M4F3*MTczMTA3MzU4Ni4xMS4xLjE3MzEwNzM2NDUuMC4wLjA.%26x-target-region%3Dus1) or the [API](/docs/phone-numbers/port-in).

### Configure your account for inbound messaging

#### Option 1: Setup via Console:

1. Navigate to the Account SID of your SMPP integration using the dropdown menu in the top right corner.
2. On the left-hand side, click on [**Phone Numbers**](https://console.twilio.com/?frameUrl=%2Fconsole%3Fx-target-region%3Dus1) or [**Short Codes**](https://console.twilio.com/us1/develop/phone-numbers/short-codes)
3. Select **Manage** > **Active Numbers**.
4. Click on the phone number you want to configure.
5. Scroll down to the **Messaging** section. In the **A Message comes in** field, select **Webhook**. Paste the MO Routing URL (`https://smpp-mo.twilio.com/mo-groups/{MO Routing SID}`) where you want to receive incoming messages.
6. Select **HTTP `POST`** from the dropdown menu.
7. Click **Save**.

#### Option 2: Setup via API:

1. To configure your Twilio phone number to receive incoming messages, you can submit an HTTP `POST` request to the [IncomingPhoneNumber resource](/docs/phone-numbers/api/incomingphonenumber-resource#update-an-incomingphonenumber-resource) associated with that number. To complete this request, you will need the following information:
   * Phone number SID: The PN SID (long code) or SC SID (short code) for the phone number you wish to update.
   * Twilio messaging app details: The URL for your Twilio app (webhook, TwiML Bin, Function, etc.).
   * Your credentials: The Account SID and Auth Token for your Twilio account.

Here is an example of how to configure your Twilio phone number to receive incoming messages via the API:

```bash
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json \
--data-urlencode "SmsUrl=http://www.example.com/twilio" \
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
```

Navigate to the [ShortCode resource page](/docs/messaging/api/short-code-resource#update-a-shortcode-resource) to learn how to configure short code phone numbers to receive incoming messages.

## Client SMPP configuration

To establish a TCP socket with Twilio, send a request to their Fully Qualified Domain Name (FQDN) via an encrypted port. Ensure you're using TLS version 1.2 or higher from one of the IP addresses allowlisted during onboarding.

During the TLS handshake, public and private keys are exchanged, and Twilio's SMPP service certificate is presented for validation.

Once completed, you'll initiate an SMPP session by issuing a `bind_sm` command PDU to establish a persistent connection, enabling the sending of outbound messages and the receiving of inbound messages and delivery receipts.

To connect your client with the SMPP API, please refer to the table below for the required SMPP settings configuration.

| **Settings** | **Values**                     | **Description**                                                                                                                            |
| ------------ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Twilio Host  | \*\*\*\*\*\*\*\*\*\*\*\*\*\*\* | Twilio SMPP API domain name. This will be provided with your initial onboarding email that also includes your `system_id` and `password​`. |
| Twilio Port  | \*\*\*\*                       | Twilio SMPP API port. This will be provided with your initial onboarding email that also includes your `system_id` and `password​`.        |
| SMPP version | 3.4                            | SMPP protocol version used by the Twilio SMPP API.                                                                                         |
| `system_id`  | Example: `12A34b56C78d91E`     | A 15 Character long System ID string provided by your Twilio account manager.                                                              |
| `password`   | Example: `i0oLw3pa`            | A 8 Character long password for your Twilio SMPP account provided by your Twilio account manager.                                          |
| Security     | TLS v.1.2 and above            | Connection encryption protocol.                                                                                                            |

## Troubleshooting connection errors

### Bind errors

> \[!NOTE]
>
> If you experience any errors during the initial connection process, please reply to the email where you received your SMPP credentials. Alternatively, you can contact us by opening a new support ticket at help.sms@twilio.com.

If Twilio rejects a bind request during an initial bind attempt, the `command_status` field of the bind requests response will be used to communicate an error message.

Twilio SMPP API doesn't send non-SMPP specification errors on bind requests. For a list of errors and brief descriptions, please visit the [SMPP Error Codes page](https://smpp.org/smpp-error-codes.html).
