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

# Send document message

> Provide either `id`, for a media previously uploaded through `POST /messages/upload-media`, or `link`, a public URL WhatsApp can download from.

Requires an open service window: the recipient must have messaged the business in the last 24 hours. Use `POST /messages/template` to reach recipients outside that window.



## OpenAPI

````yaml POST /messages/document
openapi: 3.1.0
info:
  title: Cogfy Messenger Public API
  version: 1.0.0
  description: API for interacting with the Cogfy Messenger platform
servers:
  - url: https://messenger-public-api.cogfy.com
    description: Production server
  - url: http://localhost:3100
    description: Local server
security:
  - ApiKeyAuth: []
paths:
  /messages/document:
    post:
      tags:
        - Messages
      summary: Send document message
      description: >-
        Provide either `id`, for a media previously uploaded through `POST
        /messages/upload-media`, or `link`, a public URL WhatsApp can download
        from.


        Requires an open service window: the recipient must have messaged the
        business in the last 24 hours. Use `POST /messages/template` to reach
        recipients outside that window.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                from:
                  type: string
                  minLength: 1
                  description: WhatsApp id of the sender phone number
                to:
                  type: string
                  minLength: 1
                  description: Recipient phone number, digits only, including country code
                document:
                  description: The document to send. Provide either `id` or `link`
                  type: object
                  properties:
                    id:
                      description: >-
                        Id of a media uploaded through `POST
                        /messages/upload-media`
                      type: string
                    link:
                      description: Public URL of the media
                      type: string
                      format: uri
                    caption:
                      description: Caption shown with the document
                      type: string
                    filename:
                      description: File name shown to the recipient
                      type: string
              required:
                - from
                - to
      responses:
        '200':
          description: Message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    description: Id of the created message
                required:
                  - id
                additionalProperties: false
        '400':
          description: >-
            Bad request — invalid input data, or the message was rejected by the
            WhatsApp Cloud API (e.g. invalid template)
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                  title:
                    type: string
                  detail:
                    type: string
                  code:
                    description: >-
                      WhatsApp Cloud API error code, present when the request
                      was rejected by Meta (e.g. invalid template, rate limit)
                    type: number
                required:
                  - status
                  - title
                  - detail
                additionalProperties: false
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                  title:
                    type: string
                  detail:
                    type: string
                  code:
                    description: >-
                      WhatsApp Cloud API error code, present when the request
                      was rejected by Meta (e.g. invalid template, rate limit)
                    type: number
                required:
                  - status
                  - title
                  - detail
                additionalProperties: false
        '404':
          description: >-
            Sender phone number not found or not linked to a WhatsApp Business
            Account
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                  title:
                    type: string
                  detail:
                    type: string
                  code:
                    description: >-
                      WhatsApp Cloud API error code, present when the request
                      was rejected by Meta (e.g. invalid template, rate limit)
                    type: number
                required:
                  - status
                  - title
                  - detail
                additionalProperties: false
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

````