> ## Documentation Index
> Fetch the complete documentation index at: https://docs.routa.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Send message

> Sends a text or template message through a channel.

The response is `202 Accepted`: the message is durably stored, but **not delivered yet**. Follow `sent`, `delivered`, `read` and `failed` through [webhooks](/en/webhooks/overview) or `GET /v1/messages/{id}`.

Provide `text` or `template`. With neither, the API returns `content_rejected`. With both, it sends the template and ignores `text`. Send the `Idempotency-Key` header to retry the request safely. See [Idempotency](/en/reliability/idempotency).

A template send carries exactly what the template asks for: one value in `body_parameters` for each body variable, `header_parameter` when the header is text with a variable or is media, and one item in `button_parameters` for each URL button with a variable. A missing, extra, mismatched or empty parameter returns `422 content_rejected`, and so does a value that WhatsApp refuses. See [Header and buttons](/en/guides/send-template-message#header-and-buttons).

The channel, the recipient, the template and the header file are validated when the message is accepted, so the error comes back right away. A refused request stores no message and uses none of your allowance. An imported, read-only template returns `template_not_sendable`.



## OpenAPI

````yaml en/openapi.json POST /v1/messages
openapi: 3.0.3
info:
  title: Routa API
  description: >-
    REST API to send and receive WhatsApp messages, track delivery and receive
    normalized events through webhooks.
  version: '1'
servers:
  - url: https://api.routa.chat
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Send, retrieve and list messages.
  - name: Events
    description: Query the log of normalized events.
  - name: Webhooks
    description: Manage webhook endpoints, secrets and deliveries.
  - name: Templates
    description: Create and retrieve WhatsApp templates.
  - name: Media
    description: Upload and download media files.
  - name: Usage
    description: Query the metered usage of the project.
  - name: Identity
    description: Identify the API key in use.
  - name: Partners
    description: >-
      Create one project per customer, issue the key of each project, follow the
      channels and receive the events of every customer on a single webhook.
      These routes use a partner key (`rt_partner_...`). See [Partner
      API](/en/partners/overview).
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: Send message
      description: >-
        Sends a text or template message through a channel.


        The response is `202 Accepted`: the message is durably stored, but **not
        delivered yet**. Follow `sent`, `delivered`, `read` and `failed` through
        [webhooks](/en/webhooks/overview) or `GET /v1/messages/{id}`.


        Provide `text` or `template`. With neither, the API returns
        `content_rejected`. With both, it sends the template and ignores `text`.
        Send the `Idempotency-Key` header to retry the request safely. See
        [Idempotency](/en/reliability/idempotency).


        A template send carries exactly what the template asks for: one value in
        `body_parameters` for each body variable, `header_parameter` when the
        header is text with a variable or is media, and one item in
        `button_parameters` for each URL button with a variable. A missing,
        extra, mismatched or empty parameter returns `422 content_rejected`, and
        so does a value that WhatsApp refuses. See [Header and
        buttons](/en/guides/send-template-message#header-and-buttons).


        The channel, the recipient, the template and the header file are
        validated when the message is accepted, so the error comes back right
        away. A refused request stores no message and uses none of your
        allowance. An imported, read-only template returns
        `template_not_sendable`.
      operationId: sendMessage
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            A unique key per logical message (a UUID v4, for example). Repeating
            the request with the same key and the same body returns the original
            response, with the `Idempotent-Replay: true` header. A key reused
            with a different body returns `409 idempotency_key_reuse`. The
            record is kept for 24 hours.
          schema:
            type: string
          example: 6f0a9d9e-3c1f-4e56-9a64-2b7f6a5c1d10
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - channel
                - to
              properties:
                channel:
                  description: ID of the channel to send through (`chan_...`).
                  type: string
                  example: chan_01J8ZK9M3Q7XABCDEFGHJKMNPQ
                to:
                  pattern: ^\+?[1-9]\d{1,14}$
                  description: >-
                    Recipient in E.164 format, for example `+5581999999999`. The
                    leading `+` is optional. A value outside this format returns
                    `request_invalid`; a number that cannot exist in its country
                    returns `invalid_recipient`.
                  type: string
                  example: '+5581999999999'
                text:
                  description: >-
                    Body of the text message, up to 4096 characters. It is
                    ignored when the request also carries `template`.
                  type: string
                  example: Hi! Your order is confirmed.
                template:
                  type: object
                  required:
                    - id
                  properties:
                    id:
                      description: >-
                        Template ID (`tmpl_...`). The template must be
                        `approved`.
                      type: string
                      example: tmpl_01J8ZK9M3Q7XABCDEFGHJKMNPQ
                    body_parameters:
                      description: >-
                        Positional values for the `{{1}}`, `{{2}}`, …
                        placeholders of the template body, in order. The count
                        must match the number of variables in the template. A
                        value cannot hold a line break, a tab or 5 spaces in a
                        row.
                      type: array
                      items:
                        type: string
                    header_parameter:
                      description: >-
                        The value of the template header. Send `text` when the
                        text header has a variable, or `media_id` when the
                        header is media, on **every** send. Omit it when the
                        header asks for nothing: there is no header, or its text
                        is fixed.
                      type: object
                      properties:
                        text:
                          description: >-
                            The value of the header variable. Text headers only.
                            It cannot hold a line break, a tab or 5 spaces in a
                            row.
                          type: string
                        media_id:
                          description: >-
                            The file of the media header: the `id` (`med_...`)
                            returned by `POST /v1/media`, of a type the header
                            format accepts (`image`: JPEG or PNG; `video`: MP4;
                            `document`: PDF). A file received from a contact is
                            refused. Media headers only.
                          type: string
                        filename:
                          description: >-
                            The file name the recipient sees. Optional, and for
                            document headers only.
                          type: string
                    button_parameters:
                      description: >-
                        One item for each URL button whose URL has a variable.
                        Other buttons take no item.
                      type: array
                      items:
                        type: object
                        required:
                          - index
                          - text
                        properties:
                          index:
                            description: >-
                              The position of the button in
                              `components.buttons`, as returned by `GET
                              /v1/templates/{id}`, starting at 0. Every button
                              counts, of any kind.
                            type: integer
                            example: 0
                          text:
                            description: >-
                              The value that replaces `{{1}}` in the button URL.
                              Routa passes it on exactly as it arrives, so
                              percent-encode it first: spaces, line breaks,
                              accented letters, emoji and any other character
                              outside visible ASCII are refused.
                            type: string
                            example: '1234'
                  description: Approved template to send, instead of `text`.
                metadata:
                  maxProperties: 20
                  description: >-
                    Up to 20 text key-value pairs that you own, 1 KB in total.
                    Returned when you retrieve the message and in its events.
                  type: object
                  additionalProperties:
                    type: string
            example:
              channel: chan_01J8ZK9M3Q7XABCDEFGHJKMNPQ
              to: '+5581999999999'
              text: Hi! Your order is confirmed.
              metadata:
                order_id: '1234'
      responses:
        '202':
          description: Accepted. Processing is asynchronous
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        '401':
          description: >-
            The API key is missing, invalid, revoked or expired
            (`api_key_invalid`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: >-
            Plan allowance or limit used up (`message_quota_exceeded`,
            `free_messages_exhausted`, `subscription_required`,
            `payment_failed`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The key lacks the required scope (`insufficient_scope`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            The resource does not exist or belongs to another project
            (`channel_not_found`, `template_not_found`, `media_not_found`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Idempotency or state conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            Invalid request (`request_invalid`, `channel_inactive`,
            `capability_unsupported`, `invalid_recipient`, `content_rejected`,
            `template_not_approved`, `template_paused`, `template_not_sendable`,
            `media_not_ready`, `media_content_type_rejected`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded. See the `Retry-After` header
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth:
            - messages:write
components:
  schemas:
    Message:
      type: object
      properties:
        id:
          type: string
          description: Message ID.
          example: msg_01J8ZK9M3Q7XABCDEFGHJKMNPQ
        channel:
          type: string
          description: ID of the channel used.
          example: chan_01J8ZK9M3Q7XABCDEFGHJKMNPQ
        direction:
          type: string
          enum:
            - outbound
            - inbound
          description: >-
            Message direction: `outbound` (left the channel's number, through
            the API or the WhatsApp Business app) or `inbound` (received).
        origin:
          type: string
          enum:
            - api
            - business_app
          nullable: true
          description: >-
            Where an `outbound` message came from: `api` (sent through Routa) or
            `business_app` (the business sent it from the WhatsApp Business app,
            on a number connected in coexistence mode). A `business_app` message
            is not billed and does not count as usage. It is `null` on an
            `inbound` message.
          example: api
        from:
          type: string
          description: Sender address, in E.164.
          example: '+5581988888888'
        to:
          type: string
          description: >-
            Recipient address, in E.164. On a `business_app` message, it can be
            a provider identifier when the recipient's number is unknown.
          example: '+5581999999999'
        content:
          oneOf:
            - type: object
              required:
                - type
                - body
              properties:
                type:
                  type: string
                  enum:
                    - text
                  description: Always `text` on a text message.
                body:
                  type: string
                  description: Body of the text.
            - type: object
              required:
                - type
                - media_id
              properties:
                type:
                  type: string
                  enum:
                    - image
                  description: Always `image` on an image.
                media_id:
                  type: string
                  description: >-
                    ID (`med_...`) of the file stored by Routa. Call `GET
                    /v1/media/{id}` to get a signed URL.
                caption:
                  type: string
                  description: Caption. Absent when there is none.
            - type: object
              required:
                - type
                - media_id
              properties:
                type:
                  type: string
                  enum:
                    - document
                  description: Always `document` on a document.
                media_id:
                  type: string
                  description: >-
                    ID (`med_...`) of the file stored by Routa. Call `GET
                    /v1/media/{id}` to get a signed URL.
                filename:
                  type: string
                  description: File name. Absent when there is none.
                caption:
                  type: string
                  description: Caption. Absent when there is none.
            - type: object
              required:
                - type
                - media_id
              properties:
                type:
                  type: string
                  enum:
                    - audio
                  description: Always `audio` on an audio message.
                media_id:
                  type: string
                  description: >-
                    ID (`med_...`) of the file stored by Routa. Call `GET
                    /v1/media/{id}` to get a signed URL.
            - type: object
              required:
                - type
                - media_id
              properties:
                type:
                  type: string
                  enum:
                    - video
                  description: Always `video` on a video.
                media_id:
                  type: string
                  description: >-
                    ID (`med_...`) of the file stored by Routa. Call `GET
                    /v1/media/{id}` to get a signed URL.
                caption:
                  type: string
                  description: Caption. Absent when there is none.
            - type: object
              required:
                - type
                - media_id
              properties:
                type:
                  type: string
                  enum:
                    - sticker
                  description: Always `sticker` on a sticker.
                media_id:
                  type: string
                  description: >-
                    ID (`med_...`) of the file stored by Routa. Call `GET
                    /v1/media/{id}` to get a signed URL.
            - type: object
              required:
                - type
                - latitude
                - longitude
              properties:
                type:
                  type: string
                  enum:
                    - location
                  description: Always `location` on a location.
                latitude:
                  type: number
                  description: Latitude of the place.
                longitude:
                  type: number
                  description: Longitude of the place.
                name:
                  type: string
                  description: Name of the place. Absent when there is none.
                address:
                  type: string
                  description: Address of the place. Absent when there is none.
            - type: object
              required:
                - type
                - target_message_id
                - emoji
              properties:
                type:
                  type: string
                  enum:
                    - reaction
                  description: Always `reaction` on a reaction.
                target_message_id:
                  type: string
                  description: ID (`msg_...`) of the message that was reacted to.
                emoji:
                  type: string
                  description: >-
                    The reaction emoji. An empty string means an earlier
                    reaction was removed.
            - type: object
              required:
                - type
                - template_id
                - body_parameters
              properties:
                type:
                  type: string
                  enum:
                    - template
                  description: Always `template` on a template send.
                template_id:
                  type: string
                  description: ID (`tmpl_...`) of the template sent.
                body_parameters:
                  type: array
                  items:
                    type: string
                  description: The values of the `{{n}}` variables of the body, in order.
                header_parameter:
                  oneOf:
                    - type: object
                      required:
                        - text
                      properties:
                        text:
                          type: string
                          description: The value of the variable in the text header.
                    - type: object
                      required:
                        - media_id
                      properties:
                        media_id:
                          type: string
                          description: ID (`med_...`) of the file sent in the media header.
                        filename:
                          type: string
                          description: >-
                            File name of a document header. Absent when none was
                            given.
                  description: >-
                    What was sent to the template header: `text`, the value of
                    its variable, or `media_id` (with `filename`, on a
                    document). Absent when the header asks for nothing.
                button_parameters:
                  type: array
                  items:
                    type: object
                    required:
                      - index
                      - text
                    properties:
                      index:
                        type: integer
                        description: >-
                          The position of the button in `components.buttons`,
                          starting at 0.
                      text:
                        type: string
                        description: The value that replaced `{{1}}` in the button URL.
                  description: >-
                    The values sent to the URL buttons with a variable, as
                    received. `index` is the position of the button in
                    `components.buttons`, starting at 0. Absent when the
                    template asks for none.
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - unsupported
                  description: >-
                    Always `unsupported`: received content that Routa does not
                    represent yet.
          nullable: true
          description: >-
            Message content. The `type` field gives the format. It is `null`
            once retention removes the content; `content_redacted_at` then gives
            the time of the removal.
        content_redacted_at:
          format: date-time
          type: string
          nullable: true
          description: >-
            When retention removed the message content. `null` while the message
            still has it.
          example: null
        status:
          type: string
          enum:
            - accepted
            - sent
            - delivered
            - read
            - failed
          description: Current state in the lifecycle. The status never goes back.
        failure_code:
          type: string
          nullable: true
          description: >-
            Reason for the failure, from a closed set of Routa codes, never a
            provider code. `null` until the message fails.
          example: null
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Up to 20 text key-value pairs that you own.
        accepted_at:
          format: date-time
          type: string
          description: When Routa accepted the message.
          example: '2026-09-04T13:22:41.031Z'
        sent_at:
          format: date-time
          type: string
          nullable: true
          description: >-
            When the provider accepted the message. `null` if it has not
            happened yet.
          example: '2026-09-04T13:22:41.031Z'
        delivered_at:
          format: date-time
          type: string
          nullable: true
          description: When delivery was confirmed. `null` if it has not happened yet.
          example: '2026-09-04T13:22:41.031Z'
        read_at:
          format: date-time
          type: string
          nullable: true
          description: When the recipient read it. `null` if it has not happened yet.
          example: null
        failed_at:
          format: date-time
          type: string
          nullable: true
          description: When the message failed. `null` if it did not fail.
          example: null
      required:
        - id
        - channel
        - direction
        - origin
        - from
        - to
        - content
        - content_redacted_at
        - status
        - failure_code
        - metadata
        - accepted_at
        - sent_at
        - delivered_at
        - read_at
        - failed_at
    Error:
      type: object
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
            - request_id
          properties:
            type:
              type: string
              description: >-
                Error category: `invalid_request_error`, `authentication_error`,
                `permission_error`, `not_found_error`, `conflict_error`,
                `rate_limit_error`, `billing_error` or `api_error`.
              example: invalid_request_error
            code:
              type: string
              description: >-
                Stable, machine-readable code. See [Error
                codes](/en/errors/error-codes).
              example: channel_inactive
            message:
              type: string
              description: >-
                Human-readable text, in English. It can change, so do not parse
                it.
              example: Channel chan_01J8... is not active and cannot send messages.
            param:
              type: string
              description: >-
                The request field at fault, when it applies. It is filled in on
                `request_invalid` (the field outside the schema, such as
                `template.button_parameters.0.index`) and on template errors:
                `name` in `template_name_invalid`; `body_text`,
                `components.header`, `components.footer` or `components.buttons`
                in `template_components_invalid`; and `variable_examples`,
                `variable_examples.<position>`, `components.header.example` or
                `components.buttons.<position>.example` when
                `template_variables_invalid` refuses an example.
              example: components.buttons.0.example
            doc_url:
              type: string
              description: Link to the documentation of the code, when available.
            details:
              type: object
              additionalProperties:
                oneOf:
                  - type: string
                  - type: number
              description: >-
                Actionable values, such as `limit`, `used` and `resets_at` in
                `message_quota_exceeded`, or `reason`, which tells apart the
                causes behind one code, in errors such as `invalid_recipient`
                and `template_variables_invalid`. See [Actionable
                details](/en/errors/overview#actionable-details).
            request_id:
              type: string
              description: Request ID. Quote it when you contact support.
              example: req_01J8ZK9M3Q7XABCDEFGHJKMNPQ
          description: Error details.
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Project API key, in the format `rt_live_...` or `rt_test_...`, sent as
        `Authorization: Bearer <key>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.