logo

OTP SMPP Setup

อัพเดทล่าสุด :2025-01-08

Interface Information

This protocol defines the SMPP communication protocol for OTP services, aiming to achieve efficient and reliable message delivery and status reporting via TCP connections. The interface information includes the IP address, port, and authentication credentials. Please ensure the credentials provided by authorized channels are configured correctly.

SMPP Address

Please obtain the following information from authorized channels (e.g., sales or technical support):

  • IP Address: { ip }
  • Port: { port }
  • Account: { system_id }
  • Password: { password }

Establishing Connection

Client Data Packet

After establishing a TCP connection, the first data packet must send the BindTransceiver command (0x00000009) for authentication. The packet must include the following fields:

  • system_id: The system account assigned to the client for identity verification.
  • password: The access password corresponding to the system account for authentication.

Server Response

Successful Response

  • The server will send a BindTransceiverResp command (0x80000009) as a response.
  • The system_id field will be filled with the value received in the system_id field.

Failed Response

  • If authentication fails, the server will disconnect the TCP connection and log the reason.

Message Sending

Server Logic

Message sending uses the SUBMIT_SM command (0x00000004) to submit message delivery requests. The server's logic is as follows:

  1. The server parses the request content and uses the SMS channel for delivery.
  2. Messages are delivered in synchronous mode, and results will be responded with the SUBMIT_SM_RESP command (0x80000004).
  3. Delivery reports will be sent, as detailed in the Delivery Report section.
  4. It is recommended to use UCS2 encoding to support special characters and internationalization.

Client Data Packet

The client sends the SUBMIT_SM command (0x00000004) to submit messages with the following fields:

  1. service_type
    • Values: MSG / CODE / MRKT
    • Default: MSG
  2. source_addr
    • Can be left blank; not used in OTP currently.
  3. destination_addr
    • The target of the message, must be in the international phone number format (e.g., +8613800138000).
  4. short_message
    • The message content in JSON format, as shown below:
      { "id": "xxx", // Template ID "language": "default", // Language, default is "default" "code": "xx", // Verification code, used when service_type is "code" "params": { // Custom key-value pairs "key1": "val1" // Value must be a string } }
                {
        "id": "xxx",          // Template ID
        "language": "default", // Language, default is "default"
        "code": "xx",          // Verification code, used when service_type is "code"
        "params": {            // Custom key-value pairs
          "key1": "val1"       // Value must be a string
        }
      }
      
              
      โค้ดนี้โชว์เป็นหน้าต่างลอย
  5. data_coding
    • It is recommended to use UCS2 encoding to ensure special characters {} are properly parsed.
    • If {} can be sent directly, default encoding (0x00) can be used.
  6. header status
    • Set to 0x00000000.

Server Response

The server responds to message delivery requests with the SUBMIT_SM_RESP command (0x80000004).

Successful Response

  • header status field value: 0x00000000
  • MESSAGE_ID field: The message ID used to associate delivery reports.

Failed Response

  • The server fills the header status field to indicate the reason for failure:
Status Code Description Value
ESME_RINVPARAM Invalid parameters, check the request format 0x00000032
ESME_RSYSERR Internal server error, retry later 0x00000008
ESME_RSUBMITFAIL Delivery failed, possibly due to template issues 0x00000045
ESME_RINVNUMMSGS Invalid short_message format 0x00000055
ESME_RUNKNOWNERR Unknown error, contact technical support 0x000000FF

Delivery Report

The server reports delivery results through the DELIVER_SM command (0x00000005). The fields are as follows:

  1. service_type
    • Fixed value: MSG
  2. source_addr
    • Blank.
  3. destination_addr
    • Matches the destination_addr field in the SUBMIT_SM command.
  4. data_coding
    • Encoding method: Default value 0x00.
  5. esm_class
    • Set to 0x00.
  6. short_message
    • Encapsulates the delivery report in delivery receipt format.
  7. ReceiptedMessageID in tlv
    • The message ID for association.
  8. MessageState in tlv
    • The message state, field value 0x0427.

Status Parsing

The short_message field contains the stat value, indicating the following:

Status Meaning
DELIVRD Delivered successfully
UNDELIV Delivery failed

Additional Information

Invalid Commands

For invalid commands submitted by the client, the server will return the GENERIC_NACK command (0x80000000) and log the event. The server only supports the following commands:

  1. EnquireLink command (0x00000015)
  2. Unbind command (0x00000006)
  3. SubmitSM command (0x00000004)
  4. DeliverSMResp command (0x80000005)
  5. BindTransceiver command (0x00000009)

Connection Keep-Alive

The client must send the EnquireLink command (0x00000015) every 30 seconds (±5 seconds) to maintain connection activity.


Delivery Status Meaning

Status Code Meaning
ESME_RINVPARAM Invalid parameters, check the request format
ESME_RINVNUMMSGS Invalid short_message format
ESME_RSUBMITFAIL Delivery failed, possibly due to template issues
ESME_RSYSERR Internal server error, retry later
ESME_RUNKNOWNERR Unknown error, contact technical support
DELIVRD Successfully delivered
UNDELIV Delivery failed

Terminology

  • SMPP: Short Message Peer-to-Peer Protocol for message exchange between SMS gateways.
  • SUBMIT_SM: SMPP command for submitting messages.
  • DELIVER_SM: SMPP command for reporting message delivery status.

For any inquiries, please contact Technical Support.

在文档中心打开
icon
ติดต่อฝ่ายขาย