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

# Send a message

> Send a first-contact message with `to`, or reply in an existing thread with `conversation_id`. The backend resolves sender/recipient context and finds or reuses the conversation. Use a template for first contact; text/media/interactive require an open 24h window.



## OpenAPI

````yaml /openapi.json post /v1/whatsapp/messages
openapi: 3.1.0
info:
  title: Briq API
  description: Karibu Briq API Documentation
  version: '0.8'
servers:
  - url: https://karibu.briq.tz
    description: Production
  - url: https://pre-release.karibu.briq.tz
    description: Pre-release
  - url: http://karibu.briq.tz
    description: LocalPass
security: []
paths:
  /v1/whatsapp/messages:
    post:
      tags:
        - Karibu-Whatsapp-Messages
      summary: Send a message
      description: >-
        Send a first-contact message with `to`, or reply in an existing thread
        with `conversation_id`. The backend resolves sender/recipient context
        and finds or reuses the conversation. Use a template for first contact;
        text/media/interactive require an open 24h window.
      operationId: wa_send_message
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WaMessageSendRequest'
            examples:
              template:
                summary: Template (first contact)
                value:
                  to: '255712345678'
                  type: template
                  template_name: welcome
                  variables:
                    '1': Asha
              text:
                summary: Text (window open)
                value:
                  to: '255712345678'
                  type: text
                  body: Hello!
      responses:
        '200':
          description: Sent immediately (provider acknowledged).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/WaSendData'
                  errors:
                    type: array
                    nullable: true
                    items:
                      $ref: '#/components/schemas/WaApiError'
                  request_id:
                    type: string
        '202':
          description: Queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/WaSendData'
                  errors:
                    type: array
                    nullable: true
                    items:
                      $ref: '#/components/schemas/WaApiError'
                  request_id:
                    type: string
        '400':
          description: No active sender or template parameter count mismatch.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WaErrorEnvelope'
        '403':
          description: API key is not linked to a workspace (WORKSPACE_REQUIRED).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WaErrorEnvelope'
        '404':
          description: Template or sender not found in this workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WaErrorEnvelope'
        '422':
          description: >-
            Validation error, closed 24h window, recipient unreachable, or a
            provider failure (PROVIDER_UNAVAILABLE / WHATSAPP_REAUTH_REQUIRED /
            SEND_FAILED). On provider failures, data.message_id is present and
            pollable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WaErrorEnvelope'
components:
  schemas:
    WaMessageSendRequest:
      allOf:
        - $ref: '#/components/schemas/WaConversationSendRequest'
        - type: object
          required: []
          properties:
            to:
              type: string
              minLength: 7
              maxLength: 20
              pattern: ^\+?[1-9]\d{6,17}$
              description: >-
                Destination phone in E.164 digits (optional leading +), e.g.
                255712000000. Required for first contact; omit when replying
                with conversation_id.
            sender_id:
              type: string
              format: uuid
              nullable: true
              description: >-
                Optional. Ignored when conversation_id is set; otherwise the
                backend resolves a sender when omitted.
            conversation_id:
              type: string
              format: uuid
              nullable: true
              description: >-
                Reply target. When set, recipient and sender come from the
                thread and `to` / `sender_id` are ignored.
    WaSendData:
      type: object
      properties:
        message_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            Internal message id. Use it with GET
            /v1/whatsapp/messages/{message_id}.
        conversation_id:
          type: string
          format: uuid
          nullable: true
        sender_id:
          type: string
          format: uuid
          nullable: true
        provider_message_id:
          type: string
          nullable: true
          description: WhatsApp wamid once the message is sent; null while queued.
        status:
          type: string
          example: pending
          enum:
            - pending
            - sent
            - failed
    WaApiError:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        field:
          type: string
          nullable: true
    WaErrorEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: false
        data:
          type: object
          nullable: true
          description: >-
            On a failed send that still produced a record, carries the pollable
            message_id with status='failed'; otherwise null.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/WaApiError'
        request_id:
          type: string
    WaConversationSendRequest:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - template
            - media
            - interactive
          description: Message kind. Determines which other fields are required.
        body:
          type: string
          maxLength: 4096
          description: Required when type=text.
        template_name:
          type: string
          maxLength: 512
          description: Required when type=template.
        variables:
          type: object
          additionalProperties:
            type: string
          description: Template variable values keyed by parameter name.
        media_kind:
          type: string
          enum:
            - IMAGE
            - DOCUMENT
            - VIDEO
          description: Required when type=media.
        media_url:
          type: string
          description: Publicly reachable URL. Required when type=media.
        caption:
          type: string
          maxLength: 1024
        filename:
          type: string
          maxLength: 255
        interactive:
          type: object
          additionalProperties: true
          description: Required when type=interactive.

````