Developers

Send SMS with the Flexi API

A practical SMS4U guide for developers building HTTP SMS integrations with the TNZ Flexi API, including delivery-result and inbound-message webhooks.

Flexi API overview

The Flexi API accepts a range of input field names and maps them into a known SMS schema. This is useful when moving from another provider or connecting an existing system that already emits SMS-style JSON payloads.

HTTP POSTSubmit SMS messages using a simple HTTPS JSON request.
Flexible JSONCommon aliases such as to, mobile, destination, body, and message are recognised.
WebhooksReceive delivery results and inbound SMS messages at your own HTTPS endpoint.

Quick start

Send a POST request to the Flexi API endpoint with a JSON body containing the recipient, sender, and message content.

HTTP requestPOST /flexi/sms
POST https://flexiapi.tnz.co.nz/api/v2.04/flexi/sms
Content-Type: application/json; encoding='utf-8'
Accept: application/json; encoding='utf-8'

{
  "to": "+6421000001",
  "from": "5555",
  "body": "Hello, this is a test."
}
Accepted does not mean delivered. A successful API response means the message request has been accepted for processing. Delivery is reported later through result reporting and webhooks.

Send SMS

Endpointhttps://flexiapi.tnz.co.nz/api/v2.04/flexi/sms
MethodPOST
Content typeapplication/json; encoding='utf-8'
Required setupCreate an API-enabled user in the TNZ Dashboard and use the generated API credential with your request.

Example with message reference and callback URL

JSON request bodyapplication/json
{
  "destination_number": "+6421000001",
  "format": "SMS",
  "content": "Hello, this is a test.",
  "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
  "callback_url": "https://www.example.com/webhook"
}

Flexible field names

Use clear field names for new integrations. When migrating existing systems, Flexi API can recognise many common aliases.

PurposeCommon aliases
Recipient numberto, to_number, mobile, destination, destination_number, recipient, msisdn
Senderfrom, from_number, source, source_number
Message contentmessage, message_text, text, body, sms, content
Message referencemessage_id, messageid, message_uuid, Sid, MessageSid, batch_id
Callback URLcallback_url, StatusCallback, notifyUrl, webhook_url

Responses and status

StatusMeaning
200 OKMessage request accepted for processing.
400 Bad RequestInvalid or missing request variables.
401 UnauthorizedInvalid or missing API credential.
500 Internal Server ErrorAPI-side fault.

Webhooks

Use webhooks to receive asynchronous updates after the original API request. Your endpoint should accept HTTPS POST requests, respond quickly with a 2xx status, and process events idempotently.

Result webhook

The Result webhook is used for delivery-status events after a submitted message has been processed by the network. Store your original message reference, match webhook events to your message record, and update your internal message state.

Example result payload

Result webhook payloadapplication/json
{
  "Version": "v3.00",
  "Sender": "application@domain.com",
  "APIKey": "ta8wr7ymd",
  "Type": "SMS",
  "Destination": "+6421000001",
  "ContactID": "123e4567-e89b-12d3-a456-426614174000",
  "ReceivedID": null,
  "MessageID": "a1b2c3d4-e5f6-7890-1234-567890abcdee",
  "SubAccount": "Business Unit One",
  "Department": "Department Alpha",
  "JobNumber": "10AB20CE",
  "SentTimeLocal": "2025-06-13 08:44:16",
  "SendTimeUTC": "2025-06-12 20:44:16",
  "SentTimeUTC_RFC3339": "2025-06-12T20:44:16.000Z",
  "Status": "Success",
  "Result": "delivered",
  "Message": null,
  "Price": 0.1,
  "Detail": "SMSParts:2",
  "URL": "https://www.example.com/data"
}

Inbound SMS webhook

The Inbound SMS webhook is used when TNZ receives an inbound SMS for your account, such as a customer reply, keyword response, or short-code message. Use it to ingest replies into a CRM, helpdesk, database, or automation workflow.

Example inbound SMS payload

Inbound SMS webhook payloadapplication/json
{
  "Version": "v3.00",
  "Sender": "application@domain.com",
  "APIKey": "ta8wr7ymd",
  "Type": "SMSReply",
  "Destination": "+6421000001",
  "ContactID": "123e4567-e89b-12d3-a456-426614174000",
  "ReceivedID": "a1b2c3d4-e5f6-7890-1234-567890abcdee",
  "MessageID": "a1b2c3d4-e5f6-7890-1234-567890abcdee",
  "SubAccount": "Business Unit One",
  "Department": "Department Alpha",
  "JobNumber": "10AB20CE",
  "SentTimeLocal": "2025-06-13 08:44:16",
  "SendTimeUTC": "2025-06-12 20:44:16",
  "SentTimeUTC_RFC3339": "2025-06-12T20:44:16.000Z",
  "Status": "RECEIVED",
  "Result": "RECEIVED",
  "Message": "This is a received message from a mobile phone.",
  "Price": 0.1,
  "Detail": "InputToNumber:021-777909",
  "URL": "https://www.example.com/data"
}

FAQ

Can I send internationally?

Yes. International delivery is supported. Pricing and sender restrictions may vary by destination.

Is there a request-size limit?

The Flexi API documentation states a 20MB server-side maximum request size. Your HTTP client or application framework may have a smaller limit.

Why are long messages split?

SMS is billed and delivered in message parts. Longer messages are split into concatenated parts.

Is HTTPS supported?

Yes. Use HTTPS for API submissions and webhook endpoints.

Need help integrating SMS?

Start a trial to test the Flexi API, or contact sales if you need help mapping an existing integration into SMS4U.