Your software sends an SMS, and your customer sees your brand name — not a random number. That is what the SMS masking API does: it lets your website, app or backend send branded SMS through one API call, with your registered sender ID on every message. This guide shows how the masking API works in Pakistan, with working code samples.

If you are new to branded SMS, read our branded SMS guide first — it explains masks and PTA rules. This post is for developers: the API calls, the parameters, and the errors to handle.

What a masking API is

A masking API is an SMS API that accepts a sender ID — a mask — with each send request. Instead of the message arriving from a number, it arrives from your brand name. The mask is registered with PTA in your business's own name, and the API only accepts masks that are approved on your account.

Masking is not a separate product from SMS. It is the same send endpoint with one extra parameter, and the same balance, delivery reports and rate limits — no second integration for branded messages.

How masking works: one parameter

On Pak Sender, masking is the sender_id parameter of the send SMS endpoint. The endpoint is POST /messages/send-sms on the base URL https://paksender.com/api/v1, authenticated with Authorization: Bearer YOUR_API_KEY or X-API-Key: YOUR_API_KEY.

The sender_id field is optional: an approved sender, up to 20 characters, and when empty the message goes out with the default sender. Approve a mask once, then use it in any send request. An unapproved mask is rejected — handle that error, covered below.

Numbers go in international format, such as +923001234567 (local numbers starting with 0 are converted to +92 automatically). Messages can be up to 800 characters, and the response returns the message ID, status, part count, cost and remaining balance.

Code samples: sending a masked SMS

A masked send with curl. Replace the API key and sender ID with your own, and never put the key in browser code or a public repository — server-side calls only.

curl -X POST https://paksender.com/api/v1/messages/send-sms \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "receiver_number": "+923001234567",
    "message": "Your verification code is 482913. It expires in 5 minutes.",
    "sender_id": "PAKSENDER"
  }'

The response uses the standard envelope, with the delivery status starting at sent and moving to delivered when the handset confirms:

{
  "status": "success",
  "message": "SMS sent successfully",
  "data": {
    "message_id": "msg_xxxxxxxxxxxx",
    "reference_id": "ref_xxxxxxxxxxxx",
    "status": "sent",
    "parts": 1,
    "cost": 4.30,
    "remaining_balance": 995.70
  }
}

The same call in plain PHP, using curl:

$ch = curl_init('https://paksender.com/api/v1/messages/send-sms');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'receiver_number' => '+923001234567',
        'message' => 'Your order #4821 is out for delivery.',
        'sender_id' => 'PAKSENDER',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);

if (($response['status'] ?? '') === 'success') {
    $messageId = $response['data']['message_id'];
    // Store $messageId and check its delivery status later.
}

Store the message_id for every send. It is how you follow the message from sent to delivered, and what support will ask for when a customer says a message never arrived.

Getting your mask approved first

Masking only works with an approved mask, so sort out approval before you write the integration. The mask is registered with PTA in your business's own name: 3 to 11 English characters, matching your NTN business name, in either the Promotional or the Informational category. The application needs a letterhead application, the representative's CNIC, the company NTN, and a stamp and signature.

On Pak Sender, the path is: create an account, complete KYC, and apply for your mask. Our guide on how to get a branded sender ID walks through the documents and steps. Start early — approval takes time, and it is the one part of a masking integration you cannot rush.

Bulk sends with a mask

Campaigns use the same mask in the bulk endpoint, POST /messages/send-bulk-sms, which sends to many numbers in one request. One request, one sender ID, one balance deduction per part. Prefer the bulk endpoint over hundreds of single sends: it is faster, it keeps you inside the rate limit of 60 requests per minute, and it gives you one response to log.

Keep bulk messages under the part limits: a GSM-7 English message of up to 160 characters is one part; a Unicode message (Urdu, Arabic, emoji) of up to 70 characters is one part. One emoji switches the whole message to Unicode, so test the part count on one number before you send to thousands.

Errors to handle

Branch on the stable error_code, not on the message text. The codes you will meet most with masking are KYC_REQUIRED (403 — complete KYC before SMS and voice unlock), INVALID_NUMBER (the recipient number is not valid), and the sender error when the sender_id is not approved on your account. A 429 means you hit the 60-requests-per-minute limit: slow down and retry with backoff, and never retry a request that already succeeded — check its status first, because a timed-out send may have gone through.

Test each error path before you go live: an invalid number, and an unapproved sender ID — confirm both are caught and logged, not shown to the user. The live API tester lets you try requests without writing code, and the API documentation lists the endpoints and error codes in full.

Our pick: the best masking API in Pakistan

Our top pick for the SMS masking API in Pakistan is Pak Sender: masking is one parameter on a documented REST API, with a live tester, clear error codes, bulk sending, live delivery reports and one PKR balance — no monthly or setup fees, with prices starting from Rs 0.30. That is our number 1 masking API choice, and our editorial pick. For the wider picture, see our guide to the best SMS service provider in Pakistan.

Frequently asked questions

What is SMS masking?

SMS masking is sending SMS with a registered brand name — a mask — shown as the sender instead of a phone number. In Pakistan the mask is registered with PTA in the business's own name, and the API sends it through the sender_id parameter.

Do I need PTA approval to use a mask in the API?

Yes. The API only accepts masks approved on your account. Approval needs KYC and a PTA mask registration in your business name, so start the process before you build the integration.

What happens if I send with an unapproved sender_id?

The request is rejected. Your code should branch on the error code, log the failure, and fall back to the default sender only if that is acceptable for the message — never silently send an OTP from the wrong sender.

Can I use different masks for OTP and marketing?

Yes, and you should. Register one mask in the Informational category for OTP and alerts, and another in the Promotional category for marketing. The same mask cannot be used for both, so keep the two apart in your code.