{"openapi":"3.1.0","info":{"title":"Rasel Unified Messaging API","version":"1.0.0","description":"Unified API documentation for sending messages through Rasel. JSON/request envelopes are limited to 8 MiB (HTTP 413 PAYLOAD_TOO_LARGE). Authenticated template/media send uploads accept multipart files up to 100 MiB, with 1 MiB reserved for form framing; provider-specific file limits still apply. POST /api/v2/messages/send supports single-recipient sends (to as string) and official batch sends (to as string array, up to 100 recipients with shared fields). Use the Conversation context tag to list WhatsApp Web sessions/chats and Telegram bots/subscribers before sending. Zero raw user prices consume no wallet funds, plan units or complimentary grants. Positive raw prices covered by a plan or grant still consume that coverage even when the final cost is zero."},"servers":[{"url":"https://raselsms.com","description":"Current application origin"}],"tags":[{"name":"Messaging","description":"Send unified messages across SMS, WhatsApp (including WhatsApp Web images and native groups), Telegram bots, and email depending on the selected channel."},{"name":"Verification","description":"Dedicated verification API for user_verification flows. Use this instead of messages/send when you need send, resend, and verify lifecycle handling."},{"name":"Account","description":"Read-only account APIs for the authenticated API key owner: profile snapshot, subscription history, wallet ledger, and complimentary admin gift message grants (freeMessageGrants)."},{"name":"SMS Senders","description":"List and request SMS sender names for the API key owner. New names are submitted for admin review (pending) before they can be used in send requests."},{"name":"Official Senders","description":"List the official WhatsApp senders (WABA numbers) available to the API key owner. Credentials and access tokens are never returned."},{"name":"Templates","description":"List and create message templates with the same API key used for sending. WhatsApp official templates are submitted to Meta according to the account sender. User-session templates (provider=user_session) are stored locally and can be sent on WhatsApp Web. SMS and email templates are stored and auto-approved. Header media can be attached on POST /api/v2/templates as multipart/form-data (headerMedia or file), or uploaded first via POST /api/v2/templates/media then passed as headerAssetId."},{"name":"WhatsApp Web Inbound Webhooks","description":"Rasel POSTs incoming WhatsApp Web messages to the HTTPS URL you configure in developer settings. Configure the URL and a dedicated webhook API key there. This path documents the callback your server receives; it is not a Rasel API you call."},{"name":"Conversation context","description":"List WhatsApp Web sessions/chats and Telegram bots/subscribers. send includes safe session/bot discovery; chats/subscribers additionally require messages_read. Selected-sender keys cannot access these channels. Tokens, QR codes, and webhook secrets are never returned."},{"name":"SAS Radius","description":"Compatibility API for SAS Radius SMS gateways. Send Syria SMS with api_token, phone, message, and country_code in the request body. Optional sender_id selects an approved SMS sender. Available only when an admin enables SAS Radius for your account."}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Provide your API key in the X-API-Key header."},"WebhookBearer":{"type":"http","scheme":"bearer","description":"Dedicated receiver secret sent by Rasel."},"WebhookApiKey":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Same dedicated receiver secret."}},"schemas":{"BulkErrorResponse":{"type":"object","additionalProperties":false,"required":["success","code","error"],"properties":{"success":{"type":"boolean","const":false},"code":{"type":"string","description":"Stable machine code. Match on this field, not on error text."},"error":{"type":"string","description":"Short English explanation safe to show to the account owner."}}},"BulkJobCounts":{"type":"object","additionalProperties":false,"required":["pending","sent","failed","cancelled"],"properties":{"pending":{"type":"integer","minimum":0,"description":"Rows not sent yet."},"sent":{"type":"integer","minimum":0,"description":"Rows accepted for delivery. They also appear in the normal message list."},"failed":{"type":"integer","minimum":0,"description":"Rows that failed. A completed job can still have failed rows."},"cancelled":{"type":"integer","minimum":0,"description":"Rows cancelled before send."}}},"BulkPublicJob":{"type":"object","additionalProperties":false,"required":["id","name","status","messagesPerSecond","pauseReason","total","validatedCount","counts","errorCode","errorMessage"],"properties":{"id":{"type":"string","examples":["64b0c0ff0000000000000001"]},"name":{"type":"string","description":"Optional label. Stored up to 120 characters. Empty when omitted."},"status":{"type":"string","enum":["accepting","validating","rejected","queued","running","paused","completed","cancelled"],"description":"accepting: rows are still being stored and nothing is sent. validating: every row is checked and nothing is sent yet. rejected: nothing was sent. queued: waiting for a send slot. running: sending. paused: sending stopped. completed: finished, including when some rows failed. cancelled: remaining unsent rows were cancelled."},"messagesPerSecond":{"type":"integer","minimum":1,"maximum":50},"pauseReason":{"type":["string","null"],"enum":["insufficient_balance","provider_rate_limit","user",null],"description":"Set only while status is paused. insufficient_balance and provider_rate_limit stop the current window. user means the account requested pause."},"total":{"type":"integer","minimum":0,"description":"Number of rows in the accepted request."},"validatedCount":{"type":"integer","minimum":0,"description":"How many rows have been checked while status is validating."},"counts":{"$ref":"#/components/schemas/BulkJobCounts"},"errorCode":{"type":["string","null"],"description":"Job-level code when status is rejected: VALIDATION_FAILED (one or more rows failed checks; nothing sent), INSUFFICIENT_BALANCE (the account cannot send even one message; nothing sent), INTAKE_INCOMPLETE (storage did not finish; nothing sent)."},"errorMessage":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"startedAt":{"type":["string","null"],"format":"date-time"},"completedAt":{"type":["string","null"],"format":"date-time"},"lastSentAt":{"type":["string","null"],"format":"date-time"}}},"BulkItem":{"type":"object","additionalProperties":false,"required":["index","status","to","channel","senderId","templateName","text","variables","errorCode","errorMessage","requestId"],"properties":{"index":{"type":"integer","minimum":0,"description":"Zero-based position in the original messages array."},"status":{"type":"string","enum":["received","pending","sending","sent","failed","cancelled"],"description":"received: stored, not checked yet. pending: ready to send. sending: claimed. sent: accepted. failed: this row only. cancelled: not sent."},"to":{"type":"string","description":"Recipient as submitted. Returned only to the owning account."},"channel":{"type":"string"},"senderId":{"type":"string","description":"Sender id when the row included one. Empty when omitted."},"templateName":{"type":"string","description":"Template name or key when the row used a template. Empty otherwise."},"text":{"type":"string","description":"Message text for the owning account. File bytes are not returned."},"variables":{"type":["object","null"],"additionalProperties":true,"description":"Template variables when present."},"errorCode":{"type":["string","null"]},"errorMessage":{"type":["string","null"]},"requestId":{"type":["string","null"],"description":"Present after the row is accepted for delivery."},"sentAt":{"type":["string","null"],"format":"date-time"}}},"MessageContent":{"type":"object","additionalProperties":false,"properties":{"text":{"type":"string","description":"Plain text message content. Used as caption when attachment is present."},"otpCode":{"type":"string","description":"OTP code used when messageType=otp without a template."},"subject":{"type":"string","description":"Email subject when channel=email."}}},"MessageAttachment":{"type":"object","additionalProperties":false,"required":["type"],"description":"Outbound media for WhatsApp Web (user_whatsapp_session / system_whatsapp_sessions) and Telegram bots. WhatsApp Web accepts publicUrl or base64. Telegram bot media requires a publicly reachable HTTPS publicUrl.","properties":{"type":{"type":"string","enum":["image","video","audio","document"],"example":"image"},"publicUrl":{"type":"string","format":"uri","description":"HTTPS URL the provider can fetch. Required for telegram_bot media.","example":"https://cdn.example.com/catalog/sku-100.png"},"base64":{"type":"string","description":"Raw base64 (no data: prefix). WhatsApp Web only; ignored for Telegram bots."},"mimetype":{"type":"string","example":"image/png"},"fileName":{"type":"string","example":"sku-100.png"},"assetId":{"type":"string","description":"Optional id of a previously uploaded conversation media asset owned by this account."}}},"MessageConversationContext":{"type":"object","additionalProperties":false,"required":["moduleType","accountId","chatId"],"description":"Required for telegram_bot. For WhatsApp Web groups, set chatId to the native group JID (…@g.us). accountId is the WhatsApp Web session name or the Telegram bot Mongo id.","properties":{"moduleType":{"type":"string","enum":["whatsapp_web","whatsapp_official","telegram_bot"]},"accountId":{"type":"string","description":"WhatsApp Web session name, official WhatsApp account id, or Telegram bot id."},"chatId":{"type":"string","description":"WhatsApp JID (digits@s.whatsapp.net or groupId@g.us) or Telegram numeric chat id of a user who started the bot."},"contactId":{"type":["string","null"]},"conversationKey":{"type":["string","null"]}}},"MessageTemplate":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string","description":"Internal template identifier. It may reference a regular template or a saved official WhatsApp template."},"key":{"type":"string","description":"Template key or name. It may reference a regular template or a saved official WhatsApp template."},"language":{"type":"string","description":"WhatsApp (Meta) template language only (e.g. ar, en). Used to select Meta-approved WhatsApp message templates; not used for SMS or other channels."},"variablesIndexed":{"type":"array","items":{"type":"string"},"description":"Indexed template variables in positional order. Use this for official WhatsApp / Meta templates, matching body {{1}}, {{2}}, etc."},"buttonVariables":{"type":"array","items":{"type":"object","additionalProperties":false,"properties":{"index":{"type":"integer","minimum":0,"description":"0-based index of the URL button in the approved template buttons list."},"subType":{"type":"string","enum":["url"],"description":"Button component sub-type. Only url is supported today."},"text":{"type":"string","description":"Dynamic URL suffix only (not the full URL). Example: doctor-profile-id for https://example.com/doctors/{{1}}."}},"required":["index","subType","text"]},"description":"Dynamic URL button variables, separate from body variablesIndexed. Required when the template URL button contains {{1}}."},"variablesNamed":{"type":"object","additionalProperties":{"type":"string"},"description":"Named template variables."},"headerAssetId":{"type":"string","description":"Optional. Per-send header media id. Prefer sending the file or URL in the same request (multipart headerMedia/file or template.headerMediaUrl). This field remains supported when you already uploaded via POST /api/v2/templates/media."},"headerMediaUrl":{"type":"string","format":"uri","description":"HTTPS/HTTP URL string for this send only. Example: \"https://cdn.example.com/file.pdf\". Pair with headerMediaType. String aliases: template.header, template.headerMedia, variablesNamed.header. Do NOT send header as { type, url, filename }. Meta Cloud API: components[].parameters[].document.link (string)."},"headerMediaType":{"type":"string","enum":["image","video","document"],"description":"Required with headerMediaUrl when the media type cannot be inferred. For multipart, send mediaType instead."},"header":{"type":"string","format":"uri","description":"String URL alias of headerMediaUrl. Must be a string, never an object like { type, url, filename }."}}},"MessageOptions":{"type":"object","additionalProperties":true,"properties":{"priority":{"type":"string","enum":["high","normal"],"deprecated":true,"description":"Deprecated and ignored. All unified send requests are processed with high priority automatically."},"idempotencyKey":{"type":"string","description":"Optional idempotency key for safe retries across all unified channels and message types (OTP, utility, marketing, free_text). Prefer the Idempotency-Key request header when both are present. Same key + same body replays the cached response for 24h; same key + different body returns 409 IDEMPOTENCY_KEY_CONFLICT. Requires RASEL_SEND_IDEMPOTENCY_ENABLED=true and Redis."},"scheduleAt":{"type":"string","format":"date-time","description":"Optional scheduled delivery time in ISO 8601. Must be in the future. Requires a plan with allowsScheduledMessages. Returns status=scheduled (202) and enqueues for the worker; billing occurs at send time."},"metadata":{"type":"object","additionalProperties":true,"description":"Optional client metadata persisted on the message record and shown in sending history details. Plain object only; max ~4KB. Reserved keys (requestId, sourceChannel, operationKey, campaignRecipientId, campaignReservationId, remoteChatId) are stripped."}}},"UnifiedSendRequest":{"type":"object","additionalProperties":false,"required":["to"],"example":{"to":"+963912345678","channel":"local_sms","messageType":"free_text","content":{"text":"Hello, this is a test message from Rasel."},"sender":{"id":"6800abc123def4567890fedc"}},"properties":{"to":{"oneOf":[{"type":"string","description":"Single recipient: E.164 phone, email when channel=email, WhatsApp group JID (id@g.us), or Telegram chat id when channel=telegram_bot.","examples":["+963912345678","120363012345678901@g.us","123456789"]},{"type":"array","minItems":1,"maxItems":100,"items":{"type":"string"},"description":"Batch recipients (official). Shared fields apply to every number. Use two or more entries for a batch response; a single-element array is normalized to a single-recipient response.","examples":[["+963912345678","+963987654321"]]}]},"text":{"type":"string","description":"Convenience shortcut that maps to free_text + auto when content.text is not provided."},"channel":{"type":"string","enum":["auto","local_sms","int_sms","user_whatsapp_session","system_whatsapp_sessions","official_whatsapp","official_whatsapp_otp","telegram_otp","telegram_bot","email","email_user"],"description":"Delivery channel. Prefer official_whatsapp for Meta official WhatsApp (otp/utility/marketing/free_text via messageType). official_whatsapp_otp remains accepted as a legacy alias of official_whatsapp."},"messageType":{"type":"string","enum":["otp","utility","marketing","free_text"],"description":"Message classification."},"content":{"$ref":"#/components/schemas/MessageContent"},"attachment":{"$ref":"#/components/schemas/MessageAttachment"},"conversationContext":{"$ref":"#/components/schemas/MessageConversationContext"},"template":{"$ref":"#/components/schemas/MessageTemplate"},"options":{"$ref":"#/components/schemas/MessageOptions"},"sender":{"type":"object","additionalProperties":false,"description":"Optional sender override. If omitted the system automatically uses (1) the user's default approved sender, then (2) the platform default sender, then (3) the provider's built-in default.","properties":{"id":{"type":"string","description":"Approved SMS sender identifier (from /api/v2/sms-senders). When omitted, the user's default sender is used automatically."},"name":{"type":"string","description":"Approved SMS sender name (alternative to id). Looked up by exact name match among the user's approved senders."},"officialId":{"type":"string","description":"Official WhatsApp sender identifier (from /api/v2/official-senders) used for whatsapp_official sends. When omitted, the account's default official sender is used. Must belong to the API key owner."}}},"officialSenderId":{"type":"string","description":"Alias of sender.officialId. Official WhatsApp sender to send through (from /api/v2/official-senders). A template bound to another official sender is rejected with TEMPLATE_SENDER_MISMATCH."}},"examples":{"quickSms":{"summary":"Quick local SMS send","value":{"to":"+963912345678","channel":"local_sms","messageType":"free_text","content":{"text":"Hello, this is a test message from Rasel."},"sender":{"id":"6800abc123def4567890fedc"}}},"shorthand":{"summary":"Text shortcut","value":{"to":"+963912345678","text":"Hello"}},"otp":{"summary":"OTP message","value":{"to":"+963912345678","messageType":"otp","channel":"auto","content":{"otpCode":"123456"}}},"whatsappTemplateFull":{"summary":"WhatsApp utility template with variables and URL button","description":"Matches the Templates API full example (order_ready_notice). variablesIndexed fills body {{1}} {{2}} {{3}}. buttonVariables[0].text is the URL suffix for the first URL button ({{1}} in the button URL).","value":{"to":"+963911111111","messageType":"utility","channel":"official_whatsapp","template":{"key":"order_ready_notice","variablesIndexed":["أحمد","A-1042","25000"],"buttonVariables":[{"index":0,"subType":"url","text":"A-1042"}],"headerMediaUrl":"https://cdn.example.com/order-ready.jpg","headerMediaType":"image"}}},"whatsappWebImage":{"summary":"WhatsApp Web image (user session)","description":"Sends an image through a connected user WhatsApp Web session. content.text is the caption. Prefer publicUrl; base64 is also accepted for WhatsApp Web.","value":{"to":"+963912345678","channel":"user_whatsapp_session","messageType":"free_text","content":{"text":"Product photo"},"attachment":{"type":"image","publicUrl":"https://cdn.example.com/catalog/sku-100.png","mimetype":"image/png","fileName":"sku-100.png"}}},"whatsappWebGroup":{"summary":"WhatsApp Web native group","description":"to and conversationContext.chatId are the group JID (…@g.us). accountId is the WhatsApp Web session name. This is a native WhatsApp group, not a Rasel contact group.","value":{"to":"120363012345678901@g.us","channel":"user_whatsapp_session","messageType":"free_text","content":{"text":"Hello group"},"conversationContext":{"moduleType":"whatsapp_web","accountId":"session-user-whatsapp-1","chatId":"120363012345678901@g.us"}}},"whatsappWebGroupImage":{"summary":"WhatsApp Web group + image","value":{"to":"120363012345678901@g.us","channel":"user_whatsapp_session","messageType":"free_text","content":{"text":"Catalog image"},"attachment":{"type":"image","publicUrl":"https://cdn.example.com/catalog/sku-100.png","mimetype":"image/png","fileName":"sku-100.png"},"conversationContext":{"moduleType":"whatsapp_web","accountId":"session-user-whatsapp-1","chatId":"120363012345678901@g.us"}}},"telegramBotSubscriber":{"summary":"Telegram bot subscriber","description":"Only users who already started the bot. conversationContext.accountId is the bot Mongo id. chatId is the Telegram user chat id. API keys cannot fan-out to every subscriber in one call — use campaigns for that list.","value":{"to":"123456789","channel":"telegram_bot","messageType":"free_text","content":{"text":"Hello from the bot"},"conversationContext":{"moduleType":"telegram_bot","accountId":"6800abc123def4567890fedc","chatId":"123456789"}}},"telegramBotSubscriberImage":{"summary":"Telegram bot subscriber + image","description":"Telegram media requires a public HTTPS publicUrl (base64 is not used).","value":{"to":"123456789","channel":"telegram_bot","messageType":"free_text","content":{"text":"Offer image"},"attachment":{"type":"image","publicUrl":"https://cdn.example.com/offers/banner.jpg","mimetype":"image/jpeg","fileName":"banner.jpg"},"conversationContext":{"moduleType":"telegram_bot","accountId":"6800abc123def4567890fedc","chatId":"123456789"}}},"batch":{"summary":"Official batch send (shared fields)","value":{"to":["+963912345678","+963987654321"],"channel":"local_sms","messageType":"free_text","content":{"text":"Hello from Rasel batch send."},"sender":{"id":"6800abc123def4567890fedc"}}}}},"UnifiedSendBatchResultItem":{"type":"object","additionalProperties":true,"required":["to","success"],"properties":{"to":{"type":"string"},"success":{"type":"boolean"},"requestId":{"type":"string"},"status":{"type":"string","enum":["sent","queued","scheduled"]},"code":{"type":"string"},"error":{"type":"string"},"resolved":{"type":"object","additionalProperties":true},"billing":{"type":"object","additionalProperties":true},"tracking":{"type":"object","additionalProperties":true},"retryAfterSeconds":{"type":"number"}}},"UnifiedSendBatchSummary":{"type":"object","additionalProperties":false,"required":["total","sent","queued","failed"],"properties":{"total":{"type":"integer","minimum":0},"sent":{"type":"integer","minimum":0},"queued":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0}}},"UnifiedSendBatchSuccessResponse":{"type":"object","additionalProperties":true,"required":["success","batch","summary","results"],"properties":{"success":{"type":"boolean","description":"True when at least one recipient succeeded; false when every item failed."},"batch":{"type":"boolean","const":true},"summary":{"$ref":"#/components/schemas/UnifiedSendBatchSummary"},"results":{"type":"array","items":{"$ref":"#/components/schemas/UnifiedSendBatchResultItem"}}},"example":{"success":true,"batch":true,"summary":{"total":2,"sent":2,"queued":0,"failed":0},"results":[{"to":"+963912345678","success":true,"requestId":"msgreq_1739012345678_abc123","status":"sent"},{"to":"+963987654321","success":true,"requestId":"msgreq_1739012345678_def456","status":"sent"}]}},"UnifiedSendSuccessResponse":{"type":"object","additionalProperties":true,"properties":{"smsMultipart":{"$ref":"#/components/schemas/SmsMultipartSummary"},"success":{"type":"boolean","const":true},"requestId":{"type":"string"},"status":{"type":"string","enum":["sent","queued","scheduled"]},"scheduledAt":{"type":"string","format":"date-time","description":"Present when status is scheduled; the deferred delivery time."},"resolved":{"type":"object","additionalProperties":true,"properties":{"channel":{"type":["string","null"]},"provider":{"type":["string","null"]},"senderSource":{"type":["string","null"]},"channels":{"type":"array","items":{"type":["string","null"]},"description":"Public channel names when send-on-all-compatible-channels fan-out succeeded on more than one channel."}}},"billing":{"type":"object","additionalProperties":true,"properties":{"estimatedCost":{"type":"number"},"currency":{"type":"string"}}},"tracking":{"type":"object","additionalProperties":true,"properties":{"messageId":{"type":["string","null"]},"usageId":{"type":["string","null"]},"queueId":{"type":["string","null"]},"deliveries":{"type":"array","description":"Per-channel tracking when fan-out is enabled.","items":{"type":"object","additionalProperties":true,"properties":{"channel":{"type":["string","null"]},"messageId":{"type":["string","null"]},"messageDocId":{"type":["string","null"]}}}}}},"trial":{"$ref":"#/components/schemas/TrialSendNotice"}}},"SmsMultipartSummary":{"type":"object","description":"Local SMS logical sections. sent means accepted for sending, not handset delivery. Resume failed sections from message history; never blindly resend an uncertain section.","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["sent","partial","failed","unknown"]},"totalParts":{"type":"integer","minimum":1,"maximum":32},"sentParts":{"type":"integer","minimum":0},"parts":{"type":"array","maxItems":32,"items":{"type":"object","properties":{"index":{"type":"integer","minimum":1},"state":{"type":"string","enum":["pending","sending","sent","failed","unknown"]},"messageDocId":{"type":"string"},"messageId":{"type":"string"}}}}}},"UnifiedSendErrorResponse":{"type":"object","additionalProperties":true,"example":{"success":false,"requestId":"msgreq_1739012345678_abc123","code":"WHATSAPP_NOT_REGISTERED","error":"الرقم غير مسجل في واتساب"},"properties":{"success":{"type":"boolean","const":false},"requestId":{"type":"string"},"code":{"type":"string","description":"Includes SMS_PARTIAL_DELIVERY, SMS_MULTIPART_FAILED and SMS_MULTIPART_ACCEPTANCE_UNKNOWN for sectioned SMS."},"error":{"type":"string"},"retryAfterSeconds":{"type":"number"},"trial":{"$ref":"#/components/schemas/TrialSendNotice"},"details":{"type":"object","additionalProperties":true,"properties":{"smsMultipart":{"$ref":"#/components/schemas/SmsMultipartSummary"}}},"billing":{"type":"object","properties":{"estimatedCost":{"type":"number","description":"Total wallet price recorded for all sections so far, including numbering; existing grants, bundle and failure charging policies apply."},"currency":{"type":"string"}}},"tracking":{"type":"object","additionalProperties":true,"properties":{"messageDocId":{"type":["string","null"]}}}}},"VerificationSendRequest":{"type":"object","additionalProperties":false,"required":["to"],"properties":{"to":{"type":"string","description":"Recipient phone number in international format.","example":"+963912345678"},"channel":{"type":"string","description":"Optional. Omit this field for automatic channel selection. Values such as sms, whatsapp, telegram, email, or auto alone are rejected. Prefer public aliases such as int_sms, local_sms, user_whatsapp_session, system_whatsapp_sessions, official_whatsapp, or telegram_otp. int_sms uses the international message family in system order. Legacy alias official_whatsapp_otp is still accepted.","enum":["int_sms","local_sms","user_whatsapp_session","system_whatsapp_sessions","official_whatsapp","telegram_otp","official_whatsapp_otp"]},"senderId":{"type":"string","description":"Optional approved SMS sender id (Mongo ObjectId). When omitted for SMS channels, the user's default or any approved sender with a binding for that provider is used, then the platform default sender if configured."},"officialSenderId":{"type":"string","description":"Optional official WhatsApp sender id (from /api/v2/official-senders) used when the OTP goes out on whatsapp_official. When omitted, the account's default official sender is used."},"sender":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string","description":"Same as senderId; matches messages/send shape."},"officialId":{"type":"string","description":"Same as officialSenderId; matches messages/send shape."}}},"idempotencyKey":{"type":"string","description":"Optional body alternative to the Idempotency-Key header for safe retries. Prefer the header. Use a new key when requesting a fresh verification code."}},"example":{"to":"+963912345678","channel":"int_sms","senderId":"6800abc123def4567890abcd"}},"VerificationResendRequest":{"type":"object","additionalProperties":false,"properties":{"verificationId":{"type":"string","description":"Preferred identifier returned from the send step."},"to":{"type":"string","description":"Fallback phone number when verificationId is not available."},"channel":{"type":"string","description":"Optional. Omit this field for automatic channel selection. Values such as sms, whatsapp, telegram, email, or auto alone are rejected. Prefer public aliases such as int_sms, local_sms, user_whatsapp_session, system_whatsapp_sessions, official_whatsapp, or telegram_otp. int_sms uses the international message family in system order. Legacy alias official_whatsapp_otp is still accepted.","enum":["int_sms","local_sms","user_whatsapp_session","system_whatsapp_sessions","official_whatsapp","telegram_otp","official_whatsapp_otp"]},"senderId":{"type":"string","description":"Optional SMS sender override for this resend (same resolution rules as send)."},"officialSenderId":{"type":"string","description":"Optional official WhatsApp sender override for this resend (same resolution rules as send)."},"sender":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string"},"officialId":{"type":"string"}}}},"anyOf":[{"required":["verificationId"]},{"required":["to"]}],"example":{"verificationId":"6800abc123def4567890fedc","channel":"int_sms"}},"VerificationVerifyRequest":{"type":"object","additionalProperties":false,"required":["code"],"properties":{"verificationId":{"type":"string","description":"Preferred identifier returned from the send step."},"to":{"type":"string","description":"Fallback phone number when verificationId is not available."},"code":{"type":"string","description":"Latest verification code received by the user.","example":"123456"}},"anyOf":[{"required":["verificationId","code"]},{"required":["to","code"]}],"example":{"verificationId":"6800abc123def4567890fedc","code":"123456"}},"VerificationSendResponse":{"type":"object","additionalProperties":true,"properties":{"verificationId":{"type":"string"},"status":{"type":"string","enum":["sent"]},"channel":{"type":["string","null"]},"channels":{"type":"array","items":{"type":"string"},"description":"Present when the account enabled send-on-all-compatible-channels and more than one OTP channel succeeded."},"deliveries":{"type":"array","description":"Per-channel outcomes when send-on-all-compatible-channels is on. Existing channel remains the first success.","items":{"type":"object","additionalProperties":true,"properties":{"channel":{"type":"string"},"status":{"type":"string","enum":["sent","failed"]},"messageId":{"type":"string"},"messageDocId":{"type":"string"},"code":{"type":"string"}}}},"expiresAt":{"type":"string","format":"date-time"},"resendAvailableAt":{"type":"string","format":"date-time"},"resendCount":{"type":"number"},"trial":{"$ref":"#/components/schemas/TrialSendNotice"}}},"TrialSendNotice":{"type":"object","additionalProperties":false,"description":"يظهر لحسابات الخطة التجريبية. القالب يبقي {code} ولا يتضمن رمز التحقق نفسه. sent_as_is يعني أن النص المعتمد أُرسل كما هو، substituted يعني أن طلب التحقق استُبدل بهذا النص، وrejected يعني أن المحتوى المخصص لم يُرسل.","required":["active","action","template","message","upgradeHref"],"properties":{"active":{"type":"boolean","const":true,"description":"الحساب على الخطة التجريبية."},"action":{"type":"string","enum":["sent_as_is","substituted","rejected"],"description":"ماذا فعل النظام بالنص: أرسله كما هو، أو استبدله بالنص المعتمد، أو رفض المحتوى المخصص."},"template":{"type":"string","example":"رمز التحقق: {code}","description":"قالب النص المعتمد مع {code} دون الرمز الحقيقي."},"ignored":{"type":"array","description":"حقول أرسلها العميل ولم تُستخدم في الرسالة التي خرجت.","items":{"type":"string","description":"اسم الحقل الذي لم يُسلَّم."}},"message":{"type":"string","description":"شرح عربي لما حدث وما يمكن للعميل فعله بعد ذلك."},"upgradeHref":{"type":"string","example":"/dashboard/billing","description":"مسار ترقية الخطة داخل لوحة التحكم."},"example":{"type":"object","description":"مثال طلب ينجح أثناء التجربة. يظهر عند الرفض فقط.","properties":{"method":{"type":"string","const":"POST","description":"طريقة الطلب في المثال."},"path":{"type":"string","example":"/api/v2/verification/send","description":"مسار الطلب الذي يرسل رمز التحقق بدون نص مخصص."},"body":{"type":"object","description":"جسم المثال: الرقم والقناة فقط.","properties":{"to":{"type":"string","description":"رقم المستلم في المثال."},"channel":{"type":"string","description":"قناة الإرسال في المثال."}}}}}}},"VerificationVerifySuccessResponse":{"type":"object","additionalProperties":true,"properties":{"verificationId":{"type":"string"},"verified":{"type":"boolean","const":true},"alreadyVerified":{"type":"boolean"},"verifiedAt":{"type":["string","null"],"format":"date-time"},"remainingAttempts":{"type":["number","null"]}}},"VerificationErrorResponse":{"type":"object","additionalProperties":true,"properties":{"success":{"type":"boolean","const":false},"error":{"type":"string"},"code":{"type":"string","enum":["VERIFICATION_NOT_FOUND","VERIFICATION_EXPIRED","VERIFICATION_INVALID_CODE","VERIFICATION_MAX_ATTEMPTS_EXCEEDED","VERIFICATION_RESEND_COOLDOWN","VERIFICATION_MAX_RESENDS_EXCEEDED","VERIFICATION_CHANNEL_NOT_AVAILABLE"]},"verificationId":{"type":["string","null"]},"verified":{"type":["boolean","null"]},"remainingAttempts":{"type":["number","null"]},"status":{"type":["string","null"]},"expiresAt":{"type":["string","null"],"format":"date-time"},"resendAvailableAt":{"type":["string","null"],"format":"date-time"},"resendCount":{"type":["number","null"]}}},"DeveloperAccountProfile":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"avatar":{"type":["string","null"]},"phoneVerified":{"type":"boolean"},"businessName":{"type":["string","null"]},"appName":{"type":["string","null"]},"businessNameVerified":{"type":"boolean"},"appNameVerified":{"type":"boolean"},"ownerId":{"type":["string","null"]},"memberPermissions":{"type":["array","null"],"items":{"type":"string"}},"createdAt":{"type":["string","null"],"format":"date-time"}}},"DeveloperAccountWallet":{"type":"object","additionalProperties":false,"properties":{"balance":{"type":"number"},"availableBalance":{"type":"number"},"currency":{"type":"string","example":"USD"}}},"DeveloperAccountAccess":{"type":"object","additionalProperties":false,"properties":{"canSend":{"type":"boolean"},"reason":{"type":"string"},"poolExhausted":{"type":"boolean"},"effectiveLimit":{"type":["number","null"]},"periodMessageLimit":{"type":["number","null"]},"bonusMessagesGranted":{"type":["number","null"]},"remainingSegments":{"type":["number","null"]},"usageCount":{"type":"number"},"usageByChannel":{"type":"object","additionalProperties":true},"channelLimits":{"type":["object","null"],"additionalProperties":true},"cycleStart":{"type":["string","null"],"format":"date-time"},"cycleEnd":{"type":["string","null"],"format":"date-time"}}},"DeveloperAccountActiveSubscription":{"type":["object","null"],"additionalProperties":false,"properties":{"planName":{"type":["string","null"]},"status":{"type":["string","null"]},"startAt":{"type":["string","null"],"format":"date-time"},"endAt":{"type":["string","null"],"format":"date-time"},"isTrial":{"type":"boolean"},"billingCycleMonths":{"type":["number","null"]}}},"DeveloperAccountPool":{"type":"object","additionalProperties":false,"properties":{"hasActivePlan":{"type":"boolean"},"poolSuppressed":{"type":"boolean"},"effectiveLimit":{"type":["number","null"]},"periodMessageLimit":{"type":["number","null"]},"bonusMessagesGranted":{"type":["number","null"]},"usedSegments":{"type":"number"},"remainingSegments":{"type":["number","null"]},"usedMessages":{"type":"number"},"usageByChannel":{"type":"object","additionalProperties":true},"channelLimits":{"type":["object","null"],"additionalProperties":true},"cycleStart":{"type":["string","null"],"format":"date-time"},"cycleEnd":{"type":["string","null"],"format":"date-time"},"poolExhausted":{"type":"boolean"},"planName":{"type":["string","null"]}}},"DeveloperFreeMessageGrantTotals":{"type":"object","additionalProperties":false,"properties":{"granted":{"type":"number"},"consumed":{"type":"number"},"reserved":{"type":"number"},"withdrawn":{"type":"number"},"remaining":{"type":"number"},"activeRemaining":{"type":"number"}}},"DeveloperFreeMessageGrantScope":{"type":"object","additionalProperties":false,"properties":{"channel":{"type":"string"},"providerKey":{"type":["string","null"]},"messageType":{"type":"string","enum":["all","otp","utility","marketing","free_text"]},"granted":{"type":"number"},"consumed":{"type":"number"},"reserved":{"type":"number"},"withdrawn":{"type":"number"},"remaining":{"type":"number"},"activeRemaining":{"type":"number"},"grantCount":{"type":"integer"}}},"DeveloperFreeMessageGrantSummary":{"type":"object","additionalProperties":false,"properties":{"totals":{"$ref":"#/components/schemas/DeveloperFreeMessageGrantTotals"},"activeGrantCount":{"type":"integer"},"grantCount":{"type":"integer"},"byScope":{"type":"array","items":{"$ref":"#/components/schemas/DeveloperFreeMessageGrantScope"}}}},"DeveloperFreeMessageGrantRow":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string"},"channel":{"type":"string"},"providerKey":{"type":["string","null"]},"messageType":{"type":"string","enum":["all","otp","utility","marketing","free_text"]},"initialQuantity":{"type":"number"},"consumedQuantity":{"type":"number"},"reservedQuantity":{"type":"number"},"withdrawnQuantity":{"type":"number"},"remainingQuantity":{"type":"number"},"status":{"type":"string","enum":["active","exhausted","expired","withdrawn"]},"cycleStart":{"type":["string","null"],"format":"date-time"},"cycleEnd":{"type":["string","null"],"format":"date-time"},"expiresAt":{"type":["string","null"],"format":"date-time"},"reason":{"type":["string","null"]},"userNote":{"type":["string","null"]},"subscriptionId":{"type":["string","null"]},"createdAt":{"type":["string","null"],"format":"date-time"}}},"DeveloperFreeMessageGrants":{"type":"object","additionalProperties":false,"description":"Complimentary (admin gift) message grants for the account. The list is capped at 500 rows and hasMore signals additional history; summary always covers all grants. Admin-only notes are omitted; userNote and reason are included when present.","properties":{"hasMore":{"type":"boolean"},"summary":{"$ref":"#/components/schemas/DeveloperFreeMessageGrantSummary"},"grants":{"type":"array","items":{"$ref":"#/components/schemas/DeveloperFreeMessageGrantRow"}}},"example":{"hasMore":false,"summary":{"totals":{"granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90},"activeGrantCount":1,"grantCount":1,"byScope":[{"channel":"sms_local","providerKey":null,"messageType":"all","granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90,"grantCount":1}]},"grants":[{"id":"6800abc123def4567890fedc","channel":"sms_local","providerKey":null,"messageType":"all","initialQuantity":100,"consumedQuantity":10,"reservedQuantity":0,"withdrawnQuantity":0,"remainingQuantity":90,"status":"active","cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z","expiresAt":"2026-08-31T23:59:59.000Z","reason":"admin_gift","userNote":"Complimentary SMS gift from support","subscriptionId":null,"createdAt":"2026-07-15T10:00:00.000Z"}]}},"DeveloperAccountSnapshot":{"type":"object","additionalProperties":false,"properties":{"profile":{"$ref":"#/components/schemas/DeveloperAccountProfile"},"wallet":{"$ref":"#/components/schemas/DeveloperAccountWallet"},"subscription":{"type":"object","additionalProperties":false,"properties":{"access":{"$ref":"#/components/schemas/DeveloperAccountAccess"},"active":{"$ref":"#/components/schemas/DeveloperAccountActiveSubscription"},"pool":{"$ref":"#/components/schemas/DeveloperAccountPool"}}},"freeMessageGrants":{"$ref":"#/components/schemas/DeveloperFreeMessageGrants"}}},"DeveloperAccountSnapshotResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"$ref":"#/components/schemas/DeveloperAccountSnapshot"}}},"DeveloperPlanSummary":{"type":["object","null"],"additionalProperties":false,"properties":{"id":{"type":["string","null"]},"name":{"type":["string","null"]},"monthlyPrice":{"type":["number","null"]}}},"DeveloperSubscriptionRow":{"type":"object","additionalProperties":false,"properties":{"id":{"type":["string","null"]},"status":{"type":["string","null"]},"startAt":{"type":["string","null"],"format":"date-time"},"endAt":{"type":["string","null"],"format":"date-time"},"billingCycleMonths":{"type":["number","null"]},"isTrial":{"type":"boolean"},"periodMessageLimit":{"type":["number","null"]},"periodChannelLimits":{"type":["object","null"],"additionalProperties":true},"bonusMessagesGranted":{"type":["number","null"]},"poolSuppressedByCoupon":{"type":"boolean"},"plan":{"$ref":"#/components/schemas/DeveloperPlanSummary"},"createdAt":{"type":["string","null"],"format":"date-time"}}},"DeveloperChargeCoupon":{"type":["object","null"],"additionalProperties":false,"properties":{"code":{"type":["string","null"]},"discountType":{"type":["string","null"]},"discountValue":{"type":["number","null"]}}},"DeveloperChargeRow":{"type":"object","additionalProperties":false,"properties":{"id":{"type":["string","null"]},"amount":{"type":"number"},"discountAmount":{"type":"number"},"topupAmount":{"type":"number"},"periodStart":{"type":["string","null"],"format":"date-time"},"periodEnd":{"type":["string","null"],"format":"date-time"},"isPaid":{"type":"boolean"},"paidAt":{"type":["string","null"],"format":"date-time"},"plan":{"$ref":"#/components/schemas/DeveloperPlanSummary"},"coupon":{"$ref":"#/components/schemas/DeveloperChargeCoupon"},"createdAt":{"type":["string","null"],"format":"date-time"}}},"DeveloperSubscriptionHistory":{"type":"object","additionalProperties":false,"properties":{"subscriptions":{"type":"array","items":{"$ref":"#/components/schemas/DeveloperSubscriptionRow"}},"charges":{"type":"array","items":{"$ref":"#/components/schemas/DeveloperChargeRow"}},"freeMessageGrants":{"$ref":"#/components/schemas/DeveloperFreeMessageGrants"},"totalSubscriptions":{"type":"integer"},"totalCharges":{"type":"integer"},"skip":{"type":"integer"},"limit":{"type":"integer"}}},"DeveloperSubscriptionHistoryResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"$ref":"#/components/schemas/DeveloperSubscriptionHistory"}}},"DeveloperWalletTransactionRow":{"type":"object","additionalProperties":false,"properties":{"id":{"type":["string","null"]},"amount":{"type":"number"},"type":{"type":["string","null"],"enum":["credit","debit",null]},"source":{"type":["string","null"]},"description":{"type":["string","null"]},"balanceAfter":{"type":["number","null"]},"messageCount":{"type":["number","null"]},"walletTopupDiscountPercent":{"type":["number","null"]},"walletTopupDiscountCouponCode":{"type":["string","null"]},"createdAt":{"type":["string","null"],"format":"date-time"}}},"DeveloperWalletTransactions":{"type":"object","additionalProperties":false,"properties":{"transactions":{"type":"array","items":{"$ref":"#/components/schemas/DeveloperWalletTransactionRow"}},"freeMessageGrants":{"$ref":"#/components/schemas/DeveloperFreeMessageGrants"},"total":{"type":"integer"},"balance":{"type":"number"},"skip":{"type":"integer"},"limit":{"type":"integer"}}},"DeveloperWalletTransactionsResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"$ref":"#/components/schemas/DeveloperWalletTransactions"}},"example":{"success":true,"data":{"transactions":[{"id":"6800bbb123def4567890aaaa","amount":0.12,"type":"debit","source":"usage","description":"SMS send","balanceAfter":4.88,"messageCount":1,"walletTopupDiscountPercent":null,"walletTopupDiscountCouponCode":null,"createdAt":"2026-07-20T14:22:00.000Z"},{"id":"6800ccc123def4567890bbbb","amount":10,"type":"credit","source":"admin_topup","description":"Admin top-up","balanceAfter":5,"messageCount":null,"walletTopupDiscountPercent":null,"walletTopupDiscountCouponCode":null,"createdAt":"2026-07-18T09:00:00.000Z"}],"freeMessageGrants":{"hasMore":false,"summary":{"totals":{"granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90},"activeGrantCount":1,"grantCount":1,"byScope":[{"channel":"sms_local","providerKey":null,"messageType":"all","granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90,"grantCount":1}]},"grants":[{"id":"6800abc123def4567890fedc","channel":"sms_local","providerKey":null,"messageType":"all","initialQuantity":100,"consumedQuantity":10,"reservedQuantity":0,"withdrawnQuantity":0,"remainingQuantity":90,"status":"active","cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z","expiresAt":"2026-08-31T23:59:59.000Z","reason":"admin_gift","userNote":"Complimentary SMS gift from support","subscriptionId":null,"createdAt":"2026-07-15T10:00:00.000Z"}]},"total":2,"balance":4.88,"skip":0,"limit":100}}},"SmsSenderSummary":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["pending","approved","rejected","suspended"]},"isDefault":{"type":"boolean"},"reviewNote":{"type":["string","null"]},"submittedAt":{"type":["string","null"],"format":"date-time"},"reviewedAt":{"type":["string","null"],"format":"date-time"}}},"SmsSenderCreatedSummary":{"allOf":[{"$ref":"#/components/schemas/SmsSenderSummary"},{"type":"object","additionalProperties":false,"properties":{"webhookUrl":{"type":["string","null"],"description":"Returned only on create when configured."},"webhookConfigured":{"type":"boolean","description":"True when a webhook URL was configured at create."}}}]},"SmsSenderWebhookPayload":{"type":"object","additionalProperties":false,"properties":{"event":{"type":"string","enum":["sms_sender.approved","sms_sender.rejected"]},"timestamp":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["approved","rejected"]},"isDefault":{"type":"boolean"},"reviewNote":{"type":["string","null"]},"submittedAt":{"type":["string","null"],"format":"date-time"},"reviewedAt":{"type":["string","null"],"format":"date-time"}}}}},"SmsSenderListResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","additionalProperties":false,"properties":{"smsSenders":{"type":"array","items":{"$ref":"#/components/schemas/SmsSenderSummary"}}}}}},"SmsSenderCreateRequest":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string","description":"Requested SMS sender display name. At most 11 characters. English letters are required. Digits and a single space, dot, underscore, or hyphen between groups are allowed.","example":"MyBrand"},"webhookUrl":{"type":"string","description":"Optional HTTPS webhook URL. When set, webhookSecret is required. Rasel sends a POST when the sender is approved or rejected by admins.","example":"https://your-system.com/webhooks/rasel/sender-status"},"webhookSecret":{"type":"string","description":"Required when webhookUrl is set. Rasel will send Authorization: Bearer <webhookSecret> in webhook callbacks. Not returned in responses.","example":"your-long-random-secret"}}},"SmsSenderCreateResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","additionalProperties":false,"properties":{"smsSender":{"$ref":"#/components/schemas/SmsSenderCreatedSummary"}}},"message":{"type":"string"}}},"OfficialSenderSummary":{"type":"object","additionalProperties":false,"properties":{"id":{"type":["string","null"],"description":"Value to pass as officialSenderId (or sender.officialId) when sending or creating templates. Use the literal \"platform\" for the platform default Meta number (META_DEFAULT_*). Null for a legacy single-sender setup that has not been migrated yet."},"label":{"type":["string","null"],"description":"Display name for the WhatsApp number (preferred in pickers)."},"displayName":{"type":["string","null"],"description":"Ready-to-show label combining name and phone (e.g. \"SAWA · 9613284927\")."},"phoneNumber":{"type":["string","null"],"description":"Verified display number in E.164. Provider internals are not exposed."},"status":{"type":"string","enum":["none","pending","approved","rejected"]},"enabled":{"type":"boolean"},"isDefault":{"type":"boolean","description":"Used automatically when the request omits officialSenderId."},"verifiedName":{"type":["string","null"],"description":"WhatsApp Business verified / display name when available."},"canSetDefault":{"type":"boolean","description":"Whether the account may promote this sender to default via the dashboard."}}},"OfficialSenderListResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","additionalProperties":false,"properties":{"officialSenders":{"type":"array","items":{"$ref":"#/components/schemas/OfficialSenderSummary"}}}}}},"TemplateSummary":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string"},"name":{"type":"string","example":"order_confirmation"},"category":{"type":"string","enum":["whatsapp","sms","message","email"]},"subType":{"type":"string","enum":["marketing","utility","otp","free","notification"]},"status":{"type":"string","enum":["pending","approved","rejected","active","disabled"]},"language":{"type":["string","null"],"example":"ar"},"body":{"type":["string","null"]},"bodyParameters":{"type":"array","items":{"type":"object"}},"headerType":{"type":["string","null"],"enum":["text","image","video","document",null]},"headerValue":{"type":["string","null"]},"headerAssetId":{"type":["string","null"]},"headerPreviewUrl":{"type":["string","null"]},"allowsHeaderMediaOverride":{"type":"boolean","description":"True when this official WhatsApp template has an image, video, or document header and POST /api/v2/messages/send accepts a per-send header file or URL (multipart headerMedia, or JSON template.headerMediaUrl as a string). Aliases are also URL strings: template.header or variablesNamed.header. Do not send { type, url, filename }. That media replaces the sample from template creation."},"footer":{"type":["string","null"]},"buttons":{"type":"array","items":{"type":"object"}},"urlButtonVariables":{"type":"array","items":{"type":"object"}},"indexedPlaceholders":{"type":"array","items":{"type":"integer"}},"content":{"type":["string","null"]},"parameters":{"type":"array","items":{"type":"object"}},"provider":{"type":["string","null"]},"providerTemplateId":{"type":["string","null"]},"manualProvider":{"type":["string","null"],"enum":["eshaar","jaras",null]},"officialSenderId":{"type":["string","null"],"description":"Official WhatsApp sender this template was created on. Literal \"platform\" means the platform default Meta number. Null when the template is not bound to a WABA."},"officialSender":{"type":["object","null"],"additionalProperties":false,"description":"Resolved sender identity so clients can tell platform vs a specific number.","properties":{"id":{"type":"string"},"scope":{"type":"string","enum":["platform","official_sender"]},"isPlatform":{"type":"boolean"},"isDefault":{"type":"boolean"},"label":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"displayName":{"type":["string","null"]}}},"isPlatformNumber":{"type":"boolean","description":"True when the template is bound to the platform default official number."},"isDefault":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"}}},"TemplateListResponse":{"type":"object","additionalProperties":false,"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TemplateSummary"}},"pageInfo":{"type":"object","additionalProperties":false,"required":["hasMore","nextCursor","limit"],"properties":{"hasMore":{"type":"boolean"},"nextCursor":{"type":["string","null"]},"limit":{"type":"integer","minimum":1,"maximum":100}}}}},"TemplateGetResponse":{"type":"object","additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/TemplateSummary"}}},"TemplateCreateRequest":{"type":"object","required":["name","category","subType"],"additionalProperties":true,"example":{"name":"order_ready_notice","category":"whatsapp","subType":"utility","language":"ar","headerType":"image","headerAssetId":"ASSET_ID_FROM_MEDIA_UPLOAD","body":"مرحباً {{1}}، طلبك رقم {{2}} جاهز للاستلام. الإجمالي {{3}} ل.س.","bodyParameters":[{"index":1,"label":"أحمد"},{"index":2,"label":"A-1042"},{"index":3,"label":"25000"}],"footer":"راسل","buttons":[{"type":"url","text":"تتبع الطلب","url":"https://example.com/orders/{{1}}","urlExample":"https://example.com/orders/A-1042"},{"type":"phone","text":"اتصل بنا","url":"+963911111111"}]},"properties":{"name":{"type":"string","description":"Lowercase English identifier with underscores, e.g. order_ready_notice.","example":"order_ready_notice"},"category":{"type":"string","enum":["whatsapp","sms","message","email"]},"subType":{"type":"string","enum":["marketing","utility","otp","free","notification"],"description":"WhatsApp: marketing, utility, otp, or free. notification is stored as utility."},"language":{"type":"string","description":"Required for WhatsApp (e.g. ar, en)."},"body":{"type":"string","description":"WhatsApp body. Use {{1}}, {{2}}, {{3}} placeholders. Pair with bodyParameters (Meta review examples) and later template.variablesIndexed when sending."},"content":{"type":"string","description":"Required for SMS/message (except SMS free) and used as email HTML/text."},"emailSubject":{"type":"string","description":"Required when category=email."},"headerType":{"type":"string","enum":["text","image","video","document"],"description":"For a media header, set image, video, or document. Attach the file in the same multipart request (headerMedia or file), or pass headerAssetId from POST /api/v2/templates/media."},"headerValue":{"type":"string","description":"Header text when headerType=text."},"headerAssetId":{"type":"string","description":"Asset id from POST /api/v2/templates/media when headerType is image, video, or document. Not required when the create request itself includes headerMedia or file."},"footer":{"type":"string","description":"Optional static text under the body. No variables. Official WhatsApp only."},"buttons":{"type":"array","description":"Official WhatsApp only (not user_session). URL: put {{1}} in url and a full sample URL in urlExample; send the suffix with template.buttonVariables. Phone: international number in url.","items":{"type":"object","properties":{"type":{"type":"string","enum":["quick_reply","phone","url"]},"text":{"type":"string"},"url":{"type":"string"},"urlExample":{"type":"string","description":"Full sample URL for Meta review when url contains {{1}}."}}}},"bodyParameters":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"label":{"type":"string","description":"Example value for {{index}}."}}}},"otpType":{"type":"string","enum":["copy_code","one_tap","zero_tap"]},"addSecurityRecommendation":{"type":"boolean"},"codeExpirationMinutes":{"type":"integer","minimum":1,"maximum":90},"otpButtonText":{"type":"string"},"packageName":{"type":"string"},"signatureHash":{"type":"string"},"zeroTapTermsAccepted":{"type":"boolean"},"provider":{"type":"string","enum":["user_session"],"description":"Set to user_session (or templateTarget=user_session) to create a WhatsApp Web session template."},"templateTarget":{"type":"string","enum":["user_session"]},"officialSenderId":{"type":"string","description":"Official WhatsApp sender (from /api/v2/official-senders) to create the template on. When omitted, the account's default official sender is used. Must belong to the API key owner."},"creationMode":{"type":"string","enum":["manual_external_id"],"description":"Bind an existing official WhatsApp template id without submitting a new template."},"providerTemplateId":{"type":"string","description":"Required when creationMode=manual_external_id."},"manualVariableCount":{"type":"integer","minimum":0,"maximum":100}}},"TemplateCreateResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","additionalProperties":false,"properties":{"template":{"$ref":"#/components/schemas/TemplateSummary"}}},"message":{"type":"string"}}},"TemplateMediaUploadResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","additionalProperties":false,"properties":{"media":{"type":"object","additionalProperties":false,"properties":{"assetId":{"type":"string"},"mediaHandle":{"type":"string"},"previewUrl":{"type":"string"},"mimeType":{"type":"string"},"size":{"type":"integer"},"source":{"type":"string"}}}}},"message":{"type":"string"}}},"WhatsAppWebInboundWebhookPayload":{"type":"object","additionalProperties":false,"required":["event","timestamp","data"],"properties":{"event":{"type":"string","enum":["whatsapp_web.message.received","whatsapp_web.inbound.test"]},"timestamp":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":false,"required":["accountId","conversationKey","remoteChatId","remoteMessageId","from","isGroup","text","messageType","timestamp","hasMedia"],"properties":{"accountId":{"type":"string","description":"WhatsApp Web session name."},"conversationKey":{"type":"string"},"remoteChatId":{"type":"string"},"remoteMessageId":{"type":"string"},"from":{"type":"object","additionalProperties":false,"properties":{"jid":{"type":"string"},"phone":{"type":["string","null"]},"displayName":{"type":["string","null"]}}},"isGroup":{"type":"boolean"},"text":{"type":"string"},"messageType":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"hasMedia":{"type":"boolean"},"mediaType":{"type":["string","null"]},"mimetype":{"type":["string","null"]},"fileName":{"type":["string","null"]}}}}},"DeveloperConversationContext":{"type":"object","additionalProperties":false,"required":["moduleType","accountId","chatId"],"properties":{"moduleType":{"type":"string","enum":["whatsapp_web","telegram_bot"]},"accountId":{"type":"string"},"chatId":{"type":"string"}}},"DeveloperContextListResponse":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","additionalProperties":true}}},"ProviderMessagePolicy":{"type":"object","additionalProperties":true,"properties":{"providerKey":{"type":"string"},"channel":{"type":"string"},"enabled":{"type":"boolean"},"allowedTypes":{"type":"array","items":{"type":"string","enum":["otp","utility","marketing","free_text"]}},"sendModeByType":{"type":"object","additionalProperties":true},"requiresApprovedTemplate":{"type":"boolean"},"supportsUserSender":{"type":"boolean"},"supportsSystemSenderFallback":{"type":"boolean"},"priorityOrder":{"type":"integer"},"retryPolicy":{"type":"object","additionalProperties":false,"properties":{"maxAttempts":{"type":"integer"},"backoffMs":{"type":"integer"}}}}},"SasRadiusSendRequest":{"type":"object","additionalProperties":true,"required":["phone","message"],"properties":{"api_token":{"type":"string","description":"Your Rasel API key. Required unless the same key is sent in X-API-Key; the body field is recommended for SAS Radius mapping."},"phone":{"type":"string","description":"Recipient mobile. In SAS Radius map this to {dst}. Syrian mobiles only (e.g. +9639xxxxxxxx or 09xxxxxxxx).","example":"+963912345678"},"message":{"type":"string","description":"Final SMS text. In SAS Radius map this to {text}. Templates are rendered by SAS before the request reaches Rasel.","example":"رسالة تفعيل اشتراك: مرحبا"},"country_code":{"type":"string","default":"SY","description":"Optional; defaults to SY. SY, SYR, 963, and +963 are accepted.","example":"SY"},"sender_id":{"type":"string","maxLength":128,"description":"Optional approved SMS sender. Use the sender id from SMS Senders, or the approved sender name. When omitted or blank, the account default sender is used, then the platform default.","example":"6800abc123def4567890abcd"}}},"SasRadiusSendSuccessResponse":{"type":"object","additionalProperties":true,"properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"sent"},"id":{"type":["string","null"],"description":"Provider/message tracking id when available."},"requestId":{"type":["string","null"]},"resolved":{"type":["object","null"],"additionalProperties":true},"billing":{"type":["object","null"],"additionalProperties":true},"tracking":{"type":["object","null"],"additionalProperties":true}}},"SasRadiusSendErrorResponse":{"type":"object","additionalProperties":true,"properties":{"success":{"type":"boolean","example":false},"code":{"type":"string"},"error":{"type":"string"},"message":{"type":"string"}}}}},"security":[{"ApiKeyAuth":[]}],"paths":{"/api/v2/messages/send":{"post":{"tags":["Messaging"],"summary":"Send unified message","description":"Unified send endpoint for supported channels. Send to one recipient with to as a string (legacy single response), or to multiple recipients with to as a string array (official batch: shared channel, messageType, content/template, sender, and options). Official WhatsApp templates with an image, video, or document header accept the file in the same request: multipart/form-data with headerMedia (or file) plus mediaType, or JSON with template.headerMediaUrl. No prior upload is required. Batch requests return summary + results[]. HTTP 200 when all items succeed, 207 on partial failure. Deprecated compat: batchRequests[] is still accepted (Deprecation: batchRequests response header) but to[] is the documented batch shape. Max 100 recipients per request.","operationId":"sendUnifiedMessage","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Optional unique key for safe retries. Takes precedence over options.idempotencyKey. Applies to all channels and message types on this endpoint. Successful and failed responses are cached for 24 hours when RASEL_SEND_IDEMPOTENCY_ENABLED=true."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendRequest"},"examples":{"whatsappWebImage":{"summary":"WhatsApp Web image (user session)","value":{"to":"+963912345678","channel":"user_whatsapp_session","messageType":"free_text","content":{"text":"Product photo"},"attachment":{"type":"image","publicUrl":"https://cdn.example.com/catalog/sku-100.png","mimetype":"image/png","fileName":"sku-100.png"}}},"whatsappWebGroup":{"summary":"WhatsApp Web native group","value":{"to":"120363012345678901@g.us","channel":"user_whatsapp_session","messageType":"free_text","content":{"text":"Hello group"},"conversationContext":{"moduleType":"whatsapp_web","accountId":"session-user-whatsapp-1","chatId":"120363012345678901@g.us"}}},"whatsappWebGroupImage":{"summary":"WhatsApp Web group + image","value":{"to":"120363012345678901@g.us","channel":"user_whatsapp_session","messageType":"free_text","content":{"text":"Catalog image"},"attachment":{"type":"image","publicUrl":"https://cdn.example.com/catalog/sku-100.png","mimetype":"image/png","fileName":"sku-100.png"},"conversationContext":{"moduleType":"whatsapp_web","accountId":"session-user-whatsapp-1","chatId":"120363012345678901@g.us"}}},"telegramBotSubscriber":{"summary":"Telegram bot subscriber","value":{"to":"123456789","channel":"telegram_bot","messageType":"free_text","content":{"text":"Hello from the bot"},"conversationContext":{"moduleType":"telegram_bot","accountId":"6800abc123def4567890fedc","chatId":"123456789"}}},"telegramBotSubscriberImage":{"summary":"Telegram bot subscriber + image","value":{"to":"123456789","channel":"telegram_bot","messageType":"free_text","content":{"text":"Offer image"},"attachment":{"type":"image","publicUrl":"https://cdn.example.com/offers/banner.jpg","mimetype":"image/jpeg","fileName":"banner.jpg"},"conversationContext":{"moduleType":"telegram_bot","accountId":"6800abc123def4567890fedc","chatId":"123456789"}}},"whatsappTemplateFull":{"summary":"WhatsApp utility template with header image, variables, and URL button","description":"Matches POST /api/v2/templates order_ready_notice. variablesIndexed fills body {{1}} {{2}} {{3}}. buttonVariables[0].text is the URL-button suffix only.","value":{"to":"+963911111111","messageType":"utility","channel":"official_whatsapp","template":{"key":"order_ready_notice","variablesIndexed":["أحمد","A-1042","25000"],"buttonVariables":[{"index":0,"subType":"url","text":"A-1042"}],"headerMediaUrl":"https://cdn.example.com/order-ready.jpg","headerMediaType":"image"}}},"quickSms":{"summary":"Quick local SMS send","value":{"to":"+963912345678","channel":"local_sms","messageType":"free_text","content":{"text":"Hello, this is a test message from Rasel."}}},"officialHeaderMediaUrl":{"summary":"Official WhatsApp template + header URL in the same JSON request","value":{"to":"+963912345678","channel":"official_whatsapp","messageType":"marketing","template":{"key":"bookingconfirmation6","language":"ar","variablesIndexed":["أحمد"],"headerMediaUrl":"https://cdn.example.com/booking.pdf","headerMediaType":"document"}}}}},"multipart/form-data":{"schema":{"type":"object","required":["to"],"properties":{"to":{"type":"string","description":"Recipient or JSON array string of recipients."},"channel":{"type":"string"},"messageType":{"type":"string"},"template":{"type":"string","description":"JSON string of the template object (key, language, variablesIndexed, ...)."},"content":{"type":"string","description":"JSON string of content."},"mediaType":{"type":"string","enum":["image","video","document"]},"mediaUrl":{"type":"string","description":"Public HTTP(S) header media URL when not attaching a file."},"headerMedia":{"type":"string","format":"binary","description":"Header image, video, or document for this send only."},"file":{"type":"string","format":"binary","description":"Alias of headerMedia."}}}}}},"responses":{"200":{"description":"Single recipient sent immediately, or batch completed with zero failures.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/UnifiedSendSuccessResponse"},{"$ref":"#/components/schemas/UnifiedSendBatchSuccessResponse"}]}}}},"202":{"description":"Message accepted and queued.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendSuccessResponse"}}}},"207":{"description":"Batch send completed with mixed success and failure (all items were attempted).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendBatchSuccessResponse"}}}},"400":{"description":"Invalid request payload, blocked pre-send validation (e.g. WHATSAPP_NOT_REGISTERED), or TEMPLATE_NOT_META_APPROVED when the official WhatsApp / Meta template is pending or rejected. SMS_MULTIPART_LIMIT_EXCEEDED rejects more than 32 sections; SMS_MULTIPART_URL_TOO_LONG rejects an unbreakable oversized URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"402":{"description":"Insufficient balance.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"User, subscription, or permissions do not allow sending.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"409":{"description":"Idempotency conflict: IDEMPOTENCY_KEY_CONFLICT (same key, different body) or IDEMPOTENCY_IN_PROGRESS (same key still processing). Retry-After may be present for in-progress. SMS_MULTIPART_PAYLOAD_CONFLICT rejects changed frozen text/sender. SMS_MULTIPART_PREVIOUS_CHARGE_REVIEW_REQUIRED blocks splitting an already charged legacy attempt pending financial review.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"502":{"description":"External send failed, including SMS_PARTIAL_DELIVERY or SMS_MULTIPART_ACCEPTANCE_UNKNOWN. Sectioned SMS returns details.smsMultipart and the total recorded wallet price in billing. Keep the same Idempotency-Key to replay the cached outcome; resume failed sections through message history instead of creating a new send. An uncertain acknowledgement must be reconciled before retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"503":{"description":"No provider is currently available.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}}}},"/api/v2/messages/policies":{"get":{"tags":["Messaging"],"summary":"List provider message policies","description":"Returns the provider/channel policies that govern which unified message types can be sent. Auth: X-API-Key with messages:create and a verified phone.","operationId":"listMessagePolicies","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Policy list","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"success":{"type":"boolean","example":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/ProviderMessagePolicy"}}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified or missing messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}}}},"/api/v2/messages/bulk":{"post":{"tags":["Messaging"],"summary":"Queue a bulk send job","operationId":"queueBulkMessages","description":"Stores an array of single-recipient send payloads and returns 202. Sending starts only after every row passes validation. messagesPerSecond is a required integer from 1 to 50 and is a ceiling shared by this account's running jobs, in creation order. Each job is capped at 10,000 messages (HTTP 413, code BULK_TOO_LARGE). Split larger audiences into multiple jobs. Idempotency-Key is required (maximum 200 characters). The same key and the same name, messagesPerSecond, and messages return the existing job. Object key order does not matter. The same key with a different body returns 409. Extra fields outside name, messagesPerSecond, and messages are ignored. scheduleAt is rejected later for the whole job. Duplicate recipients are allowed. One invalid row rejects the job and nothing is sent. The API key needs messages:create, a verified phone, and an active subscription.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":1,"maxLength":200},"description":"Required retry key. Keep it on your server. Do not reuse it for a different body."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["messagesPerSecond","messages"],"properties":{"name":{"type":"string","maxLength":120,"description":"Optional label."},"messagesPerSecond":{"type":"integer","minimum":1,"maximum":50},"messages":{"type":"array","minItems":1,"maxItems":10000,"description":"Each item is one recipient and uses the same fields as POST /api/v2/messages/send (to, channel, messageType, content, sender, template, attachment). to is one recipient. scheduleAt is not allowed. OTP, marketing, templates, and attachments follow the same plan rules as a single send. A disallowed row rejects the whole job during validation.","items":{"$ref":"#/components/schemas/UnifiedSendRequest"}}}},"example":{"name":"Morning notices","messagesPerSecond":10,"messages":[{"to":"+963912345678","channel":"local_sms","messageType":"free_text","content":{"text":"Example notice from Rasel."}},{"to":"+963987654321","channel":"local_sms","messageType":"free_text","content":{"text":"Example notice from Rasel."}}]}}}},"responses":{"202":{"description":"Job stored. status is validating for a new job. The same idempotency key and body return this status with the job's current status. Poll GET /api/v2/messages/bulk/{jobId}.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["success","id","name","status","messagesPerSecond","pauseReason","total","validatedCount","counts","errorCode","errorMessage"],"properties":{"id":{"type":"string","examples":["64b0c0ff0000000000000001"]},"name":{"type":"string","description":"Optional label. Stored up to 120 characters. Empty when omitted."},"status":{"type":"string","enum":["accepting","validating","rejected","queued","running","paused","completed","cancelled"],"description":"accepting: rows are still being stored and nothing is sent. validating: every row is checked and nothing is sent yet. rejected: nothing was sent. queued: waiting for a send slot. running: sending. paused: sending stopped. completed: finished, including when some rows failed. cancelled: remaining unsent rows were cancelled."},"messagesPerSecond":{"type":"integer","minimum":1,"maximum":50},"pauseReason":{"type":["string","null"],"enum":["insufficient_balance","provider_rate_limit","user",null],"description":"Set only while status is paused. insufficient_balance and provider_rate_limit stop the current window. user means the account requested pause."},"total":{"type":"integer","minimum":0,"description":"Number of rows in the accepted request."},"validatedCount":{"type":"integer","minimum":0,"description":"How many rows have been checked while status is validating."},"counts":{"$ref":"#/components/schemas/BulkJobCounts"},"errorCode":{"type":["string","null"],"description":"Job-level code when status is rejected: VALIDATION_FAILED (one or more rows failed checks; nothing sent), INSUFFICIENT_BALANCE (the account cannot send even one message; nothing sent), INTAKE_INCOMPLETE (storage did not finish; nothing sent)."},"errorMessage":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"startedAt":{"type":["string","null"],"format":"date-time"},"completedAt":{"type":["string","null"],"format":"date-time"},"lastSentAt":{"type":["string","null"],"format":"date-time"},"success":{"type":"boolean","const":true}}},"example":{"success":true,"id":"64b0c0ff0000000000000001","name":"Morning notices","status":"validating","messagesPerSecond":10,"pauseReason":null,"total":2,"validatedCount":0,"counts":{"pending":0,"sent":0,"failed":0,"cancelled":0},"errorCode":null,"errorMessage":null,"createdAt":"2026-09-24T12:00:00.000Z"}}}},"400":{"description":"Cheap gate failed before a job is stored. Codes: IDEMPOTENCY_KEY_REQUIRED, IDEMPOTENCY_KEY_INVALID (empty or longer than 200), INVALID_REQUEST_BODY, MESSAGES_PER_SECOND_INVALID (missing, zero, fraction, or above 50), MESSAGES_REQUIRED (missing or empty array), INVALID_MESSAGE (an item is not an object).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"MESSAGES_PER_SECOND_INVALID","error":"messagesPerSecond must be an integer from 1 to 50"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"403":{"description":"SUBSCRIPTION_INACTIVE when the subscription is inactive, before any job is stored. FORBIDDEN when the phone is unverified or messages:create is missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"SUBSCRIPTION_INACTIVE","error":"Subscription is inactive"}}}},"409":{"description":"Same Idempotency-Key with a different body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"IDEMPOTENCY_CONFLICT","error":"Idempotency key was used with a different body"}}}},"413":{"description":"Job exceeds the 10,000-message product cap. Split into multiple jobs. Code: BULK_TOO_LARGE.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"BULK_TOO_LARGE","error":"A bulk job cannot exceed 10000 messages"}}}}}}},"/api/v2/messages/bulk/{jobId}":{"get":{"tags":["Messaging"],"summary":"Read a bulk job","operationId":"getBulkMessageJob","description":"Returns status, counts, validation progress, pause reason, and job error code for the owning account. Poll until status is queued, running, rejected, paused, completed, or cancelled. Requires messages:read.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."}],"responses":{"200":{"description":"The job that belongs to this API key.","content":{"application/json":{"schema":{"type":"object","required":["success","job"],"properties":{"success":{"type":"boolean","const":true},"job":{"$ref":"#/components/schemas/BulkPublicJob"}}},"example":{"success":true,"job":{"id":"64b0c0ff0000000000000001","name":"Morning notices","status":"running","messagesPerSecond":10,"pauseReason":null,"total":2,"validatedCount":2,"counts":{"pending":1,"sent":1,"failed":0,"cancelled":0},"errorCode":null,"errorMessage":null,"createdAt":"2026-09-24T12:00:00.000Z"}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"403":{"description":"Phone is not verified or the key lacks messages:read.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}}}}},"/api/v2/messages/bulk/{jobId}/items":{"get":{"tags":["Messaging"],"summary":"List bulk job rows","operationId":"listBulkMessageItems","description":"One page of rows for the owning account. Page size is 50. cursor is the zero-based row index to start from. nextCursor is null on the last page. Message text and template variables are included. File bytes are not. An unknown status filter returns an empty page. Requires messages:read.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."},{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["received","pending","sending","sent","failed","cancelled"]},"description":"Optional row status filter."},{"name":"cursor","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0},"description":"Row index to start from, inclusive."}],"responses":{"200":{"description":"A page of rows.","content":{"application/json":{"schema":{"type":"object","required":["success","items","nextCursor"],"properties":{"success":{"type":"boolean","const":true},"items":{"type":"array","items":{"$ref":"#/components/schemas/BulkItem"}},"nextCursor":{"type":["integer","null"]}}},"example":{"success":true,"items":[{"index":0,"status":"failed","to":"+963912345678","channel":"local_sms","senderId":"","templateName":"","text":"Example notice from Rasel.","variables":null,"errorCode":"SEND_FAILED","errorMessage":"Send failed","requestId":null}],"nextCursor":null}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"403":{"description":"Phone is not verified or the key lacks messages:read.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}}}}},"/api/v2/messages/bulk/{jobId}/errors":{"get":{"tags":["Messaging"],"summary":"List bulk job errors","operationId":"listBulkMessageErrors","description":"One page of rows that have an error code. Includes validation failures and send failures. Page size is 50. cursor is the row index. Validation row codes include SCHEDULE_NOT_ALLOWED, TO_REQUIRED, CONTENT_REQUIRED, MARKETING_NOT_ALLOWED, CONTENT_BLOCKED, SENDER_NOT_FOUND, TEMPLATE_REQUIRED, TEMPLATE_NOT_FOUND, and TEMPLATE_UNAVAILABLE. Recipient format uses the same codes as a single send. A send-time failure uses that send's code, or SEND_FAILED when the send has no code. SUBSCRIPTION_INACTIVE means the subscription ended and remaining rows were failed. Opt-out or a blocked recipient fails that row only at send time. Requires messages:read.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."},{"name":"cursor","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0},"description":"Row index to start from, inclusive."}],"responses":{"200":{"description":"A page of error rows. Does not include message text.","content":{"application/json":{"schema":{"type":"object","required":["success","errors","nextCursor"],"properties":{"success":{"type":"boolean","const":true},"errors":{"type":"array","items":{"type":"object","required":["index","code","message"],"properties":{"index":{"type":"integer"},"code":{"type":["string","null"]},"message":{"type":["string","null"]}}}},"nextCursor":{"type":["integer","null"]}}},"example":{"success":true,"errors":[{"index":1,"code":"SENDER_NOT_FOUND","message":"Sender was not found"}],"nextCursor":null}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"403":{"description":"Phone is not verified or the key lacks messages:read.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}}}}},"/api/v2/messages/bulk/{jobId}/pause":{"post":{"tags":["Messaging"],"summary":"Pause a bulk job","operationId":"pauseBulkMessageJob","description":"Accepts a pause for a job in validating, queued, or running. The current send window can still finish. Poll GET until status is paused and pauseReason is user. No request body. Requires messages:create.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."}],"responses":{"200":{"description":"The job that belongs to this API key.","content":{"application/json":{"schema":{"type":"object","required":["success","job"],"properties":{"success":{"type":"boolean","const":true},"job":{"$ref":"#/components/schemas/BulkPublicJob"}}},"example":{"success":true,"job":{"id":"64b0c0ff0000000000000001","name":"Morning notices","status":"running","messagesPerSecond":10,"pauseReason":null,"total":2,"validatedCount":2,"counts":{"pending":1,"sent":1,"failed":0,"cancelled":0},"errorCode":null,"errorMessage":null,"createdAt":"2026-09-24T12:00:00.000Z"}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"403":{"description":"Phone is not verified or the key lacks messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}},"409":{"description":"The job is not validating, queued, or running.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_PAUSABLE","error":"Job cannot be paused"}}}}}}},"/api/v2/messages/bulk/{jobId}/resume":{"post":{"tags":["Messaging"],"summary":"Resume a paused bulk job","operationId":"resumeBulkMessageJob","description":"Resumes a paused job. No request body. If pauseReason is insufficient_balance and the account still cannot send one message, the response is 402 and the job stays paused. If the subscription is inactive, remaining rows fail with SUBSCRIPTION_INACTIVE and the job becomes completed. A provider rate-limit pause resumes without another balance check beyond the normal send path. Requires messages:create. This call can start delivery and debit the account.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."}],"responses":{"200":{"description":"The job that belongs to this API key.","content":{"application/json":{"schema":{"type":"object","required":["success","job"],"properties":{"success":{"type":"boolean","const":true},"job":{"$ref":"#/components/schemas/BulkPublicJob"}}},"example":{"success":true,"job":{"id":"64b0c0ff0000000000000001","name":"Morning notices","status":"running","messagesPerSecond":10,"pauseReason":null,"total":2,"validatedCount":2,"counts":{"pending":1,"sent":1,"failed":0,"cancelled":0},"errorCode":null,"errorMessage":null,"createdAt":"2026-09-24T12:00:00.000Z"}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"402":{"description":"The account cannot send one message. The job stays paused.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"INSUFFICIENT_BALANCE","error":"The account cannot send one message"}}}},"403":{"description":"Phone is not verified or the key lacks messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}},"409":{"description":"The job is not paused.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_PAUSED","error":"Job is not paused"}}}}}}},"/api/v2/messages/bulk/{jobId}/cancel":{"post":{"tags":["Messaging"],"summary":"Cancel a bulk job","operationId":"cancelBulkMessageJob","description":"Accepts cancellation unless the job is already completed, cancelled, or rejected. The current send window can still finish, then unsent rows become cancelled. Poll GET until status is cancelled. No request body. Requires messages:create.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."}],"responses":{"200":{"description":"The job that belongs to this API key.","content":{"application/json":{"schema":{"type":"object","required":["success","job"],"properties":{"success":{"type":"boolean","const":true},"job":{"$ref":"#/components/schemas/BulkPublicJob"}}},"example":{"success":true,"job":{"id":"64b0c0ff0000000000000001","name":"Morning notices","status":"running","messagesPerSecond":10,"pauseReason":null,"total":2,"validatedCount":2,"counts":{"pending":1,"sent":1,"failed":0,"cancelled":0},"errorCode":null,"errorMessage":null,"createdAt":"2026-09-24T12:00:00.000Z"}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"403":{"description":"Phone is not verified or the key lacks messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}},"409":{"description":"The job is completed, cancelled, or rejected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_CANCELLABLE","error":"Job cannot be cancelled"}}}}}}},"/api/v2/messages/bulk/{jobId}/retry-failed":{"post":{"tags":["Messaging"],"summary":"Retry failed bulk rows","operationId":"retryFailedBulkMessages","description":"Moves every failed row back to pending and queues the job. No request body. If the account cannot send one message, the response is 402 and failed rows stay failed. If there is no failed row, the response is 409. Requires messages:create. This call can start delivery and debit the account.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"},"description":"Job id returned by POST /api/v2/messages/bulk. A job belongs to the API key account only."}],"responses":{"200":{"description":"Failed rows were requeued. retried is how many rows moved back to pending.","content":{"application/json":{"schema":{"type":"object","required":["success","job","retried"],"properties":{"success":{"type":"boolean","const":true},"job":{"$ref":"#/components/schemas/BulkPublicJob"},"retried":{"type":"integer","minimum":1}}},"example":{"success":true,"retried":1,"job":{"id":"64b0c0ff0000000000000001","name":"Morning notices","status":"queued","messagesPerSecond":10,"pauseReason":null,"total":2,"validatedCount":2,"counts":{"pending":1,"sent":1,"failed":0,"cancelled":0},"errorCode":null,"errorMessage":null,"createdAt":"2026-09-24T12:00:00.000Z"}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"UNAUTHORIZED","error":"Missing or invalid API key"}}}},"402":{"description":"The account cannot send one message. Failed rows stay failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"INSUFFICIENT_BALANCE","error":"The account cannot send one message"}}}},"403":{"description":"Phone is not verified or the key lacks messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"FORBIDDEN","error":"Phone not verified or missing permission"}}}},"404":{"description":"No job with this id belongs to the API key account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"JOB_NOT_FOUND","error":"Job was not found"}}}},"409":{"description":"There are no failed rows.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkErrorResponse"},"example":{"success":false,"code":"NOTHING_TO_RETRY","error":"There are no failed messages"}}}}}}},"/api/v2/verification/send":{"post":{"tags":["Verification"],"summary":"Send verification code","description":"Creates a new user_verification attempt, supersedes any previous active code for the same number, and sends a newly generated code. Trial accounts deliver the approved fixed text and include a trial notice.","operationId":"sendVerificationCodeV2","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Optional unique key for safe retries of the same verification send. Prefer a new key when intentionally requesting a new code."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationSendRequest"}}}},"responses":{"200":{"description":"Verification code sent successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationSendResponse"}}}},"400":{"description":"Invalid payload or delivery channel selection.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"403":{"description":"The account is not allowed to use the verification API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"409":{"description":"Idempotency conflict (IDEMPOTENCY_KEY_CONFLICT) or in-progress (IDEMPOTENCY_IN_PROGRESS).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}}}}},"/api/v2/verification/resend":{"post":{"tags":["Verification"],"summary":"Resend verification code","description":"Generates a fresh code for the current active verification. If no active verification exists for the target number, the API creates a new one using the same internal policy.","operationId":"resendVerificationCodeV2","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationResendRequest"}}}},"responses":{"200":{"description":"Verification code resent successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationSendResponse"}}}},"400":{"description":"Invalid request or the verification cannot be resent in its current state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"404":{"description":"Verification reference not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"409":{"description":"The referenced verification is already verified.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"429":{"description":"Cooldown or resend limit reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}}}}},"/api/v2/verification/verify":{"post":{"tags":["Verification"],"summary":"Verify latest code","description":"Validates only the latest active code for the requested verification. Older codes become invalid after resend or replacement.","operationId":"verifyVerificationCodeV2","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationVerifyRequest"}}}},"responses":{"200":{"description":"Verification succeeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationVerifySuccessResponse"}}}},"400":{"description":"Invalid code or invalid request payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"404":{"description":"Verification reference not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"410":{"description":"Verification expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}},"429":{"description":"Maximum verification attempts exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerificationErrorResponse"}}}}}}},"/api/v2/account/wallet/spend-report":{"get":{"operationId":"getWalletSpendReport","tags":["Account"],"summary":"Wallet message spend by API key","description":"Requires api_keys:read and wallet_read. Defaults to the authenticated key. apiKeyId accepts an owned key ID, all, or unattributed. Reports successful wallet-paid messages at their recorded net price after discounts; excludes bundles and free grants. Sender restrictions still apply. Historical unattributed records cannot be reconstructed. Account balance, subscriptions and ledger remain account-wide and are available through existing account APIs. Use month OR both fromDate/toDate, equal dates for one day; maximum range 10 years. IDs are database references, never secret credentials.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"apiKeyId","in":"query","description":"Owned key ID, all, or unattributed. Omit for the authenticated key.","schema":{"type":"string"}},{"name":"month","in":"query","schema":{"type":"string","pattern":"^[0-9]{4}-(0[1-9]|1[0-2])$","example":"2026-11"}},{"name":"fromDate","in":"query","schema":{"type":"string","format":"date","example":"2026-11-01"}},{"name":"toDate","in":"query","schema":{"type":"string","format":"date","example":"2026-11-01"}},{"name":"channel","in":"query","schema":{"type":"string","enum":["all","whatsapp_user_session","whatsapp_web","whatsapp_official","telegram_verifyway","telegram_bot","sms_twilio","sms_clicksend","sms_syria","sms_taqnyat","email_system","email_user"],"example":"sms_syria"}},{"name":"messageType","in":"query","schema":{"type":"string","enum":["all","otp","utility","marketing","free_text"]}}],"responses":{"200":{"description":"Net spend and message/unit counts with monthly/channel/type breakdowns. No wallet balance or ledger totals are scoped to a key.","content":{"application/json":{"example":{"success":true,"data":{"period":{"fromDate":"2026-11-01","toDate":"2026-11-30","timezone":"Asia/Damascus"},"filters":{"apiKeyId":"6800abc123def4567890fedc","channel":null,"messageType":null},"apiKey":{"id":"6800abc123def4567890fedc","name":"Online store","revoked":false,"deleted":false},"currency":"USD","coverage":"successful_wallet_paid_messages","senderScope":"all","totals":{"spendUsd":0.8,"messageCount":2,"segmentCount":4,"averageMessageCostUsd":0.4},"monthly":[{"key":"2026-11","spendUsd":0.8,"messageCount":2,"segmentCount":4,"averageMessageCostUsd":0.4}],"byChannel":[{"key":"sms_syria","spendUsd":0.8,"messageCount":2,"segmentCount":4,"averageMessageCostUsd":0.4}],"byMessageType":[{"key":"utility","spendUsd":0.8,"messageCount":2,"segmentCount":4,"averageMessageCostUsd":0.4}]}},"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"period":{"type":"object","properties":{"fromDate":{"type":"string","format":"date"},"toDate":{"type":"string","format":"date"},"timezone":{"type":"string"}}},"filters":{"type":"object","properties":{"apiKeyId":{"type":["string","null"]},"channel":{"type":["string","null"]},"messageType":{"type":["string","null"]}}},"apiKey":{"type":["object","null"],"properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"revoked":{"type":"boolean"},"deleted":{"type":"boolean"}}},"currency":{"type":"string","enum":["USD"]},"coverage":{"type":"string"},"senderScope":{"type":"string","enum":["all","selected"]},"totals":{"type":"object","properties":{"spendUsd":{"type":"number"},"messageCount":{"type":"integer"},"segmentCount":{"type":"integer"},"averageMessageCostUsd":{"type":"number"}}},"monthly":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"spendUsd":{"type":"number"},"messageCount":{"type":"integer"},"segmentCount":{"type":"integer"},"averageMessageCostUsd":{"type":"number"}}}},"byChannel":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"spendUsd":{"type":"number"},"messageCount":{"type":"integer"},"segmentCount":{"type":"integer"},"averageMessageCostUsd":{"type":"number"}}}},"byMessageType":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"spendUsd":{"type":"number"},"messageCount":{"type":"integer"},"segmentCount":{"type":"integer"},"averageMessageCostUsd":{"type":"number"}}}}}}}}}}},"400":{"description":"Invalid key ID, date, range, channel, message type, or conflicting period inputs."},"401":{"description":"Missing, invalid or revoked API key."},"403":{"description":"Missing permission or wallet_read scope."},"429":{"description":"At most 60 requests per minute per authenticated key."},"500":{"description":"Report unavailable; retry later."}}}},"/api/v2/account":{"get":{"tags":["Account"],"summary":"Get account snapshot","description":"Returns the API key owner's safe profile fields, current wallet balance, active subscription summary, and complimentary admin gift message grants (`freeMessageGrants`).","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Account snapshot","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperAccountSnapshotResponse"},"examples":{"withGiftMessages":{"summary":"Snapshot including admin gift message grants","value":{"success":true,"data":{"profile":{"id":"6800user123def4567890ffff","name":"Acme Co","email":"ops@acme.example","phone":"+963912345678","avatar":null,"phoneVerified":true,"businessName":"Acme","appName":"Acme App","businessNameVerified":true,"appNameVerified":true,"ownerId":null,"memberPermissions":null,"createdAt":"2026-01-10T08:00:00.000Z"},"wallet":{"balance":4.88,"availableBalance":4.88,"currency":"USD"},"subscription":{"access":{"canSend":true,"reason":"ok","poolExhausted":false,"effectiveLimit":1000,"periodMessageLimit":1000,"bonusMessagesGranted":0,"remainingSegments":800,"usageCount":200,"usageByChannel":{},"channelLimits":null,"cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z"},"active":{"planName":"Growth","status":"active","startAt":"2026-07-01T00:00:00.000Z","endAt":"2026-08-01T00:00:00.000Z","isTrial":false,"billingCycleMonths":1},"pool":{"hasActivePlan":true,"poolSuppressed":false,"effectiveLimit":1000,"usedSegments":200,"remainingSegments":800,"usedMessages":180,"usageByChannel":{},"channelLimits":null,"cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z","poolExhausted":false,"planName":"Growth"}},"freeMessageGrants":{"hasMore":false,"summary":{"totals":{"granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90},"activeGrantCount":1,"grantCount":1,"byScope":[{"channel":"sms_local","providerKey":null,"messageType":"all","granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90,"grantCount":1}]},"grants":[{"id":"6800abc123def4567890fedc","channel":"sms_local","providerKey":null,"messageType":"all","initialQuantity":100,"consumedQuantity":10,"reservedQuantity":0,"withdrawnQuantity":0,"remainingQuantity":90,"status":"active","cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z","expiresAt":"2026-08-31T23:59:59.000Z","reason":"admin_gift","userNote":"Complimentary SMS gift from support","subscriptionId":null,"createdAt":"2026-07-15T10:00:00.000Z"}]}}}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Missing api_keys:read permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"getAccountSnapshot"}},"/api/v2/account/subscriptions":{"get":{"tags":["Account"],"summary":"List subscription history","description":"Paginated subscription periods and billing charges for the API key owner, plus complimentary admin gift message grants (`freeMessageGrants`). Sensitive internal fields are omitted.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"skip","in":"query","schema":{"type":"integer","minimum":0,"default":0}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","active","scheduled","expired","paused","cancelled","upgrade_pending"]}},{"name":"include","in":"query","schema":{"type":"string","enum":["charges","subscriptions"]},"description":"Default includes both subscriptions and charges. Use subscriptions to omit charges."}],"responses":{"200":{"description":"Subscription history page","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperSubscriptionHistoryResponse"},"examples":{"withGiftMessages":{"summary":"History including admin gift message grants","value":{"success":true,"data":{"subscriptions":[{"id":"6800sub123def4567890cccc","status":"active","startAt":"2026-07-01T00:00:00.000Z","endAt":"2026-08-01T00:00:00.000Z","billingCycleMonths":1,"isTrial":false,"periodMessageLimit":1000,"periodChannelLimits":null,"bonusMessagesGranted":0,"poolSuppressedByCoupon":false,"plan":{"id":"6800plan123def4567890dddd","name":"Growth","monthlyPrice":49},"createdAt":"2026-07-01T00:00:00.000Z"}],"charges":[],"freeMessageGrants":{"hasMore":false,"summary":{"totals":{"granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90},"activeGrantCount":1,"grantCount":1,"byScope":[{"channel":"sms_local","providerKey":null,"messageType":"all","granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90,"grantCount":1}]},"grants":[{"id":"6800abc123def4567890fedc","channel":"sms_local","providerKey":null,"messageType":"all","initialQuantity":100,"consumedQuantity":10,"reservedQuantity":0,"withdrawnQuantity":0,"remainingQuantity":90,"status":"active","cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z","expiresAt":"2026-08-31T23:59:59.000Z","reason":"admin_gift","userNote":"Complimentary SMS gift from support","subscriptionId":null,"createdAt":"2026-07-15T10:00:00.000Z"}]},"totalSubscriptions":1,"totalCharges":0,"skip":0,"limit":100}}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Missing api_keys:read permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listAccountSubscriptions"}},"/api/v2/account/wallet/transactions":{"get":{"tags":["Account"],"summary":"List wallet transactions","description":"Paginated wallet ledger for the API key owner, plus complimentary admin gift message grants in `data.freeMessageGrants` (summary + grants). Gift grants are not wallet money rows; they are complimentary message credits. Internal billing margins and operation keys are omitted.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"skip","in":"query","schema":{"type":"integer","minimum":0,"default":0,"example":0}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":500,"default":100,"example":100}},{"name":"fromDate","in":"query","schema":{"type":"string","format":"date","example":"2026-01-01"}},{"name":"toDate","in":"query","schema":{"type":"string","format":"date","example":"2026-06-30"}},{"name":"type","in":"query","schema":{"type":"string","enum":["credit","debit"],"example":"debit"}},{"name":"source","in":"query","schema":{"type":"string","enum":["admin_topup","usage","topup_request","default_plan_bonus","trial_balance","admin_withdrawal","subscription_refund","subscription_payment","coupon","send_failure_refund"],"example":"usage"}}],"responses":{"200":{"description":"Wallet transactions page. Always includes `freeMessageGrants` (empty grants array when none exist).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperWalletTransactionsResponse"},"examples":{"withGiftMessages":{"summary":"Wallet ledger + admin gift message grants","value":{"success":true,"data":{"transactions":[{"id":"6800bbb123def4567890aaaa","amount":0.12,"type":"debit","source":"usage","description":"SMS send","balanceAfter":4.88,"messageCount":1,"walletTopupDiscountPercent":null,"walletTopupDiscountCouponCode":null,"createdAt":"2026-07-20T14:22:00.000Z"},{"id":"6800ccc123def4567890bbbb","amount":10,"type":"credit","source":"admin_topup","description":"Admin top-up","balanceAfter":5,"messageCount":null,"walletTopupDiscountPercent":null,"walletTopupDiscountCouponCode":null,"createdAt":"2026-07-18T09:00:00.000Z"}],"freeMessageGrants":{"hasMore":false,"summary":{"totals":{"granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90},"activeGrantCount":1,"grantCount":1,"byScope":[{"channel":"sms_local","providerKey":null,"messageType":"all","granted":100,"consumed":10,"reserved":0,"withdrawn":0,"remaining":90,"activeRemaining":90,"grantCount":1}]},"grants":[{"id":"6800abc123def4567890fedc","channel":"sms_local","providerKey":null,"messageType":"all","initialQuantity":100,"consumedQuantity":10,"reservedQuantity":0,"withdrawnQuantity":0,"remainingQuantity":90,"status":"active","cycleStart":"2026-07-01T00:00:00.000Z","cycleEnd":"2026-08-01T00:00:00.000Z","expiresAt":"2026-08-31T23:59:59.000Z","reason":"admin_gift","userNote":"Complimentary SMS gift from support","subscriptionId":null,"createdAt":"2026-07-15T10:00:00.000Z"}]},"total":2,"balance":4.88,"skip":0,"limit":100}}},"noGiftMessages":{"summary":"Wallet ledger with no gift grants","value":{"success":true,"data":{"transactions":[{"id":"6800bbb123def4567890aaaa","amount":0.12,"type":"debit","source":"usage","description":"SMS send","balanceAfter":4.88,"messageCount":1,"walletTopupDiscountPercent":null,"walletTopupDiscountCouponCode":null,"createdAt":"2026-07-20T14:22:00.000Z"},{"id":"6800ccc123def4567890bbbb","amount":10,"type":"credit","source":"admin_topup","description":"Admin top-up","balanceAfter":5,"messageCount":null,"walletTopupDiscountPercent":null,"walletTopupDiscountCouponCode":null,"createdAt":"2026-07-18T09:00:00.000Z"}],"freeMessageGrants":{"summary":{"totals":{"granted":0,"consumed":0,"reserved":0,"withdrawn":0,"remaining":0,"activeRemaining":0},"activeGrantCount":0,"grantCount":0,"byScope":[]},"grants":[]},"total":2,"balance":4.88,"skip":0,"limit":100}}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Missing api_keys:read permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listWalletTransactions"}},"/api/v2/sms-senders":{"get":{"tags":["SMS Senders"],"summary":"List SMS sender names","description":"Requires send scope, which includes sender discovery. Returns only SMS sender names allowed by the API key sender constraint. Use approvedOnly=true to fetch senders usable in /api/v2/messages/send.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"approvedOnly","in":"query","schema":{"type":"boolean","default":false},"description":"When true, returns only approved senders."}],"responses":{"200":{"description":"SMS sender list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsSenderListResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified or missing permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listSmsSenders"},"post":{"tags":["SMS Senders"],"summary":"Request a new SMS sender name","description":"Submits a new sender name for admin review. The sender remains pending until approved. Account owners only (team members cannot create via API).\n\nOptional: set webhookUrl + webhookSecret to receive a POST callback when the sender is approved or rejected.\n\nWebhook headers:\n- Authorization: Bearer <webhookSecret>\n- X-Rasel-Event: sms_sender.approved | sms_sender.rejected\n\nWebhook payload schema: SmsSenderWebhookPayload","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsSenderCreateRequest"}}}},"responses":{"201":{"description":"Sender name submitted for review","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsSenderCreateResponse"}}}},"400":{"description":"Validation error or duplicate name.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Team member or phone not verified.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"createSmsSender"}},"/api/v2/official-senders":{"get":{"tags":["Official Senders"],"summary":"List official WhatsApp senders","description":"Requires send scope, which includes sender discovery. Returns only official WhatsApp senders allowed by the API key sender constraint. Use approvedOnly=true to fetch only senders usable in /api/v2/messages/send and /api/v2/templates.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"approvedOnly","in":"query","schema":{"type":"boolean","default":false},"description":"When true, returns only approved and enabled senders."}],"responses":{"200":{"description":"Official sender list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OfficialSenderListResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified or missing permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listOfficialSenders"}},"/api/v2/templates":{"get":{"tags":["Templates"],"summary":"List templates","description":"Returns every template the API key owner can see (account templates plus platform default templates) when officialSenderId, limit, and cursor are omitted. For bounded reads, pass limit (1-100) and follow pageInfo.nextCursor. Default status filter is active and approved. Use provider=user_session, meta, or internal to narrow WhatsApp sources. Each row includes officialSender, isPlatformNumber, headerType, headerAssetId, headerPreviewUrl, and allowsHeaderMediaOverride. When allowsHeaderMediaOverride is true, POST /api/v2/messages/send accepts headerMedia or template.headerMediaUrl in the same request. Use GET /api/v2/templates/platform for only the platform number, or GET /api/v2/templates/{id} for one template.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"category","in":"query","schema":{"type":"string","enum":["whatsapp","sms","message","email"]}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","rejected","active","disabled"]}},{"name":"provider","in":"query","schema":{"type":"string","enum":["user_session","meta","internal"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Enables bounded cursor pagination. When omitted with cursor, the page size is 50. When both limit and cursor are omitted, the legacy all-visible response is preserved."},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"Opaque nextCursor from the previous paginated response."},{"name":"officialSenderId","in":"query","schema":{"type":"string"},"description":"Narrows results to templates bound to one official WhatsApp sender id from GET /api/v2/official-senders. Use the literal \"platform\" for templates created on the platform default Meta number (useDefaultCredentials)."}],"responses":{"200":{"description":"Template list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListResponse"},"examples":{"allTemplates":{"summary":"All visible templates (no officialSenderId)","value":{"data":[{"id":"6800tpl123def4567890aaaa","name":"order_ready_notice","category":"whatsapp","subType":"utility","language":"ar","status":"approved","headerType":"image","headerValue":null,"headerAssetId":null,"headerPreviewUrl":null,"allowsHeaderMediaOverride":true,"provider":"meta","officialSenderId":"platform","officialSender":{"id":"platform","scope":"platform","isPlatform":true,"isDefault":true,"label":null,"phoneNumber":null,"displayName":"platform"},"isPlatformNumber":true,"isDefault":false,"createdAt":"2026-09-01T10:00:00.000Z"},{"id":"6800tpl123def4567890bbbb","name":"promo_offer","category":"whatsapp","subType":"utility","language":"ar","status":"approved","headerType":"image","headerValue":null,"headerAssetId":null,"headerPreviewUrl":null,"allowsHeaderMediaOverride":true,"provider":"meta","officialSenderId":"6800abc123def4567890abcd","officialSender":{"id":"6800abc123def4567890abcd","scope":"official_sender","isPlatform":false,"isDefault":false,"label":"SAWA","phoneNumber":"+963911111111","displayName":"SAWA · +963911111111"},"isPlatformNumber":false,"isDefault":false,"createdAt":"2026-09-01T10:00:00.000Z"}]}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"404":{"description":"Templates feature disabled."},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listTemplates"},"post":{"tags":["Templates"],"summary":"Create a template","description":"Creates a template of any supported type. Auth: X-API-Key with messages:create and a verified phone.\n\nJSON (application/json): same fields as before. For a media header either pass headerAssetId from POST /api/v2/templates/media, or send this create call as multipart/form-data with the file in headerMedia or file.\n\nMultipart (multipart/form-data): text fields match the JSON body. Attach the image/video/PDF as headerMedia or file. Optional payload is a JSON string for buttons and bodyParameters. Do not put a File object inside JSON.\n\nComplete WhatsApp utility example (see request examples): use {{1}} {{2}} {{3}} in the body with matching bodyParameters, then add a URL button (url + urlExample) and a phone button. Footer is optional text with no variables.\n\nWhatsApp official templates are submitted to Meta according to the account's approved official sender. Without an approved sender, the platform official number is used when available.\n\nUser WhatsApp Web templates: set provider or templateTarget to user_session. No footer/buttons.\n\nManual official bind: creationMode=manual_external_id plus providerTemplateId.\n\nName must be lowercase English with underscores (order_ready_notice).","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateCreateRequest"},"examples":{"whatsappFull":{"summary":"WhatsApp utility with header image, variables, and buttons","description":"JSON path: upload an image via POST /api/v2/templates/media and replace headerAssetId, or send the same fields as multipart with headerMedia. {{1}} {{2}} {{3}} in body are filled from bodyParameters labels (examples for Meta) and later from variablesIndexed when sending. URL button uses {{1}} in the path; send the suffix with template.buttonVariables. Phone button dials the number in url.","value":{"name":"order_ready_notice","category":"whatsapp","subType":"utility","language":"ar","headerType":"image","headerAssetId":"ASSET_ID_FROM_MEDIA_UPLOAD","body":"مرحباً {{1}}، طلبك رقم {{2}} جاهز للاستلام. الإجمالي {{3}} ل.س.","bodyParameters":[{"index":1,"label":"أحمد"},{"index":2,"label":"A-1042"},{"index":3,"label":"25000"}],"footer":"راسل","buttons":[{"type":"url","text":"تتبع الطلب","url":"https://example.com/orders/{{1}}","urlExample":"https://example.com/orders/A-1042"},{"type":"phone","text":"اتصل بنا","url":"+963911111111"}]}},"whatsappUtility":{"summary":"WhatsApp utility (body only)","value":{"name":"order_confirmation","category":"whatsapp","subType":"utility","language":"ar","body":"مرحباً {{1}}، طلبك رقم {{2}} تم تأكيده.","bodyParameters":[{"index":1,"label":"أحمد"},{"index":2,"label":"12345"}]}},"whatsappOtp":{"summary":"WhatsApp OTP copy code","value":{"name":"login_otp","category":"whatsapp","subType":"otp","language":"ar","otpType":"copy_code","addSecurityRecommendation":true,"codeExpirationMinutes":10,"otpButtonText":"Copy code"}},"userSession":{"summary":"WhatsApp Web session template","value":{"name":"session_welcome","category":"whatsapp","subType":"utility","language":"ar","provider":"user_session","body":"مرحباً {{1}}، شكراً لتواصلك معنا."}},"sms":{"summary":"SMS template","value":{"name":"sms_otp","category":"sms","subType":"otp","content":"رمز التحقق هو {{1}}"}},"email":{"summary":"Email template","value":{"name":"welcome_email","category":"email","subType":"utility","emailSubject":"Welcome","content":"<p>Hello {{1}}</p>"}},"manualEshaar":{"summary":"Bind existing official WhatsApp template","value":{"name":"eshaar_order_status","creationMode":"manual_external_id","providerTemplateId":"1234567890","subType":"utility","language":"ar","manualVariableCount":2}}}},"multipart/form-data":{"schema":{"type":"object","required":["name","category","subType"],"properties":{"name":{"type":"string","example":"invoice_notice"},"category":{"type":"string","enum":["whatsapp","sms","message","email"]},"subType":{"type":"string","enum":["marketing","utility","otp","free","notification"]},"language":{"type":"string","example":"ar"},"body":{"type":"string"},"headerType":{"type":"string","enum":["text","image","video","document"]},"officialSenderId":{"type":"string"},"footer":{"type":"string"},"provider":{"type":"string","enum":["user_session"]},"templateTarget":{"type":"string","enum":["user_session"]},"headerMedia":{"type":"string","format":"binary","description":"Header image, video, or PDF. Alternative field name: file."},"file":{"type":"string","format":"binary","description":"Same as headerMedia. Use one of the two fields."},"payload":{"type":"string","description":"Optional JSON string for buttons and bodyParameters."},"headerAssetId":{"type":"string","description":"Ignored when headerMedia or file is present."}}},"examples":{"whatsappDocument":{"summary":"WhatsApp utility with document header in one request","description":"Send headerMedia as the PDF (or image/video) file. Do not nest a File object inside JSON. Optional payload holds buttons and bodyParameters.","value":{"name":"invoice_notice","category":"whatsapp","subType":"utility","language":"ar","headerType":"document","body":"فاتورتك رقم {{1}} جاهزة.","headerMedia":"(binary PDF)","payload":"{\"bodyParameters\":[{\"index\":1,\"label\":\"A-1042\"}]}"}}}}}},"responses":{"201":{"description":"Template created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateCreateResponse"}}}},"400":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified or missing permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"409":{"description":"Duplicate template name.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"503":{"description":"Official WhatsApp provider unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"createTemplate"}},"/api/v2/templates/platform":{"get":{"tags":["Templates"],"summary":"List platform-number templates","description":"Returns only templates bound to the platform default official WhatsApp number (useDefaultCredentials / officialSenderId=platform). Same filters and optional cursor pagination as GET /api/v2/templates. Does not change the legacy unpaginated list, which still returns every visible template.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"category","in":"query","schema":{"type":"string","enum":["whatsapp","sms","message","email"]}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","rejected","active","disabled"]}},{"name":"provider","in":"query","schema":{"type":"string","enum":["user_session","meta","internal"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Enables bounded cursor pagination. When omitted with cursor, the page size is 50. When both limit and cursor are omitted, the legacy all-visible response is preserved."},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"Opaque nextCursor from the previous paginated response."}],"responses":{"200":{"description":"Templates on the platform default number","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListResponse"},"examples":{"platformTemplates":{"summary":"Platform default number only","value":{"data":[{"id":"6800tpl123def4567890aaaa","name":"order_ready_notice","category":"whatsapp","subType":"utility","language":"ar","status":"approved","headerType":"image","headerValue":null,"headerAssetId":null,"headerPreviewUrl":null,"allowsHeaderMediaOverride":true,"provider":"meta","officialSenderId":"platform","officialSender":{"id":"platform","scope":"platform","isPlatform":true,"isDefault":true,"label":null,"phoneNumber":null,"displayName":"platform"},"isPlatformNumber":true,"isDefault":false,"createdAt":"2026-09-01T10:00:00.000Z"}]}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"404":{"description":"Templates feature disabled."},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listPlatformTemplates"}},"/api/v2/templates/{id}":{"get":{"tags":["Templates"],"summary":"Get one template by id","description":"Returns one template by its Mongo id. The template must belong to the API key owner or be a platform default template. The row includes officialSender, isPlatformNumber, headerType, headerAssetId, headerPreviewUrl, and allowsHeaderMediaOverride.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Template id from GET /api/v2/templates (data[].id).","example":"6800tpl123def4567890aaaa"}],"responses":{"200":{"description":"Template","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateGetResponse"},"examples":{"oneTemplate":{"summary":"Template bound to the platform number","value":{"data":{"id":"6800tpl123def4567890aaaa","name":"order_ready_notice","category":"whatsapp","subType":"utility","language":"ar","status":"approved","headerType":"image","headerValue":null,"headerAssetId":null,"headerPreviewUrl":null,"allowsHeaderMediaOverride":true,"provider":"meta","officialSenderId":"platform","officialSender":{"id":"platform","scope":"platform","isPlatform":true,"isDefault":true,"label":null,"phoneNumber":null,"displayName":"platform"},"isPlatformNumber":true,"isDefault":false,"createdAt":"2026-09-01T10:00:00.000Z"}}}}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"404":{"description":"Template not found."},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"getTemplateById"}},"/api/v2/templates/media":{"post":{"tags":["Templates"],"summary":"Upload template header media","description":"Optional two-step upload. Upload an image, video, or document for a WhatsApp header and pass assetId as headerAssetId on create. You can instead attach the file on POST /api/v2/templates as multipart/form-data. For official WhatsApp you may send mediaUrl instead of a file. For WhatsApp Web templates set targetProvider=user_session.","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["mediaType"],"properties":{"mediaType":{"type":"string","enum":["image","video","document"]},"file":{"type":"string","format":"binary"},"mediaUrl":{"type":"string","description":"HTTPS URL. Official WhatsApp only; alternative to file."},"targetProvider":{"type":"string","enum":["user_session","eshaar","meta"]}}}}}},"responses":{"201":{"description":"Media uploaded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateMediaUploadResponse"}}}},"400":{"description":"Validation or upload error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified or missing permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"uploadTemplateMedia"}},"/api/v2/whatsapp-web/sessions":{"get":{"tags":["Conversation context"],"summary":"List WhatsApp Web sessions","parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"maximum":1000,"default":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"description":"Returns your linked user WhatsApp Web sessions. Use accountId (session name) in send requests and in GET /api/v2/whatsapp-web/chats. System default and presence-probe sessions are excluded.","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Session list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperContextListResponse"},"example":{"success":true,"data":{"page":1,"limit":20,"hasMore":false,"sessions":[{"accountId":"session-user-whatsapp-1","displayName":"Sales WhatsApp","status":"active","connectionState":"ready","moduleType":"whatsapp_web"}]}}}}},"400":{"description":"Invalid query parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified, insufficient scope/permission, or selected sender key (SENDER_NOT_ALLOWED). Chats/subscribers require messages_read; session/bot discovery requires send. All require messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listWhatsAppWebSessions"}},"/api/v2/whatsapp-web/chats":{"get":{"tags":["Conversation context"],"summary":"List WhatsApp Web chats","description":"Lists chats for a session you own. Each item includes a ready conversationContext. Use type=group for native WhatsApp groups (@g.us). Hits the live WhatsApp Web provider — keep limit low (max 50).","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"accountId","in":"query","required":true,"schema":{"type":"string"},"description":"Session name from GET /api/v2/whatsapp-web/sessions."},{"name":"type","in":"query","schema":{"type":"string","enum":["all","direct","group"],"default":"all"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"Opaque pagination cursor from the previous response."}],"responses":{"200":{"description":"Chat list with conversationContext","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperContextListResponse"},"example":{"success":true,"data":{"accountId":"session-user-whatsapp-1","chats":[{"accountId":"session-user-whatsapp-1","chatId":"120363012345678901@g.us","kind":"group","title":"Support group","phoneNumber":null,"conversationKey":"whatsapp_web:session-user-whatsapp-1:120363012345678901@g.us","conversationContext":{"moduleType":"whatsapp_web","accountId":"session-user-whatsapp-1","chatId":"120363012345678901@g.us"}}],"nextCursor":null,"hasMore":false}}}}},"400":{"description":"Missing accountId or invalid query (including cursor).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified, insufficient scope/permission, or selected sender key (SENDER_NOT_ALLOWED). Chats/subscribers require messages_read; session/bot discovery requires send. All require messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"404":{"description":"Session not found for this API key owner.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"409":{"description":"Session exists but is not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"502":{"description":"WhatsApp Web provider failed while listing chats.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"503":{"description":"WhatsApp Web provider is unavailable or timed out.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listWhatsAppWebChats"}},"/api/v2/telegram-bots":{"get":{"tags":["Conversation context"],"summary":"List Telegram bots","parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"maximum":1000,"default":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"description":"Returns your Telegram bots. Use accountId (Mongo id) as conversationContext.accountId. Bot tokens and webhook secrets are never returned.","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Bot list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperContextListResponse"},"example":{"success":true,"data":{"page":1,"limit":20,"hasMore":false,"bots":[{"accountId":"64f1a2b3c4d5e6f7a8b9c0d1","name":"Support bot","botUsername":"mysupportbot","displayName":"Support","isActive":true,"moduleType":"telegram_bot"}]}}}}},"400":{"description":"Invalid query parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified, insufficient scope/permission, or selected sender key (SENDER_NOT_ALLOWED). Chats/subscribers require messages_read; session/bot discovery requires send. All require messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listTelegramBots"}},"/api/v2/telegram-bots/{botId}/subscribers":{"get":{"tags":["Conversation context"],"summary":"List Telegram bot subscribers","description":"Lists users who started this bot. Each item includes a ready conversationContext for POST /api/v2/messages/send with channel=telegram_bot. Ownership is checked before listing.","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"},"description":"Bot Mongo id from GET /api/v2/telegram-bots (same as accountId)."},{"name":"q","in":"query","schema":{"type":"string"},"description":"Optional search on chatId, username, or name."},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"Subscriber list with conversationContext","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeveloperContextListResponse"},"example":{"success":true,"data":{"accountId":"64f1a2b3c4d5e6f7a8b9c0d1","subscribers":[{"accountId":"64f1a2b3c4d5e6f7a8b9c0d1","chatId":"123456789","telegramUserId":"123456789","username":"customer","firstName":"Ali","lastName":null,"lastSeenAt":"2026-08-31T12:00:00.000Z","conversationKey":"telegram_bot:64f1a2b3c4d5e6f7a8b9c0d1:123456789","conversationContext":{"moduleType":"telegram_bot","accountId":"64f1a2b3c4d5e6f7a8b9c0d1","chatId":"123456789"}}],"page":1,"limit":20,"total":1,"hasMore":false}}}}},"400":{"description":"Invalid botId or query.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"403":{"description":"Phone not verified, insufficient scope/permission, or selected sender key (SENDER_NOT_ALLOWED). Chats/subscribers require messages_read; session/bot discovery requires send. All require messages:create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"404":{"description":"Bot not found for this API key owner.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnifiedSendErrorResponse"}}}}},"operationId":"listTelegramSubscribers"}},"/api/messages/sas/send":{"post":{"tags":["SAS Radius"],"summary":"Send Syria SMS (SAS Radius body format)","description":"Drop-in compatibility endpoint for SAS Radius SMS configuration. Place api_token, phone={dst}, message={text}, and country_code=SY in the POST body. Optional sender_id selects an approved SMS sender; omit it to use the account default. JSON and application/x-www-form-urlencoded are accepted. X-API-Key may be used instead of api_token for Swagger testing.","security":[{"ApiKeyAuth":[]},{}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Reuse the same key and body for an identical attempt. Cached replay requires send idempotency to be enabled and available."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendRequest"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/SasRadiusSendRequest"}}}},"responses":{"200":{"description":"Message accepted/sent through Syria SMS.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendSuccessResponse"}}}},"400":{"description":"Invalid body, phone, message, country_code, or sender_id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"401":{"description":"Missing or invalid API token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"402":{"description":"Insufficient balance for this send.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"403":{"description":"SAS Radius not enabled for this account, or phone not verified / missing permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"409":{"description":"Idempotency key conflict or an identical request is still in progress.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"413":{"description":"Request body exceeds the 64 KiB limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"415":{"description":"Unsupported content type.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}},"502":{"description":"The selected SMS provider rejected or failed the send.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SasRadiusSendErrorResponse"}}}}},"operationId":"sasRadiusSend"}}},"externalDocs":{"description":"Legacy v1 compatibility and migration","url":"https://raselsms.com/api-docs/markdown/legacy-v1.md"},"webhooks":{"whatsappWebInbound":{"post":{"servers":[{"url":"https://receiver.example","description":"Your configured HTTPS receiver"}],"tags":["WhatsApp Web Inbound Webhooks"],"summary":"Inbound WhatsApp Web message callback (sent by Rasel)","description":"Rasel sends this POST to your configured HTTPS receiver. Authenticate the dedicated webhook key in Authorization: Bearer or X-API-Key. Rasel sends both headers. Record X-Rasel-Delivery-Id to ignore duplicate deliveries. Return any 2xx within 10 seconds. The body is ignored. Delivery allows up to three total attempts.","security":[{"WebhookBearer":[]},{"WebhookApiKey":[]}],"parameters":[{"name":"X-Rasel-Event","in":"header","required":true,"schema":{"type":"string","enum":["whatsapp_web.message.received","whatsapp_web.inbound.test"]}},{"name":"X-Rasel-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsAppWebInboundWebhookPayload"}}}},"responses":{"200":{"description":"Acknowledge receipt. Body is ignored."}},"operationId":"whatsappWebInboundWebhook"}}}}