REST API reference
Send SMS, check balances and configure callbacks over IPv4 or IPv6.
Authentication
Start with https://smsgw.uk/api/v1. Generate a token in API settings and include Authorization: Bearer YOUR_TOKEN. The token can only access its own account. Send JSON with Content-Type: application/json.
Endpoints
| Method and path | Purpose |
|---|---|
GET /balance | Return the available credit balance. |
POST /messages/quote | Quote a destination and content before sending. Set flash to true for a flash SMS quote. Returns the destination country code, encoding, units, segments, cost, message type and any compatibility warning. |
POST /messages | Send with source, destination and content. Use "flash": true for flash SMS. Copy the quote’s cost into expected_cost to reject a changed quote. The API accepts up to four decimal places in expected_cost. |
GET /messages/sent | List your sent messages. |
GET /messages/incoming | List received SMS. Locked keyword messages omit the body until your balance is positive. |
GET /messages/{id} | Get a message by its gateway reference, including delivery reports. |
GET /callbacks | Read the registered callback URLs. |
PUT /callbacks | Set incoming_callback and delivery_callback. Send both keys. Use null to disable an event. |
Send a message
Your account can send to the UK and any international destinations approved by Staff. Use a verified telephone number, an active dedicated number you rent, or an alphanumeric sender ID approved for the recipient’s country. Manage sender IDs in the portal.
curl -X POST 'https://smsgw.uk/api/v1/messages' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: example-order-001' \
-d '{"source":"YourCompany","destination":"YOUR_RECIPIENT_NUMBER","content":"Your order is ready.","expected_cost":1}'
The optional flash flag defaults to false. Use the same value when quoting and sending. Flash SMS uses the standard destination tariff and may appear directly on the recipient’s screen, depending on the device. Outgoing message records and delivery callbacks include the flash flag.
Supply a distinct Idempotency-Key for each intended send. Repeating it with the same message returns the original record. Changing the message or its flash setting with the same key returns 409. A new accepted submission returns 201. 202 means submission is pending or uncertain. Use the Location header to check the outcome. 422 indicates invalid input, an unsupported destination, a changed cost or insufficient credit. 502 indicates the supplier declined submission and the credits were returned.
Callbacks
The gateway sends JSON by POST for sms.incoming and sms.delivery. Each event has an id, an event and a message. Delivery events also include a report. Locked incoming events omit the message body. Use the message ID to fetch the body after topping up.
Use the signing secret from API settings to verify X-SMSGW-Signature. Calculate HMAC-SHA256 over the value of X-SMSGW-Timestamp, a period, and the raw request body. Compare the hex digest against the header after sha256= with a constant-time comparison. Reject stale timestamps and de-duplicate by event ID.
Use an HTTPS hostname on port 443 with a public IPv4 address (DNS A record), a public IPv6 address (DNS AAAA record), or both. Return a 2xx response to acknowledge. Failed callbacks are retried up to four times.