Every SMS integration hits an error sooner or later. A number is typed wrong, a verification code expires, or a burst of traffic trips a rate limit. What matters is not that errors happen, but that your code understands them and responds the right way instead of failing silently or retrying blindly.

This guide explains the error codes and delivery statuses you will actually see on the Pak Sender API, what each one means, and what your application should do next. It covers the codes documented in the API documentation, so you can build your error handling on facts rather than guesswork.

How Pak Sender reports errors

Every API response uses the same envelope. A successful call returns "status": "success" with a data object. A failed call returns "status": "error" with a human-readable message and, where one applies, a stable error_code:

{
  "status": "error",
  "message": "Invalid receiver number",
  "error_code": "INVALID_NUMBER"
}

Branch your code on error_code, not on message. Messages are written for humans and may be reworded; error codes are stable identifiers your code can rely on. Log the full response, including the message, so support can help quickly if you need to ask a question.

Sending errors

INVALID_NUMBER

This means the receiver number could not be accepted as a valid phone number. Pak Sender expects numbers in international format, such as +923001234567; a local number like 03001234567 is converted to +92 automatically, so a number that still fails is usually mistyped, incomplete, or missing digits. Do not retry the same number. Instead, show the user a clear message, let them correct the number, and validate the format in your own form before the request leaves your server. If numbers come from an imported list, clean the list first and re-send only the corrected entries.

KYC_REQUIRED

This is a 403 response that means the account has not completed the approval step required for SMS and voice. Short-code SMS requires the account's SMS permission plus approved KYC, and the same approval unlocks voice, bulk and API sending. The fix is not in your code: complete KYC in the dashboard with a CNIC, national ID or passport, and wait for approval. Until then, your integration should surface a clear account-level message rather than retrying the request, because no retry will succeed while the account is unapproved. Email marketing works right away, but SMS and voice stay locked until KYC is approved.

HTTP 429: rate limit exceeded

The API allows 60 requests per minute. If your application sends more than that, further requests are rejected with HTTP 429. This is a temporary limit, not a ban, and the correct response is to slow down. Pause, then retry the failed requests after a short wait, and spread bulk work across time instead of firing everything at once. If you regularly hit the limit, queue your sends and pace them under 60 per minute. Never retry a 429 immediately in a tight loop: that only extends the problem.

Verification failures

The managed verification flow has its own set of failure codes, returned when a code is checked with the verify endpoint. Knowing which one you received tells you exactly what to show the user:

Error codeWhat it meansWhat to do
CODE_INVALIDThe code entered does not match. The response includes attempts_remaining.Let the user try again and show how many attempts are left.
CODE_EXPIREDThe code's validity window has passed.Ask the user to request a fresh code.
CODE_LOCKEDThe verification is locked after 5 wrong tries.Start a new verification; the old one cannot be unlocked by retrying.
VERIFICATION_NOT_FOUNDNo verification matches the given request ID.Check the request_id you stored, then start a new verification if needed.

Remember that the code itself is stored hashed and is never returned by the API. Your application only ever receives a request_id, a pending status, an expiry time and the cost, so keep the request_id safe and pass it back with the code the user enters.

Delivery statuses: sent, then delivered

A successful send response does not mean the message is already on the phone. It means the request was accepted and the message is on its way. The status field in the response starts as sent and changes to delivered when the handset confirms receipt. Treat sent as "accepted by the network and in transit" and delivered as "confirmed on the handset". A message can sit at sent for a while if the phone is switched off or out of coverage, so build your user interface around both states instead of treating sent as the final word. For practical tips on keeping delivery high, see our guide on how to improve SMS delivery rates and avoid failed messages.

Voice OTP results

Voice OTP calls finish with one of three results. delivered means the call was answered, expired means it was not answered, and failed means the call was busy, rejected, or failed. A voice OTP call costs Rs 5.00 and is refunded if it is not answered, so an expired result costs you nothing. When a voice OTP expires or fails, the sensible next step is to offer the user another attempt or a different channel, such as SMS, rather than repeating the same call immediately.

What to build into your integration

  • Branch on error_code, not on message text. Codes are stable; wording is not.
  • Never retry a rejected number or an unapproved account. Fix the input or complete KYC first.
  • Back off on 429. Queue and pace sends under 60 requests per minute.
  • Track the message_id from every send response. It is your reference for delivery status and support queries.
  • Show users the next step, not the raw error. "Please check your number and try again" beats a bare code every time.

If you want to see these responses for yourself before writing code, try the API tester or follow the SMS API integration guide for a full walkthrough.

Frequently asked questions

What should my code check first when an API call fails?

Check error_code first. It is the stable identifier for the failure, while the message field is written for humans and may change. Log both, and branch your handling on the code.

Why am I getting KYC_REQUIRED when my API key works?

The key is valid, but the account has not completed KYC approval. SMS, voice, bulk and API sending unlock only after KYC is approved with a CNIC, national ID or passport. Complete KYC in the dashboard and the same key will work.

Does "sent" mean the message was delivered?

No. sent means the message was accepted by the network and is in transit. It changes to delivered only when the handset confirms receipt. Always treat the two states separately in your interface and your records.

What happens after five wrong verification attempts?

The verification becomes CODE_LOCKED and cannot be completed. Start a new verification to issue a fresh code, and tell the user clearly that a new code has been sent.