{"openapi":"3.0.3","info":{"title":"Messenger Nepal Public WhatsApp API","version":"1.0.0","description":"Public WhatsApp API v1. Authenticate with the X-API-Key header. Sandbox (`msnp_test_`) keys work without KYC on any plan. Live (`msnp_live_`) keys and live send require a Package or Enterprise plan (not Flex), approved dashboard KYC (or an active grace period), plus a separate live API approval. Dashboard KYC is either an individual package (nagarita or national ID) or a company package (company registration and a letterhead cover letter; PAN is optional). Package/Enterprise may be prepaid or a postpaid credit pool; live send still debits shared User.credits. Path prefix is /api/v1/whatsapp. Scope whatsapp:send is required for send, templates, and message status. Scope whatsapp:otp is required for OTP send and verify. Default rate limits are 60 requests per minute and 1000 per hour per API key. Send accepts up to 1000 recipients. Live traffic may return KYC_REQUIRED, KYC_PENDING, LIVE_API_NOT_APPROVED, or FLEX_LIVE_API_BLOCKED."},"servers":[{"url":"https://api.messengernepal.com.np","description":"Production"}],"tags":[{"name":"Discovery","description":"Unauthenticated manifest and OpenAPI spec"},{"name":"Send","description":"Send WhatsApp template and session messages (scope whatsapp:send)"},{"name":"Templates","description":"List approved WhatsApp templates (scope whatsapp:send)"},{"name":"Messages","description":"Read public WhatsApp message status (scope whatsapp:send)"},{"name":"OTP","description":"Send and verify one-time passwords over WhatsApp (scope whatsapp:otp)"}],"security":[{"ApiKeyAuth":[]}],"paths":{"/api/v1/whatsapp":{"get":{"tags":["Discovery"],"summary":"API manifest","description":"Lists public WhatsApp v1 endpoints, auth header, and error codes. No API key required.","operationId":"getWhatsappManifest","security":[],"responses":{"200":{"description":"Manifest","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManifestResponse"}}}}}}},"/api/v1/whatsapp/openapi.json":{"get":{"tags":["Discovery"],"summary":"OpenAPI 3 specification","description":"This document. No API key required.","operationId":"getWhatsappOpenApi","security":[],"responses":{"200":{"description":"OpenAPI 3 JSON","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/whatsapp/send":{"post":{"tags":["Send"],"summary":"Send a WhatsApp template","description":"Accepts an approved template for one or more recipients. Provide template_name or template_id. Optional language, header_params, body_params, and phone_number_id. Scope: whatsapp:send.","operationId":"sendWhatsappTemplate","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateSendRequest"},"examples":{"template":{"summary":"Approved template","value":{"to":"9800000000","template_name":"order_update","variables":{"name":"Ada"}}},"bulkTemplate":{"summary":"Bulk template recipients","value":{"to":["9800000000","9700000000"],"template_name":"order_update","variables":{"name":"Ada"}}}}}}},"responses":{"202":{"$ref":"#/components/responses/SendAccepted"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/Error"}},"x-codeSamples":[{"lang":"bash","label":"cURL","source":"curl -X POST \"/api/v1/whatsapp/send\" \\\n  -H \"X-API-Key: msnp_live_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: wa-template-1\" \\\n  -d '{\"to\":\"9800000000\",\"template_name\":\"order_update\",\"variables\":{\"name\":\"Ada\"}}'"}]}},"/api/v1/whatsapp/send/text":{"post":{"tags":["Send"],"summary":"Send a WhatsApp session message","description":"Sends free-form text only when the customer service window is open (24 hours after an inbound message). Scope: whatsapp:send.","operationId":"sendWhatsappText","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TextSendRequest"},"examples":{"sessionText":{"summary":"Session text inside 24h window","value":{"to":"9800000000","message":"Thanks for your reply. Your ticket is open."}}}}}},"responses":{"202":{"$ref":"#/components/responses/SendAccepted"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/Error"}}}},"/api/v1/whatsapp/templates":{"get":{"tags":["Templates"],"summary":"List approved templates","description":"Returns APPROVED templates owned by the organization. Scope: whatsapp:send.","operationId":"listWhatsappTemplates","responses":{"200":{"description":"Approved templates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListResponse"},"examples":{"list":{"summary":"Approved templates","value":{"success":true,"data":{"templates":[{"id":"6621bb22cc33dd44ee55ff66","name":"order_update","language":"en","category":"UTILITY","status":"APPROVED","components":[]}]}}}}}}},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"}}}},"/api/v1/whatsapp/messages/{messageId}":{"get":{"tags":["Messages"],"summary":"Get message status","description":"Returns status for a public WhatsApp send belonging to this organization. Live includes status, recipient, timestamps, and cost. Sandbox also includes body or template preview. Scope: whatsapp:send.","operationId":"getWhatsappMessage","parameters":[{"name":"messageId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Message status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageStatusResponse"},"examples":{"delivered":{"summary":"Delivered","value":{"success":true,"data":{"message_id":"661f0a1b2c3d4e5f67890123","dispatch_id":"661f0a1b2c3d4e5f67890123","job_id":"661f0a1b2c3d4e5f67890123","status":"delivered","environment":"live","recipient":"9800000000","cost":1,"created_at":"2026-04-02T09:00:00.000Z","submitted_at":"2026-04-02T09:00:02.000Z","delivered_at":"2026-04-02T09:00:08.000Z","read_at":null,"failed_at":null}}}}}}},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/api/v1/whatsapp/otp/send":{"post":{"tags":["OTP"],"summary":"Send a WhatsApp OTP","description":"Requires an approved AUTHENTICATION template (template_id or template_name). Optional language, ttl_seconds (clamped to 30-900, default 300), and phone_number_id. Scope: whatsapp:otp.","operationId":"sendWhatsappOtp","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsappOtpSendRequest"},"examples":{"send":{"summary":"Send WhatsApp OTP","value":{"to":"9800000000","ttl_seconds":300}}}}}},"responses":{"202":{"description":"OTP accepted for delivery","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsappOtpSendResponse"},"examples":{"accepted":{"summary":"OTP accepted","value":{"success":true,"data":{"challenge_id":"ch_8f3a2b1c0d9e","dispatch_id":"661f0a1b2c3d4e5f67890123","message_id":"661f0a1b2c3d4e5f67890123","expires_at":"2026-04-02T08:20:00.000Z","cost":1,"remaining_balance":481,"environment":"live"}}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/Error"}}}},"/api/v1/whatsapp/otp/verify":{"post":{"tags":["OTP"],"summary":"Verify a WhatsApp OTP code","description":"to and code are required. Optional challenge_id selects a specific challenge. Scope: whatsapp:otp.","operationId":"verifyWhatsappOtp","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsappOtpVerifyRequest"},"examples":{"verify":{"summary":"Verify OTP","value":{"to":"9800000000","code":"123456","challenge_id":"ch_8f3a2b1c0d9e"}}}}}},"responses":{"200":{"description":"Verified","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsappOtpVerifyResponse"},"examples":{"verified":{"summary":"Verified","value":{"success":true,"data":{"verified":true,"challenge_id":"ch_8f3a2b1c0d9e","dispatch_id":"661f0a1b2c3d4e5f67890123"}}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Organization API key from the dashboard API Token page. Shown only once at creation."}},"parameters":{"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Optional key for send and OTP send. Also accepted as X-Idempotency-Key or as the JSON field idempotencyKey (header wins if both are sent). Max 128 characters. Replaying the same key for the same organization and environment returns the original accepted send and is not charged again. When one request has several recipients, each recipient is stored under that key plus a colon and a zero-based index (key:0, key:1, ...). Omit only when every call is intentionally a new send."}},"schemas":{"ErrorEnvelope":{"type":"object","required":["success","error","code"],"properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"string"},"code":{"$ref":"#/components/schemas/ErrorCode"}}},"ErrorCode":{"type":"string","enum":["VALIDATION_ERROR","NO_API_KEY","INVALID_API_KEY","API_KEY_EXPIRED","ORG_INACTIVE","IP_RESTRICTED","INSUFFICIENT_PERMISSIONS","MISSING_TO","MISSING_MESSAGE","INVALID_TO_FORMAT","TOO_MANY_RECIPIENTS","INSUFFICIENT_CREDITS","ACCESS_DENIED","RATE_LIMIT_EXCEEDED","TEMPLATE_NOT_FOUND","TEMPLATE_NOT_APPROVED","NO_CREDENTIAL","SESSION_WINDOW_EXPIRED","WHATSAPP_OTP_TEMPLATE_REQUIRED","OTP_NOT_FOUND","OTP_EXPIRED","OTP_INVALID","OTP_LOCKED","OTP_TEMPLATE_MISSING_CODE","OTP_TEMPLATE_NOT_FOUND","MESSAGE_NOT_FOUND","SERVICE_UNAVAILABLE","KYC_REQUIRED","KYC_PENDING","KYC_REJECTED","LIVE_API_NOT_APPROVED","FLEX_LIVE_API_BLOCKED"]},"DeliveryStatus":{"type":"string","enum":["accepted","sending","sent","delivered","read","failed","unknown","cancelled","scheduled"]},"RecipientTo":{"oneOf":[{"type":"string","example":"9800000000"},{"type":"array","items":{"type":"string"},"maxItems":1000}],"description":"Single MSISDN, CSV string, or array. Max 1000 recipients."},"TemplateSendRequest":{"type":"object","required":["to"],"properties":{"to":{"$ref":"#/components/schemas/RecipientTo"},"template_name":{"type":"string"},"template_id":{"type":"string"},"language":{"type":"string","example":"en"},"header_params":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"body_params":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"phone_number_id":{"type":"string","description":"Optional connected WhatsApp phone number id. Defaults to the oldest active number for the organization owner."},"idempotencyKey":{"type":"string"}}},"TextSendRequest":{"type":"object","required":["to","message"],"properties":{"to":{"$ref":"#/components/schemas/RecipientTo"},"message":{"type":"string"},"phone_number_id":{"type":"string"},"idempotencyKey":{"type":"string"}}},"AcceptedDispatch":{"type":"object","properties":{"dispatch_id":{"type":"string"},"job_id":{"type":"string"},"message_id":{"type":"string"},"status":{"$ref":"#/components/schemas/DeliveryStatus"},"environment":{"type":"string","enum":["live","sandbox"]},"recipient":{"type":"string","nullable":true},"cost":{"type":"number","nullable":true},"remaining_balance":{"type":"number","nullable":true},"remaining_credits":{"type":"number","nullable":true},"batch_id":{"type":"string"},"charged":{"type":"boolean","description":"`false` when the send used a Sandbox key. Not included on Live-key sends."}}},"SendAcceptedSingle":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string"},"data":{"$ref":"#/components/schemas/AcceptedDispatch"}}},"SendAcceptedBulk":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string"},"data":{"type":"object","properties":{"batch_id":{"type":"string"},"environment":{"type":"string","enum":["live","sandbox"]},"total_count":{"type":"integer"},"accepted_count":{"type":"integer"},"failed_count":{"type":"integer"},"total_cost":{"type":"number"},"remaining_balance":{"type":"number","nullable":true},"remaining_credits":{"type":"number","nullable":true},"dispatches":{"type":"array","items":{"$ref":"#/components/schemas/AcceptedDispatch"}},"dispatch_ids":{"type":"array","items":{"type":"string"}},"job_ids":{"type":"array","items":{"type":"string"}}}}}},"TemplateListResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"templates":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"category":{"type":"string"},"status":{"type":"string"},"components":{"type":"array","items":{"type":"object"}}}}}}}}},"MessageStatusResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"message_id":{"type":"string"},"dispatch_id":{"type":"string"},"job_id":{"type":"string"},"status":{"$ref":"#/components/schemas/DeliveryStatus"},"environment":{"type":"string","enum":["live","sandbox"]},"recipient":{"type":"string","nullable":true},"cost":{"type":"number","nullable":true},"created_at":{"type":"string","format":"date-time","nullable":true},"submitted_at":{"type":"string","format":"date-time","nullable":true},"delivered_at":{"type":"string","format":"date-time","nullable":true},"read_at":{"type":"string","format":"date-time","nullable":true},"failed_at":{"type":"string","format":"date-time","nullable":true},"body":{"type":"string","nullable":true},"template":{"type":"object","nullable":true}}}}},"WhatsappOtpSendRequest":{"type":"object","required":["to"],"properties":{"to":{"type":"string","example":"9800000000"},"template_id":{"type":"string"},"template_name":{"type":"string"},"language":{"type":"string","example":"en"},"ttl_seconds":{"type":"integer","minimum":30,"maximum":900,"default":300},"phone_number_id":{"type":"string"}}},"WhatsappOtpSendResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"challenge_id":{"type":"string"},"dispatch_id":{"type":"string"},"message_id":{"type":"string"},"expires_at":{"type":"string","format":"date-time"},"cost":{"type":"number"},"remaining_balance":{"type":"number","nullable":true},"environment":{"type":"string","enum":["live","sandbox"]},"charged":{"type":"boolean","description":"`false` when the send used a Sandbox key. Not included on Live-key sends."}}}}},"WhatsappOtpVerifyRequest":{"type":"object","required":["to","code"],"properties":{"to":{"type":"string"},"code":{"type":"string"},"challenge_id":{"type":"string"}}},"WhatsappOtpVerifyResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"verified":{"type":"boolean","example":true},"challenge_id":{"type":"string"},"dispatch_id":{"type":"string","nullable":true}}}}},"ManifestResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string"},"data":{"type":"object","properties":{"version":{"type":"string"},"auth":{"type":"object","properties":{"header":{"type":"string"}}},"endpoints":{"type":"array","items":{"type":"object"}},"errorCodes":{"type":"array","items":{"$ref":"#/components/schemas/ErrorCode"}}}}}}},"responses":{"Error":{"description":"Error envelope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"validation":{"summary":"Validation error","value":{"success":false,"error":"Human-readable message","code":"VALIDATION_ERROR"}},"sessionExpired":{"summary":"Session window expired","value":{"success":false,"error":"Customer care window is closed","code":"SESSION_WINDOW_EXPIRED"}}}}}},"RateLimited":{"description":"Too many requests for this API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rateLimited":{"summary":"Rate limited","value":{"success":false,"error":"Rate limit exceeded. Try again later.","code":"RATE_LIMIT_EXCEEDED","retry_after":42}}}}}},"SendAccepted":{"description":"Accepted for delivery. One recipient returns a single object. Several recipients return a batch.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/SendAcceptedSingle"},{"$ref":"#/components/schemas/SendAcceptedBulk"}]},"examples":{"singleLive":{"summary":"Single recipient (live)","value":{"success":true,"message":"WhatsApp message accepted","data":{"dispatch_id":"661f0a1b2c3d4e5f67890123","job_id":"661f0a1b2c3d4e5f67890123","message_id":"661f0a1b2c3d4e5f67890123","status":"accepted","environment":"live","recipient":"9800000000","cost":1,"remaining_balance":480,"remaining_credits":480}}},"singleSandbox":{"summary":"Single recipient (sandbox)","value":{"success":true,"message":"WhatsApp message accepted","data":{"dispatch_id":"661f0a1b2c3d4e5f67890123","job_id":"661f0a1b2c3d4e5f67890123","message_id":"661f0a1b2c3d4e5f67890123","status":"accepted","environment":"sandbox","recipient":"9800000000","cost":1,"remaining_balance":999,"remaining_credits":999,"charged":false}}}}}}}}}}