OTP SMPP Setup
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 thesystem_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:
- The server parses the request content and uses the SMS channel for delivery.
- Messages are delivered in synchronous mode, and results will be responded with the
SUBMIT_SM_RESP
command (0x80000004
). - Delivery reports will be sent, as detailed in the Delivery Report section.
- 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:
- service_type
- Values:
MSG
/CODE
/MRKT
- Default:
MSG
- Values:
- source_addr
- Can be left blank; not used in OTP currently.
- destination_addr
- The target of the message, must be in the international phone number format (e.g.,
+8613800138000
).
- The target of the message, must be in the international phone number format (e.g.,
- 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 } }
โค้ดนี้โชว์เป็นหน้าต่างลอย
- The message content in JSON format, as shown below:
- 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.
- It is recommended to use
- header status
- Set to
0x00000000
.
- Set to
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:
- service_type
- Fixed value:
MSG
- Fixed value:
- source_addr
- Blank.
- destination_addr
- Matches the
destination_addr
field in theSUBMIT_SM
command.
- Matches the
- data_coding
- Encoding method: Default value
0x00
.
- Encoding method: Default value
- esm_class
- Set to
0x00
.
- Set to
- short_message
- Encapsulates the delivery report in
delivery receipt
format.
- Encapsulates the delivery report in
- ReceiptedMessageID in tlv
- The message ID for association.
- MessageState in tlv
- The message state, field value
0x0427
.
- The message state, field value
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:
EnquireLink
command (0x00000015
)Unbind
command (0x00000006
)SubmitSM
command (0x00000004
)DeliverSMResp
command (0x80000005
)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.