# How SMS service works

DIDWW SMS lets you receive text messages on your DID numbers and send
messages from your applications. SMS trunks connect DIDWW to your systems,
and Sender ID Verifications approve the Sender IDs used for
application-to-person (A2P) messaging.

## How SMS is sent and received

Every message travels through an [SMS trunk](sms-trunks/index.html). The
trunk type defines how DIDWW and your systems exchange messages: by email,
over HTTP, or over SMPP.

| Trunk type | Direction | How messages are exchanged |
| --- | --- | --- |
| [SMS to Email](sms-trunks/sms-to-email/sms-to-email-trunk.html) | Inbound | DIDWW forwards each inbound SMS to an email address. |
| [HTTP IN](sms-trunks/http-in/http-in-trunk.html) | Inbound | DIDWW sends each inbound SMS to your HTTP endpoint as an HTTP request. |
| [HTTP OUT](sms-trunks/http-out/http-out-trunk.html) | Outbound | Your application submits SMS to the [Outbound SMS API](outbound-sms-api/index.html). DIDWW sends status callbacks to the trunk's **Callback URL**. |
| [SMPP ESME](sms-trunks/smpp-esme/smpp-esme-trunk.html) | Inbound and outbound | Your application binds to the DIDWW SMPP server to send and receive SMS. |
| [SMPP SMSC](sms-trunks/smpp-smsc/smpp-smsc-trunk.html) | Inbound and outbound | DIDWW binds to your SMSC to deliver and receive SMS. |

### Inbound SMS

When someone sends a text message to your DID number, the originating network
delivers the message to DIDWW. DIDWW delivers it through the SMS trunk or SMS
trunk group assigned to that DID number.

```
        %%{init: {
  "theme": "base",
  "themeVariables": {
    "fontSize": "14px",
    "actorBkg": "#e0f2fe",
    "actorBorder": "#38bdf8",
    "actorTextColor": "#1f2d3d",
    "actorLineColor": "#38bdf8",
    "signalColor": "#0f766e",
    "signalTextColor": "#1f2d3d",
    "labelBoxBkgColor": "#ccfbf1",
    "labelBoxBorderColor": "#14b8a6",
    "labelTextColor": "#1f2d3d",
    "noteBkgColor": "#fef3c7",
    "noteBorderColor": "#f59e0b",
    "noteTextColor": "#1f2d3d",
    "sequenceNumberColor": "#ffffff"
  }
}}%%

sequenceDiagram
   autonumber
   participant sender as Sender
   participant network as Mobile network
   participant didww as DIDWW
   participant system as Your system

   sender->>network: Send SMS to DID number
   network->>didww: Deliver SMS to DIDWW
   Note over didww: Find the SMS trunk or trunk group<br/>assigned to the DID number
   didww->>system: Deliver SMS by email, HTTP, or SMPP
```

### Outbound SMS

Your system submits a message to DIDWW through an HTTP OUT, SMPP ESME, or SMPP
SMSC trunk. DIDWW checks the trunk and the sender, routes the
message to the destination network, and reports the result.

```
        %%{init: {
  "theme": "base",
  "themeVariables": {
    "fontSize": "14px",
    "actorBkg": "#e0f2fe",
    "actorBorder": "#38bdf8",
    "actorTextColor": "#1f2d3d",
    "actorLineColor": "#38bdf8",
    "signalColor": "#0f766e",
    "signalTextColor": "#1f2d3d",
    "labelBoxBkgColor": "#ccfbf1",
    "labelBoxBorderColor": "#14b8a6",
    "labelTextColor": "#1f2d3d",
    "noteBkgColor": "#fef3c7",
    "noteBorderColor": "#f59e0b",
    "noteTextColor": "#1f2d3d",
    "sequenceNumberColor": "#ffffff"
  }
}}%%

sequenceDiagram
   autonumber
   participant app as Your system
   participant didww as DIDWW
   participant network as Destination network
   participant recipient as Recipient

   app->>didww: Submit SMS through an SMS trunk
   Note over didww: Check the trunk<br/>and the sender
   didww->>network: Route SMS
   network->>recipient: Deliver SMS
   didww-->>app: Report the result
```

## DID numbers, trunks and sender IDs

