> For a complete page index, fetch https://developer.close.com/llms.txt

# 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](https://developer.close.com/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](https://developer.close.com/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](https://developer.close.com/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](https://developer.close.com/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: Use your API key as the username and leave the password empty.
          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: >-
        Direction of communication. Outgoing means the communication flowing
        from the user to the lead/contact. Inbound means the opposite.
      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
      description: Use your API key as the username and leave the password empty.
    OAuth2:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python activities.whatsapp_messages_create_example
import requests

url = "https://api.close.com/api/v1/activity/whatsapp_message/"

payload = {
    "activity_at": "2016-10-03T16:06:11.167000+00:00",
    "contact_id": "cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk",
    "direction": "outgoing",
    "external_whatsapp_message_id": "1234567890",
    "lead_id": "lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb",
    "local_phone": "16503334444",
    "message_markdown": "test",
    "remote_phone": "18183004000",
    "integration_link": "https://example.com/messages/1234567890",
    "response_to_id": "acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak",
    "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<CLOSE_API_KEY>", ""))

print(response.json())
```

```javascript activities.whatsapp_messages_create_example
const url = 'https://api.close.com/api/v1/activity/whatsapp_message/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'POST',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"activity_at":"2016-10-03T16:06:11.167000+00:00","contact_id":"cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk","direction":"outgoing","external_whatsapp_message_id":"1234567890","lead_id":"lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb","local_phone":"16503334444","message_markdown":"test","remote_phone":"18183004000","integration_link":"https://example.com/messages/1234567890","response_to_id":"acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak","organization_id":"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go activities.whatsapp_messages_create_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.close.com/api/v1/activity/whatsapp_message/"

	payload := strings.NewReader("{\n  \"activity_at\": \"2016-10-03T16:06:11.167000+00:00\",\n  \"contact_id\": \"cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk\",\n  \"direction\": \"outgoing\",\n  \"external_whatsapp_message_id\": \"1234567890\",\n  \"lead_id\": \"lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb\",\n  \"local_phone\": \"16503334444\",\n  \"message_markdown\": \"test\",\n  \"remote_phone\": \"18183004000\",\n  \"integration_link\": \"https://example.com/messages/1234567890\",\n  \"response_to_id\": \"acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<CLOSE_API_KEY>", "")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby activities.whatsapp_messages_create_example
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/activity/whatsapp_message/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<CLOSE_API_KEY>", "")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"activity_at\": \"2016-10-03T16:06:11.167000+00:00\",\n  \"contact_id\": \"cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk\",\n  \"direction\": \"outgoing\",\n  \"external_whatsapp_message_id\": \"1234567890\",\n  \"lead_id\": \"lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb\",\n  \"local_phone\": \"16503334444\",\n  \"message_markdown\": \"test\",\n  \"remote_phone\": \"18183004000\",\n  \"integration_link\": \"https://example.com/messages/1234567890\",\n  \"response_to_id\": \"acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\"\n}"

response = http.request(request)
puts response.read_body
```

```java activities.whatsapp_messages_create_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.close.com/api/v1/activity/whatsapp_message/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"activity_at\": \"2016-10-03T16:06:11.167000+00:00\",\n  \"contact_id\": \"cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk\",\n  \"direction\": \"outgoing\",\n  \"external_whatsapp_message_id\": \"1234567890\",\n  \"lead_id\": \"lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb\",\n  \"local_phone\": \"16503334444\",\n  \"message_markdown\": \"test\",\n  \"remote_phone\": \"18183004000\",\n  \"integration_link\": \"https://example.com/messages/1234567890\",\n  \"response_to_id\": \"acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\"\n}")
  .asString();
```

```php activities.whatsapp_messages_create_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.close.com/api/v1/activity/whatsapp_message/', [
  'body' => '{
  "activity_at": "2016-10-03T16:06:11.167000+00:00",
  "contact_id": "cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk",
  "direction": "outgoing",
  "external_whatsapp_message_id": "1234567890",
  "lead_id": "lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb",
  "local_phone": "16503334444",
  "message_markdown": "test",
  "remote_phone": "18183004000",
  "integration_link": "https://example.com/messages/1234567890",
  "response_to_id": "acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak",
  "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

echo $response->getBody();
```

```csharp activities.whatsapp_messages_create_example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.close.com/api/v1/activity/whatsapp_message/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"activity_at\": \"2016-10-03T16:06:11.167000+00:00\",\n  \"contact_id\": \"cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk\",\n  \"direction\": \"outgoing\",\n  \"external_whatsapp_message_id\": \"1234567890\",\n  \"lead_id\": \"lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb\",\n  \"local_phone\": \"16503334444\",\n  \"message_markdown\": \"test\",\n  \"remote_phone\": \"18183004000\",\n  \"integration_link\": \"https://example.com/messages/1234567890\",\n  \"response_to_id\": \"acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```