# WhatsApp Official template

Choose an eligible official number and an approved template. Match its language and variable order.

Required. Send the account API key in the X-API-Key header. Never expose the key in a public browser or git repository.

1. Choose the number customers will see. GET /api/v2/official-senders?approvedOnly=true lists eligible senders for this key. Use the ID of your enabled business number or platform if Rasel’s number is available.

2. Create the template using POST /api/v2/templates with the selected officialSenderId, name, language, message body and sample variables. For media, follow the upload fields in the create reference.

3. Use GET /api/v2/templates with officialSenderId and limit to find an existing template, or GET /api/v2/templates/platform for Rasel’s number. Check GET /api/v2/templates/{id} for its status. Wait for approval if pending and address the reason if rejected.

4. Once approved, POST /api/v2/messages/send with channel=official_whatsapp, the same officialSenderId and the recipient in to. Supply template.id or template.key and fill variablesIndexed in placeholder order. Include the approved button or header fields when the template requires them.

## Request preview

```bash
curl --request POST 'https://raselsms.com/api/v2/messages/send' \
  -H "X-API-Key: $RASEL_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'RASEL_JSON'
{
  "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"
  },
  "officialSenderId": "platform"
}
RASEL_JSON
```

## HTTP 200

```json
{
  "success": true,
  "requestId": "msgreq_1739012345678_abc123",
  "status": "sent",
  "resolved": {
    "channel": "official_whatsapp",
    "provider": "meta",
    "senderSource": "official_default"
  },
  "billing": {
    "estimatedCost": 0.02,
    "currency": "USD"
  },
  "tracking": {
    "messageId": "6800msg123def4567890aaaa",
    "usageId": "6800use123def4567890bbbb",
    "queueId": null
  }
}
```

Test locally with a mock response first. Confirm the recipient and cost before sending a live request.

- [GET /api/v2/official-senders](https://raselsms.com/api-docs/markdown/official-senders/list.md)

- [POST /api/v2/templates](https://raselsms.com/api-docs/markdown/templates/create.md)

- [GET /api/v2/templates](https://raselsms.com/api-docs/markdown/templates/list.md)

- [GET /api/v2/templates/platform](https://raselsms.com/api-docs/markdown/templates/platform.md)

- [GET /api/v2/templates/{id}](https://raselsms.com/api-docs/markdown/templates/get.md)

## HTTP 502

Partial failure does not undo an accepted section or its charge. The same key replays the cached response; resume failed sections from message history. A new key creates a new message and may duplicate accepted sections. Uncertain acceptance is never blindly retried.

```json
{
  "success": false,
  "requestId": "msgreq_example",
  "code": "SMS_PARTIAL_DELIVERY",
  "error": "إرسال الرسالة الطويلة: قُبل 1 من 3 أقسام. يمكن إعادة محاولة الأقسام الفاشلة فقط.",
  "details": {
    "smsMultipart": {
      "id": "sms_batch_example",
      "status": "partial",
      "totalParts": 3,
      "sentParts": 1,
      "parts": [
        {
          "index": 1,
          "state": "sent",
          "messageDocId": "680000000000000000000001"
        },
        {
          "index": 2,
          "state": "failed",
          "messageDocId": "680000000000000000000002"
        },
        {
          "index": 3,
          "state": "pending"
        }
      ]
    }
  },
  "billing": {
    "estimatedCost": 0.06,
    "currency": "USD"
  },
  "tracking": {
    "messageDocId": "680000000000000000000002",
    "messageId": null,
    "usageId": null,
    "queueId": null
  }
}
```

[API reference](https://raselsms.com/api-docs/markdown/messaging/send.md)

[OpenAPI](https://raselsms.com/api-docs/openapi.json)