**DID numbers** receive inbound SMS. A DID number can receive SMS when it
supports the **Inbound SMS** feature. To receive messages, [assign an
SMS trunk or an SMS trunk group](../phone-numbers/my-numbers/how-to-guides/assign-sms-trunk.html#assigning-sms-trunk) to
the DID number.
Several DID numbers can use the same trunk.

**SMS trunks** connect DIDWW to your systems. An inbound message is delivered
through the trunk assigned to the DID number that received it. An outbound
message is sent through the trunk that your application uses. Outbound SMS
does not require a DID number to be assigned to the trunk.

**SMS trunk groups** combine several SMS trunks. When a DID number uses a
trunk group, DIDWW attempts the member trunks in priority order. If a delivery
attempt fails, DIDWW tries the next member trunk in priority order. See [SMS trunk
groups](sms-trunks/trunk-groups/sms-trunk-groups.html).

**Sender IDs** define who an outbound message comes from:

- For P2P messaging, the sender is a DID number that supports the **Outbound
  P2P SMS** feature. The trunk's **Source Address Settings** control which
  of these DID numbers it can use. By default, a trunk can use every DID
  number with Outbound P2P SMS enabled in your account.
- For A2P messaging, the sender is a Sender ID covered by an active
  [Sender ID Verification](sender-id-verifications/index.html), such as an
  Alphanumeric, Long-code, or Toll-Free Sender ID. Messages must be sent
  through the outbound SMS trunk associated with the verification.

## P2P and A2P messaging

DIDWW supports two types of outbound messaging traffic:

| Type | Description | Sender |
| --- | --- | --- |
| Person-to-person (P2P) | Low-volume, two-way exchange of SMS between end users. | A DID number with the **Outbound P2P SMS** feature. |
| Application-to-person (A2P) | High-volume SMS generated by applications and sent to subscribers. | A Sender ID registered through an active Sender ID Verification. |

P2P and A2P messages have separate rates. Download the **Outbound P2P SMS
Trunk Rates** and **Outbound A2P SMS Trunk Rates** pricelists from **SMS >
SMS Trunks** in the DIDWW User Panel, or see [Download
pricelists](../phone-numbers/buy-numbers/download-pricelists.html#services-coverage-pricing-access-pricelists). In the
[Outbound SMS
logs](../logs-analytics/sms-logs/outbound-logs.html#outbound-logs), you can filter messages by service type.

Inbound A2P messages sent to DID numbers can be restricted in some countries.
See [A2P messaging](sms-trunks/technical-data/guidelines.html#sms-in-guidelines-a2p) in the Inbound SMS
Guidelines.

## Service access and message delivery

Which messages you can receive and send depends on the features of your DID
numbers and on your Sender ID Verifications:

- Inbound SMS requires a DID number that supports **Inbound SMS** and an
  assigned SMS trunk or trunk group.
- Outbound P2P SMS requires a DID number that supports **Outbound P2P SMS**.
- Outbound A2P SMS requires an active Sender ID Verification associated with
  the outbound SMS trunk.

DID numbers are optimized to receive SMS within their country of
registration. For delivery considerations, see the [Inbound SMS
Guidelines](sms-trunks/technical-data/guidelines.html).

### P2P Outbound SMS access

P2P Outbound SMS is enabled automatically after your DIDWW account is
verified through [Account Setup](../account-settings/account-setup.html#user-panel-account-verification). You
do not need to contact DIDWW Sales or Support to request access. Account
verification starts when you first buy a DID number. After that, you can send
P2P SMS from any DID number in your account that supports **Outbound P2P
SMS**, through an outbound SMS trunk that allows that number as the sender.

### Submission and delivery

When DIDWW accepts a message, the message is not yet delivered. Delivery is
reported separately:

- **Outbound SMS API:** A `201 Created` response confirms that DIDWW
  accepted the request and returns the message ID. DIDWW then sends a status
  callback with the processing result to the trunk's **Callback URL**. When
  enabled, a delivery receipt (DLR) event reports the final delivery status
  from the carrier. See [Status callbacks and delivery
receipts](outbound-sms-api/status-callbacks-and-delivery-receipts.html).
- **SMPP:** Each PDU is acknowledged, for example `submit_sm` with
  `submit_sm_resp`. Delivery receipts are sent in `deliver_sm`. See
  [SMPP message flow](sms-trunks/technical-data/smpp-specification.html#smpp-pdu-flow).
- **HTTP IN:** If your endpoint does not respond with a `2xx` status code,
  DIDWW retries delivery until the message's time to live (TTL) of 3600
  seconds expires. See [Technical details](sms-trunks/technical-data/http-specification.html#sms-in-spec-technical).

Review sent and received messages in the [Outbound SMS
logs](../logs-analytics/sms-logs/outbound-logs.html#outbound-logs) and [Inbound SMS
logs](../logs-analytics/sms-logs/inbound-logs.html#inbound-logs).

### Message length and billing

SMS messages are billed per fragment. A long message is split into several
fragments, and its encoding determines how many characters fit in each
fragment. Each fragment is billed separately. For character limits,
concatenation, and billing examples, see the [SMS encoding
reference](sms-trunks/technical-data/sms-encoding-reference.html).

## Related resources

- [SMS trunks](sms-trunks/index.html) - Compare the trunk types and choose
  how messages travel between DIDWW and your systems.
- [Outbound SMS API](outbound-sms-api/index.html) - Send SMS from your
  application over HTTPS.
- [How Sender ID Verification works](sender-id-verifications/how-sender-id-verification-works.html) - Understand
  Sender ID types, verification, and billing.
- [SMS encoding reference](sms-trunks/technical-data/sms-encoding-reference.html) - Look up GSM-7 and
  UCS-2 limits, reassembly, and fragment billing.
- [Inbound SMS Guidelines](sms-trunks/technical-data/guidelines.html) -
  Review delivery considerations and restrictions for inbound SMS.
