Auth and headers

API keys, Idempotency-Key, and the other headers public v1 uses.

Pass the full key in X-API-Key. Keys can be limited by scope, expiry, IP allowlist, and per-key rate limits. See Rate limits for the defaults. Sandbox keys start with msnp_test_; Live keys start with msnp_live_. Live keys are not available on the Flex plan. See Sandbox.

Request: authenticated call

bash

curl -X GET "https://api.messengernepal.com.np/api/v1/sms/sender-ids" \
  -H "X-API-Key: msnp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Request headers you send:

  • X-API-Key (required on authenticated routes) - full secret from API Integration, then API Token
  • Content-Type: application/json (required on POST bodies)
  • Idempotency-Key (optional on send and OTP send) - client-chosen string so retries do not create a second charge; see below
  • X-Idempotency-Key - same meaning as Idempotency-Key (either header works)

You can also put idempotencyKey in the JSON body instead of a header. Header wins if both are present. Max length is 128 characters after trim.

What Idempotency-Key means: if your HTTP client times out or retries a POST /send (or OTP send), the platform looks up that key for your organization and environment. A replay of the same key returns the original accepted response and is not charged again. Omit the header only when every call is intentionally a new send; the API then generates an internal key. For bulk to lists, each recipient is stored as your-key:0, your-key:1, and so on.

Request: send with Idempotency-Key

bash

curl -X POST "https://api.messengernepal.com.np/api/v1/sms/send" \
  -H "X-API-Key: msnp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-notify-1001" \
  -d '{
    "to": "98XXXXXXX",
    "message": "Your order ships today."
  }'

Use a stable business id (order id, invoice id, login attempt id). Do not reuse the same key for a different message or recipient set. OTP send also accepts the header; OTP verify does not need it.

Response headers the API may set:

  • Retry-After - seconds to wait when the response is HTTP 429 (RATE_LIMIT_EXCEEDED); the JSON body also includes retry_after
  • Content-Type: application/json - normal success and error bodies

Webhook delivery headers (outbound to your URL, not on API calls you make) are documented on Webhooks: X-Msngr-Signature, X-Msngr-Timestamp, X-Msngr-Event, X-Msngr-Delivery-Id.

Unauthenticated discovery: GET https://api.messengernepal.com.np/api/v1/sms and GET https://api.messengernepal.com.np/api/v1/whatsapp (manifests), plus GET https://api.messengernepal.com.np/api/v1/sms/openapi.json and GET https://api.messengernepal.com.np/api/v1/whatsapp/openapi.json (OpenAPI).

Request: discovery (no key)

bash

curl -X GET "https://api.messengernepal.com.np/api/v1/sms"

Common auth failures:

  • NO_API_KEY if the header is missing
  • INVALID_API_KEY if the key is unknown, revoked, or malformed
  • API_KEY_EXPIRED if the key is past expiry
  • IP_RESTRICTED if the caller IP is not on the allowlist
  • KYC_REQUIRED or KYC_PENDING if a live key is used before dashboard KYC is approved (individual nagarita or national ID, or company registration plus letterhead cover letter; PAN optional) or the grace period ended
  • LIVE_API_NOT_APPROVED if live API access was not granted
  • FLEX_LIVE_API_BLOCKED if the wallet owner is on Flex (live keys and live API calls require Package or Enterprise)

Response: missing key (401)

json

{
  "success": false,
  "error": "API key required",
  "code": "NO_API_KEY"
}