> 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 ## Authentication - `Authorization` header (basic auth, required) — Use your API key as the username and leave the password empty. - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Query parameters - `send_to_inbox` (boolean, optional) ### Body (application/json) This endpoint expects a CreateWhatsAppMessage. - `activity_at` (datetime, required) - `contact_id` (string, required) - `direction` (enum, required) — Direction of communication. Outgoing means the communication flowing from the user to the lead/contact. Inbound means the opposite. - Allowed values: `incoming`, `outgoing` - `external_whatsapp_message_id` (string, required) - `lead_id` (string, required) - `local_phone` (string, required) - `message_markdown` (string, required) - `remote_phone` (string, required) - `attachments` (list of WhatsAppAttachmentData, optional) - `integration_link` (string, optional, nullable) - `response_to_id` (string, optional, nullable) - `user_id` (string, optional, nullable) ## Response ### 200 Successful response - `_type` (string, required) - `activity_at` (datetime, required, nullable) - `contact_id` (string, required, nullable) - `created_by` (string, required, nullable) - `date_created` (datetime, required) - `date_updated` (datetime, required) - `direction` (enum, required) — Direction of communication. Outgoing means the communication flowing from the user to the lead/contact. Inbound means the opposite. - Allowed values: `incoming`, `outgoing` - `external_whatsapp_message_id` (string, required) - `id` (string, required) - `integration_link` (string, required, nullable) - `integration_name` (string, required, nullable) - `lead_id` (string, required, nullable) - `local_phone` (string, required) - `local_phone_formatted` (string, required) - `message_html` (string, required) - `message_markdown` (string, required) - `organization_id` (string, required) - `remote_phone` (string, required) - `remote_phone_formatted` (string, required) - `response_to_id` (string, required, nullable) - `source` (enum, required) - Allowed values: `ui`, `api`, `import`, `clipper`, `email`, `suggestion`, `segment-integration`, `customerio-integration`, `calendly-integration`, `ai`, `whatsapp`, `webform` - `text` (string, required) - `updated_by` (string, required, nullable) - `user_id` (string, required, nullable) - `users` (list of string, required) - `attachments` (list of Attachment, optional) - `created_by_name` (string, optional, nullable) - `sequence_id` (string, optional, nullable) - `sequence_name` (string, optional, nullable) - `sequence_subscription_id` (string, optional, nullable) - `updated_by_name` (string, optional, nullable) - `user_name` (string, optional, nullable) ## Errors ### 400 Bad Request Error Bad request - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Not found - `any` ## Types ### WhatsAppAttachmentData - `content_type` (string, required) - `filename` (string, required) - `url` (string, required) ### Attachment - `content_type` (string, required, nullable) - `filename` (string, required, nullable) - `size` (integer, required, nullable) - `url` (string, required) - `thumbnail_url` (string, optional, nullable) ## Examples **Request** ```json { "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" } ``` **Response** ```json { "_type": "WhatsAppMessage", "activity_at": "2016-10-03T16:06:11.167000+00:00", "contact_id": "cont_q4xYmlGhA3060dEl0NDJuHRxPMuVjqLn30AFSzh1fRk", "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date_created": "2016-10-03T16:06:11.167000+00:00", "date_updated": "2016-10-03T16:06:11.167000+00:00", "direction": "outgoing", "external_whatsapp_message_id": "1234567890", "id": "acti_12358hIUhaklslYoYSbtozZuUTyB2zO2nhm7iVSpZpp", "integration_link": "https://example.com/messages/1234567890", "integration_name": "API", "lead_id": "lead_iuSXNk1x3446ggPVwQS7ynmp8pGRIDieRYiCnuo4yFb", "local_phone": "+16503334444", "local_phone_formatted": "+1 650-333-444", "message_html": "

test

", "message_markdown": "test", "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "remote_phone": "+18183004000", "remote_phone_formatted": "+1 818-300-4000", "response_to_id": "acti_asjiweURMfsLgKuYGqbQ4Qp7L5a16pQOcDfTgotqDak", "source": "api", "text": "test", "updated_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "users": [], "attachments": [], "created_by_name": "Tobias Fuenke", "updated_by_name": "Tobias Fuenke", "user_name": "Tobias Fuenke" } ``` **SDK Code** ```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" } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript activities.whatsapp_messages_create_example const url = 'https://api.close.com/api/v1/activity/whatsapp_message/'; const credentials = btoa(":"); 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"}' }; 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}") req, _ := http.NewRequest("POST", url, payload) req.SetBasicAuth("", "") 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("", "") 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}" 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 response = Unirest.post("https://api.close.com/api/v1/activity/whatsapp_message/") .basicAuth("", "") .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}") .asString(); ``` ```php activities.whatsapp_messages_create_example 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" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); 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("", ""); 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}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```