# Create a WhatsAppMessage activity

POST https://api.close.com/api/v1/activity/whatsapp_message/
Content-Type: application/json

`external_whatsapp_message_id` must be the ID of the message inside WhatsApp. You can filter by this field to find messages in Close to update or delete based on updates or deletions in WhatsApp.

`message_markdown` must be the body of the message in the WhatsApp Markdown format. The `message_html` read-only field will return the HTML representation of this message.

To include an attachment, you must first upload the file to Close using the [Files API](/resources/files/). Then, add an object to the `attachments` array with the following fields: `url`, `filename`, and `content_type`. The `url` should be the URL provided in the `download.url` field of the response from the [Files API](/resources/files/). It must begin with `https://app.close.com/go/file/`.

`integration_link` (optional) is a URL string that can be provided by the integration partner creating the WhatsApp message. This can be used to link back to the message in the external system.

`response_to_id` (optional) is the Close activity ID of another WhatsApp message activity (not the WhatsApp native message ID) that this message is replying to. This field creates a thread relationship between messages, allowing you to track conversation flow and message replies within WhatsApp threads. The ID must be a valid WhatsApp message activity ID in Close (e.g., `acti_...`).

Only WhatsApp Markdown messages and file attachments are supported. No support is provided for Polls, Events, Locations, etc.

**Important**: The total size of all attachments for a single WhatsApp message activity cannot exceed 25MB.

When creating a new WhatsApp message with the direction set to `incoming`, you can pass the query parameter `send_to_inbox` with the value of `true` to create a corresponding Inbox Notification for the message.

Reference: https://developer.close.com/api/resources/activities/whatsapp/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /activity/whatsapp_message/:
    post:
      operationId: create
      summary: Create a WhatsAppMessage activity
      description: >-
        `external_whatsapp_message_id` must be the ID of the message inside
        WhatsApp. You can filter by this field to find messages in Close to
        update or delete based on updates or deletions in WhatsApp.


        `message_markdown` must be the body of the message in the WhatsApp
        Markdown format. The `message_html` read-only field will return the HTML
        representation of this message.


        To include an attachment, you must first upload the file to Close using
        the [Files API](/resources/files/). Then, add an object to the
        `attachments` array with the following fields: `url`, `filename`, and
        `content_type`. The `url` should be the URL provided in the
        `download.url` field of the response from the [Files
        API](/resources/files/). It must begin with
        `https://app.close.com/go/file/`.


        `integration_link` (optional) is a URL string that can be provided by
        the integration partner creating the WhatsApp message. This can be used
        to link back to the message in the external system.


        `response_to_id` (optional) is the Close activity ID of another WhatsApp
        message activity (not the WhatsApp native message ID) that this message
        is replying to. This field creates a thread relationship between
        messages, allowing you to track conversation flow and message replies
        within WhatsApp threads. The ID must be a valid WhatsApp message
        activity ID in Close (e.g., `acti_...`).


        Only WhatsApp Markdown messages and file attachments are supported. No
        support is provided for Polls, Events, Locations, etc.


        **Important**: The total size of all attachments for a single WhatsApp
        message activity cannot exceed 25MB.


        When creating a new WhatsApp message with the direction set to
        `incoming`, you can pass the query parameter `send_to_inbox` with the
        value of `true` to create a corresponding Inbox Notification for the
        message.
      tags:
        - subpackage_activitiesWhatsappMessages
      parameters:
        - name: send_to_inbox
          in: query
          required: false
          schema:
            type: boolean
        - name: Authorization
          in: header
          description: Basic authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppMessageActivity'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: Not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWhatsAppMessage'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    WhatsAppAttachmentData:
      type: object
      properties:
        content_type:
          type: string
        filename:
          type: string
        url:
          type: string
      required:
        - content_type
        - filename
        - url
      title: WhatsAppAttachmentData
    CommunicationDirection:
      type: string
      enum:
        - incoming
        - outgoing
      description: >-
        This is the former EmailDirection.

        Any activity that has a concept of direction (in or out) should be using

        this enum.

        For historical reasons, this is different from PhoneActivityDirection

        but at some point PhoneActivityDirection should be deprecated and
        replaced

        with CommunicationDirection.
      title: CommunicationDirection
    CreateWhatsAppMessage:
      type: object
      properties:
        activity_at:
          type: string
          format: date-time
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/WhatsAppAttachmentData'
        contact_id:
          type: string
        direction:
          $ref: '#/components/schemas/CommunicationDirection'
        external_whatsapp_message_id:
          type: string
        integration_link:
          type:
            - string
            - 'null'
          format: uri
        lead_id:
          type: string
        local_phone:
          type: string
        message_markdown:
          type: string
        remote_phone:
          type: string
        response_to_id:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
      required:
        - activity_at
        - contact_id
        - direction
        - external_whatsapp_message_id
        - lead_id
        - local_phone
        - message_markdown
        - remote_phone
      title: CreateWhatsAppMessage
    Attachment:
      type: object
      properties:
        content_type:
          type:
            - string
            - 'null'
        filename:
          type:
            - string
            - 'null'
        size:
          type:
            - integer
            - 'null'
        thumbnail_url:
          type:
            - string
            - 'null'
        url:
          type: string
      required:
        - content_type
        - filename
        - size
        - url
      title: Attachment
    CreationSource:
      type: string
      enum:
        - ui
        - api
        - import
        - clipper
        - email
        - suggestion
        - segment-integration
        - customerio-integration
        - calendly-integration
        - ai
        - whatsapp
        - webform
      title: CreationSource
    WhatsAppMessageActivity:
      type: object
      properties:
        _type:
          type: string
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
        contact_id:
          type:
            - string
            - 'null'
        created_by:
          type:
            - string
            - 'null'
        created_by_name:
          type:
            - string
            - 'null'
        date_created:
          type: string
          format: date-time
        date_updated:
          type: string
          format: date-time
        direction:
          $ref: '#/components/schemas/CommunicationDirection'
        external_whatsapp_message_id:
          type: string
        id:
          type: string
        integration_link:
          type:
            - string
            - 'null'
        integration_name:
          type:
            - string
            - 'null'
        lead_id:
          type:
            - string
            - 'null'
        local_phone:
          type: string
        local_phone_formatted:
          type: string
        message_html:
          type: string
        message_markdown:
          type: string
        organization_id:
          type: string
        remote_phone:
          type: string
        remote_phone_formatted:
          type: string
        response_to_id:
          type:
            - string
            - 'null'
        sequence_id:
          type:
            - string
            - 'null'
        sequence_name:
          type:
            - string
            - 'null'
        sequence_subscription_id:
          type:
            - string
            - 'null'
        source:
          $ref: '#/components/schemas/CreationSource'
        text:
          type: string
        updated_by:
          type:
            - string
            - 'null'
        updated_by_name:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
        user_name:
          type:
            - string
            - 'null'
        users:
          type: array
          items:
            type: string
      required:
        - _type
        - activity_at
        - contact_id
        - created_by
        - date_created
        - date_updated
        - direction
        - external_whatsapp_message_id
        - id
        - integration_link
        - integration_name
        - lead_id
        - local_phone
        - local_phone_formatted
        - message_html
        - message_markdown
        - organization_id
        - remote_phone
        - remote_phone_formatted
        - response_to_id
        - source
        - text
        - updated_by
        - user_id
        - users
      title: WhatsAppMessageActivity
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: basic
    OAuth2:
      type: http
      scheme: bearer

```