When a bank sends you a one-time password, or an online store texts you that your order has shipped, that message usually arrives from a short number rather than a regular mobile number. That short number is a short code, and the software interface businesses use to send through it is a short code SMS API.
This guide explains what a short code SMS API is, how it works in Pakistan, how to set one up with the required KYC, what it costs, and how to send your first message with real code samples. It is written for developers and business owners who want to add SMS to a website or app without guessing at the steps.
What is a short code SMS API?
A short code is a short, memorable number used to send and receive text messages. Unlike a regular mobile number, a short code is designed for application-to-person messaging: the messages a business sends to its customers, such as verification codes, order updates and reminders. Short codes you may have seen in Pakistan include 8583, 8584 and 8286 — numbers that appear as the sender when a service texts you.
An SMS API is the programming interface that lets your website or app send those messages automatically. Instead of typing each message on a phone, your software makes a request to the provider's server, and the provider delivers the message to the recipient's handset. A short code SMS API combines the two: your application talks to an API, and the messages go out through a short code.
That combination matters for three reasons. First, recognition: customers learn to recognise messages from a short, consistent sender. Second, replies: a short code can receive replies and keyword messages, which turns one-way alerts into two-way conversations. Third, scale: an API can send one message or many, driven by events in your own system, such as a new signup or a dispatched order.
For a broader look at what a short-code service includes beyond the API itself, see our guide to short code SMS service in Pakistan.
How a short code SMS API works
Every message follows the same path, whether it is a single OTP or a bulk campaign:
- Your application sends a request to the API with the recipient's number and the message text.
- The provider checks your account, your balance and your permissions, and accepts the request.
- The message is routed through the short code to the recipient's mobile network.
- The network delivers it to the handset, and a delivery status travels back through the API.
Pak Sender's API is a REST API with the base URL https://paksender.com/api/v1. Requests use JSON, and every response uses the same envelope, so your code can handle success and failure in one place. The code samples later in this guide show the exact requests.
Dedicated vs shared short codes
Not every business needs its own short code, and the difference between dedicated and shared codes is the first decision to understand.
A shared short code is used by many businesses at once. Each business is separated by a keyword: customers text a keyword to the shared code, and the keyword decides which business receives the reply. Shared codes are the usual starting point, because the code is already live and you do not wait for a new number to be arranged. Pak Sender's platform short code is shared infrastructure: approved accounts send through it once their SMS permission and KYC are in place.
A dedicated short code belongs to one business alone. Every message and every reply on that code is yours, and customers see the same number every time. Dedicated codes suit larger senders who run keyword campaigns or two-way flows at volume and want a number that is unmistakably theirs.
| Shared short code | Dedicated short code | |
|---|---|---|
| Exclusive to your business | No — shared with other businesses | Yes — only your messages use it |
| Replies | Routed to you by keyword | All replies come to you |
| Setup | Available once KYC and SMS permission are approved | Arranged individually with support |
| Best for | OTP, alerts and order updates | High-volume keyword and two-way campaigns |
| Cost | Pay per message; no separate code fee published | No published fee — discuss with support |
Pak Sender publishes no dedicated short-code price or annual fee, and this guide will not invent one. If a dedicated code fits your plans, contact Pak Sender support to discuss availability and what it involves.
Short code vs sender ID vs long number
A short code is not the only way a message can be addressed. A branded sender ID is a name, such as your business name, shown as the sender instead of a number. A long number is a regular mobile number used for messaging. Each has its place:
| Sender | What customers see | Replies | Typical use |
|---|---|---|---|
| Short code | A short number | Yes — replies and keywords | OTP, alerts and two-way flows |
| Branded sender ID | Your business name | Usually one-way | Branded alerts and updates |
| Long number | A regular mobile number | Yes — like a normal number | Small-scale or personal messaging, such as the My SIM route |
With Pak Sender, the sender_id field on the send request is optional: you can pass an approved sender of up to 20 characters, or leave it empty to use the default sender. If a branded name matters more to you than a short number, read how to get a branded sender ID for SMS in Pakistan.
How to get a short code SMS API in Pakistan
Short-code messaging in Pakistan is a regulated channel, and setup follows a clear path. With Pak Sender, the steps are:
- Create your account. Register on Pak Sender and set up your dashboard.
- Complete KYC. Submit your CNIC, national ID or passport. For your protection and PTA compliance, SMS, voice, bulk and API access unlock after your KYC is approved. Email marketing works right away, so you can explore the dashboard while verification is in progress.
- Get your SMS permission. Once KYC is approved, your account's SMS permission is unlocked and short-code sending becomes available.
- Approve your website, app or IP. Short-code and SIM API access only works from an approved website, app or IP address. Submit your site or app in the dashboard and an admin approves it for the allow-list.
- Create an API key. API keys are created in the dashboard and shown only once, so store yours safely. You will use it in the authorisation header of every request.
- Send a test message. Try your first request in the API tester or from your own code with the samples below, then check the delivery status in your dashboard.
If you would rather send from your own phone number, the My SIM gateway is a different route: it sends through the My SIM Android gateway from your own number, and no short-code KYC is needed for it. The platform guide walks through both routes in more detail.
One API for all four networks: Jazz, Zong, Telenor and Ufone
Pakistan has four mobile operators — Jazz, Zong, Telenor and Ufone — and a common question is whether each one needs its own API. It does not. One integration with Pak Sender reaches all four networks: your application sends to the same endpoint, and the platform routes each message to the recipient's operator.
Numbers go in international format, such as +923001234567. If your users type a local number such as 03001234567, the API converts it to +92 automatically, so you do not need to normalise numbers yourself.
Pak Sender publishes a 99%+ delivery rate across its platform. This guide makes no per-operator delivery claims, because delivery depends on the handset, the network at that moment and the message itself — what matters is that a single API covers every operator your customers use.
Sending your first SMS: real API code samples
Authentication uses an API key, sent as Authorization: Bearer YOUR_API_KEY or as the X-API-Key header. GET endpoints also accept ?api_key=... for server-side use. Never put the key in browser code, a mobile app or a public repository. Requests send JSON with Content-Type: application/json and Accept: application/json, and the rate limit is 60 requests per minute.
To send an SMS, post to POST /messages/send-sms with receiver_number and message (maximum 800 characters). The optional sender_id holds an approved sender of up to 20 characters; leave it empty to use the default sender. Here is the request with curl:
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 order has shipped.", "sender_id": "YOUR_SENDER"}'
The same request in PHP, using cURL:
<?php
$apiKey = 'YOUR_API_KEY';
$data = [
'receiver_number' => '+923001234567',
'message' => 'Your order has shipped.',
'sender_id' => 'YOUR_SENDER',
];
$ch = curl_init('https://paksender.com/api/v1/messages/send-sms');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Accept: application/json',
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
A successful response uses the standard envelope:
{
"status": "success",
"message": "...",
"data": {
"message_id": "msg_xxx",
"reference_id": "ref_xxx",
"status": "sent",
"parts": 1,
"cost": 4.30,
"remaining_balance": 995.70
}
}
Read the status field inside data: a message starts as sent and becomes delivered when the handset confirms receipt. The response also tells you how many parts the message used, what it cost and your remaining balance. Full details, including bulk sending to many numbers in one request, are in the API documentation, and our SMS API integration guide covers the wider integration in more depth.
OTP verification in two API calls
One-time passwords are the most common use of a short code API, and Pak Sender offers a managed verification flow that handles code generation, storage and expiry for you.
First, start a verification with POST /v1/verifications/start. You send the channel (sim, sms or email), the recipient, and your app_name (or its alias brand). You can also set expire_time from 1 to 30 minutes (default 10), length from 4 to 8 digits (default 6), and a template with the placeholders {code}, {app} and {minutes}. The code is stored hashed and is never returned — the response gives you only a request ID, a pending status, the expiry and the cost:
curl -X POST https://paksender.com/api/v1/v1/verifications/start \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"channel": "sms", "recipient": "+923001234567", "app_name": "MyApp", "expire_time": 5, "length": 6}'
{
"status": "success",
"message": "...",
"data": {
"request_id": "vr_xxx",
"status": "pending",
"expires_in": 300,
"cost": 4.30
}
}
The recipient receives a message like this: "482913 is your verification code for MyApp. It is valid for 5 minutes. Do not share this code with anyone."
Then verify the code the user types in:
curl -X POST https://paksender.com/api/v1/v1/verifications/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"request_id": "vr_xxx", "code": "482913"}'
{
"status": "success",
"message": "Code verified",
"data": { "status": "verified", "verified": true }
}
If the code is wrong, the API returns CODE_INVALID with attempts_remaining; after five wrong tries the verification locks (CODE_LOCKED). An expired code returns CODE_EXPIRED. Use the sms channel for short-code delivery — it needs the SMS permission and approved KYC. The sim channel needs only the SIM permission, and email needs an active SMTP connection.
If your own system already generates codes, use the delivery flow instead: POST /v1/verifications/send takes the channel and recipient plus either your code — which is wrapped into a standard verification message — or a full message of your own, plus your app name:
curl -X POST https://paksender.com/api/v1/v1/verifications/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"channel": "sms", "recipient": "+923001234567", "code": "482913", "app_name": "MyApp"}'
Note the full URLs exactly as documented: the verification paths sit under the API base, so a start request goes to https://paksender.com/api/v1/v1/verifications/start, with the version segment appearing twice. Write it that way in your code.
Delivery statuses and error handling
Every send returns a status, and your code should branch on the stable error_code field, not on the human-readable message text. The statuses you will see most often are sent, meaning the message was accepted and handed to the network, and delivered, meaning the handset confirmed receipt. Voice OTP adds its own final results: answered counts as delivered, unanswered expires, and busy or rejected calls fail.
Two error codes are worth handling first: KYC_REQUIRED (HTTP 403) means the account must complete KYC before SMS and voice unlock, and INVALID_NUMBER means the recipient number could not be used. If you exceed 60 requests per minute, the API answers with HTTP 429 — slow your requests down and retry. The API documentation lists the full set of codes and statuses.
Transparent pricing: what one message really costs
Pak Sender charges per message from one PKR balance. There are no hidden fees, no monthly charges and no setup costs, and volume discounts are available, although no discount figures are published.
| Channel | Price |
|---|---|
| SMS | Rs 4.30 per SMS part |
| Voice OTP | Rs 5.00 per call — refunded if not answered |
| Voice call | Rs 4.00 per call |
| Rs 0.30 per email | |
| My SIM SMS | Rs 0.50 software fee per SMS part — refunded if the phone cannot send; the SIM's own package pays for the SMS itself |
An SMS "part" is how long messages are counted. A message in English (GSM-7) holds 160 characters in one part, or 153 characters per part when the message runs long. A message with Urdu, Arabic or emoji switches to Unicode: 70 characters for one part, 67 per part in long messages. A single Unicode character switches the whole message to Unicode, and the characters ^ { } \ [ ] ~ | € count as two in standard text. The maximum message length is 800 characters.
The arithmetic is straightforward: 1,000 single-part English messages cost 1,000 × Rs 4.30 = Rs 4,300. You are charged only when a request is accepted — a response with "status": "success" — so a rejected request costs nothing. See the rates in the API documentation or the pricing section on the Pak Sender homepage.
Use cases by industry
Short code SMS fits anywhere a business must reach a customer reliably and be recognised when it does. If you are comparing providers, our overview of Pak Sender as a short code SMS service provider in Pakistan explains what the platform offers beyond the API.
OTP and logins
Signup verification, login codes and password resets are the classic short-code use case. A short, recognisable sender helps customers spot the real code among their messages, and the managed verification flow handles expiry and lockout so your team does not have to build it.
Banking and fintech alerts
Transaction alerts, balance notifications and fraud warnings need a sender customers trust at a glance. Short codes give banks and fintech apps a consistent identity for alerts, while voice OTP offers a fallback channel when a customer cannot read a text message.
E-commerce order updates
Order confirmations, dispatch notices, delivery alerts and cash-on-delivery reminders keep customers informed and cut down "where is my order" support messages. Bulk sending handles campaigns and sale announcements to many numbers in one request.
Healthcare and school reminders
Clinics send appointment reminders and lab-result notifications; schools send fee reminders, exam schedules and closure notices. In both cases the message must arrive on time and be clearly from the institution, which is exactly what a short code provides.
Two-way keyword flows
Because a short code can receive replies, customers can text a keyword to subscribe, confirm, vote or opt out. Shared codes route those replies by keyword, while a dedicated code gives one business every reply on its number.
Whatever your industry, the fastest way to start is the path above: register, complete KYC, approve your website or app, create an API key and send a test message. From there, the API scales with you — one message or a bulk campaign, to any network in Pakistan.
Frequently asked questions
Is there a free short code SMS API in Pakistan?
There is no free lunch in messaging: every SMS travels over a mobile network that charges for delivery, so a genuinely free and unlimited short code API does not exist. What you can find are low-barrier ways to start. Pak Sender charges no monthly fee and no setup cost — you pay per message, so a small test of a few messages costs only a few rupees, and you can prove the integration works before spending more.
How much does an SMS API cost in Pakistan?
With Pak Sender, an SMS costs Rs 4.30 per part, with voice OTP at Rs 5.00 per call and email at Rs 0.30 per message. The final cost of a message depends on its length and alphabet: English messages hold 160 characters per part, while Urdu, Arabic or emoji messages hold 70. There are no monthly or setup fees, so your spend is simply the number of parts you send.
Do I need a separate Jazz or Telenor SMS API?
No. One Pak Sender integration reaches Jazz, Zong, Telenor and Ufone, so there is no need to integrate a separate API per operator or to detect which network a number belongs to. Send every message to the same endpoint and the platform routes it.
How do I get a short code, and how is it different from a sender ID?
To get started, register on Pak Sender, complete KYC with a CNIC, national ID or passport, get your SMS permission, approve your website, app or IP, and create an API key — then you send through the platform's shared short code. A sender ID is different: it is a name, up to 20 characters, shown as the sender instead of a number, and it is used for one-way branded messages rather than a shared reply number. A dedicated short code of your own is arranged by contacting support.