# API Documentation

## :speech\_balloon: Introduction

​Desk360 API is a Representational State Transfer ([REST](https://en.wikipedia.org/wiki/Representational_state_transfer)) ​​structure that provides operations such as:\
\
:black\_medium\_small\_square:Reading\
:black\_medium\_small\_square:Modifying\
:black\_medium\_small\_square:Adding data\
:black\_medium\_small\_square:Deleting data\
\
from your help desk.

{% hint style="success" %}
Desk360 APIs also support Cross-Origin Resource Sharing ([CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)).
{% endhint %}

### :sparkles: HTTP Methods

> **The list of API commands used by Desk360**

| **Command** | **Description**            |
| ----------- | -------------------------- |
| **GET**     | Fetches object(s)          |
| **POST**    | Creates an object          |
| **PUT**     | Updates/Modifies an object |
| **DELETE**  | Deletes an object          |

{% hint style="info" %}
All API requests must reach the secure endpoint i.e. **HTTPS** only
{% endhint %}

### :dash: **Rate Limit** <a href="#rate-limit" id="rate-limit"></a>

This rate limit applies are based on IP address.

| **Plan**     | **Rate Limit/Minute** |
| ------------ | --------------------- |
| **Business** | 60                    |

{% hint style="success" %}

* Make sure to apply the rate limit-best practices and it stays within the rate limit.
* Make sure to make API calls in a safe layer such as your backend, **not** **front-end or your mobile application**.
* Remind that even invalid requests are included in the rate limit.
  {% endhint %}

Check your current rate limit status by looking at the following HTTP headers returned in response to each API request:

```http
HTTP/1.1 200 OK
Content-Type: application/json
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
```

| **Title**                 | **Description**                                                                                                                                            |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **X-RateLimit-Limit**     | Total number of API calls allowed per minute.                                                                                                              |
| **X-RateLimit-Remaining** | The number of requests remaining in the current rate limit window.                                                                                         |
| **X-RateLimit-Reset**     | The reset time in Unix epoch time format.                                                                                                                  |
| **Retry-After**           | <p>The number of seconds you should wait in order to trigger your next API request.</p><p>This header is returned only when the rate limit is reached.</p> |

{% hint style="info" %}
If your API request is received after the rate limit is reached, Desk360 will return an error in the response. The **Retry-After** value in the response header will tell you how long to wait before sending another API request.
{% endhint %}

```http
HTTP/1.1 200 OK
Content-Type: application/json
Retry-After: 26
```

## :rocket: Getting Started

### :lock: Authentication <a href="#authentication" id="authentication"></a>

> **Who can access my helpdesk? Can anyone see my data?**

Before prioritizing responding to a customer or using any of the APIs listed above, you must **authenticate** or **log in** as you sign in to your helpdesk web portal.

You need to create an API Key for your WABA account using the "Create API Key" button on the Public API page where you entered your webhook URL information. You must use the API Key you generate as the Bearer token required for authorization in Desk360 API requests.

All Desk360 API endpoints need this API Key as Bearer token in order to respond to your request.

You can see an example of the API Key below.

```
06RS4pzxsPquYVOmHAZlogoRNatNjYnVCI1eZZiUK1Fu1DpxqFz1Fl9zyRON4juM
```

### :paperclip: Attachments

The following endpoints are supported with attachments:

:black\_medium\_small\_square:Sending a media message\
:black\_medium\_small\_square:Sending a interactive message

{% hint style="info" %}
Please follow the guidelines listed below:

* Only files on a local machine can be added using the API. You can not use links!
* **Content-Type** should always be multi-part/form-data for attached requests.
  {% endhint %}

### :x: Errors

> **I received an error. How can I solve it?**

API requests that cause errors will return an appropriate HTTP status code to help determine the type of error. You can use the following table to understand what each code means:

| **HTTP Status Code** | **Status Code Definition**       | **Description**                                                                                                                                                                                                                                                                            |
| -------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **400**              | **Client or Validation Error**   | <p>The request body/query string is not in the correct format.</p><p>For example, the <strong>Send a message</strong> API requires the <strong>to</strong> field to be submitted as part of the request, and if it is missing, this status code is returned.</p>                           |
| **401**              | **Authentication Failure**       | <p>This indicates that the <strong>Authorization</strong> field is either missing or incorrect.</p><p>Check <a href="#authentication">Authentication</a> for more information.</p>                                                                                                         |
| **404**              | **Requested Resource not Found** | <p>The request contains an <strong>invalid ID</strong> or <strong>invalid parameters in the URL</strong>.<br>For example, an API call to retrieve a integration with an invalid ID will return an <strong>HTTP 404</strong> status code to inform you that no such integration exists.</p> |
| **405**              | **Method not allowed**           | <p>This API request has used the wrong HTTP method.</p><p>For example, a <strong>DELETE</strong> requested on <strong>/integrations</strong> endpoint will return an <strong>HTTP 405</strong> as <strong>/integrations</strong> allows only <strong>GET</strong> requests.</p>            |
| **406**              | **Unsupported Accept Header**    | Only **application/json** and **\*/\*** are supported. When uploading files **multipart/form-data** are supported.                                                                                                                                                                         |
| **415**              | **Unsupported Content-type**     | Only **application/json** is supported.                                                                                                                                                                                                                                                    |
| **429**              | **Rate Limit Exceeded**          | The API rate limit allowed for your Desk360 domain has been exhausted. Check[ Rate Limit](#rate-limit).                                                                                                                                                                                    |
| **500**              | **Unexpected Server Error**      | You can't do much more here. This indicates an error on the Desk360 side. Please [email us](mailto:support@desk360.com) your API script with response headers. We will contact you and fix this issue as soon as possible.                                                                 |

**Sample error response**

In addition to the HTTP status code, most errors also return a response with more information to help you troubleshoot the error. An example error response is shown below. The format of the error response is explained after the example.

```http
    "error": {
        "code": "failed_validation",
        "message": "The to field is required."
        "doc_url": "https://docs.desk360.com/api"
    }
}
```

**Error Response Fields**

| **Field**    | **Description**                                                  |
| ------------ | ---------------------------------------------------------------- |
| **code**     | Custom error code that is machine-parseable.                     |
| **message**  | Descriptive error message.                                       |
| **doc\_url** | A link to guide you if there is a solution on the documentation. |

#### Error Codes

| **Code**                            | **Description**                                                                                                                                                                             |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **authentication\_exception**       | Authentication failed. The token is missing or invalid. Do not forget to put "**Bearer**" in the beginning of your token. eg: "**Bearer YOUR-API-TOKEN**"                                   |
| **method\_not\_allowed\_exception** | If the method and endpoint is mismatched, you will get this error. Please check the endpoint method. eg:  [Products](https://whatsapp.desk360.com/broken-reference) only allows GET method. |
| **not\_found\_exception**           | You may have made a typo in your request URL.                                                                                                                                               |
| **model\_not\_found\_exception**    | Requested resource not found, the resource maybe deleted or maybe the resource is not yours.                                                                                                |
| **internal\_server\_error**         | The error is coming from our servers. If you have been receiving this error message for a while, [contact us](mailto:support@desk360.com).                                                  |
| **insecure\_request\_exception**    | HTTP is not allowed. Use **HTTPS** instead.                                                                                                                                                 |
| **too\_many\_requests\_exception**  | Check [Rate Limit](#rate-limit).                                                                                                                                                            |
| **invalid\_credentials**            | You typed your email/password wrong.                                                                                                                                                        |
| **too\_many\_attempts**             | If you entered your email/password wrong more than 5 times, you should wait for a minute.                                                                                                   |
| **not\_authorized**                 | You do not have permission to modify the resource.                                                                                                                                          |
| **not\_found**                      | Requested resource not found, the resource maybe deleted or maybe the resource is not yours.                                                                                                |
| **failed\_validation**              | This is a validation error, please read the message and apply what it says.                                                                                                                 |

### :page\_facing\_up: Pagination

API responses that return a list of objects are paginated, for example, **View Integration List**. Add the parameter page to the query string to navigate through the pages. The page number starts from 1 and each page is fixed to show 20 objects.

```http
https://public-api.desk360.com/api/v1/integrations?page=1
```

The "Link" header in the response will be showing the next page if it exists:

```http
Headers
"Link" : <https://public-api.desk360.com/v1/integrations?page=2>; rel=next
```

{% hint style="info" %}
If you are on the last page the link header will not be filled.
{% endhint %}

### :white\_check\_mark: Best Practices

* Whenever it is possible, please queue API calls on your side. This allows you to buffer recent calls to avoid reaching the rate limit. Once you reach the rate limit, retry API calls after the retry period.
* Whenever it is feasible, cache the data that does not change much on your side. For example, the mapping between agent name and ID is extremely unlikely to change, so it is a useful approach to cache this data to avoid the rate limit.&#x20;
* Avoid making API calls directly from a mobile app, instead, send the request to your servers and make API calls from there. This ensures that if an API endpoint is changed, you can make and deploy the change on your server instead of updating your application and forcing your customers to the latest version.

## Integrations

Apart from its competitors, Desk360 enables its customers to manage multiple integrations under one account.

In order to find your **Integration ID**, visit [Integrations](#introduction).

### Integrations <a href="#integrations" id="integrations"></a>

<mark style="color:blue;">`GET`</mark> `https://public-api.desk360.com/v1/integrations`

List of your integrations.

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API token |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "id": 11,
        "display_name": "YourIntegration1",
        "phone_number": "+905554443322"
    },
    {
        "id": 22,
        "name": "YourIntegration2",
        "logo": "+905555555555"
    }
]
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request GET 'https://public-api.desk360.com/v1/integrations' \
--header 'Authorization: Bearer YOUR_API_TOKEN'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new RestClient("https://public-api.desk360.com/v1/integrations");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations")
  .method("GET", null)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://public-api.desk360.com/v1/integrations',
  headers: { 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations"

payload={}
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}

## WhatsApp Message Templates

WhatsApp message templates are message formats that let you deliver multiple notifications to customers who have agreed to receive them via WhatsApp.

### WhatsApp Message Templates

<mark style="color:blue;">`GET`</mark> `https://public-api.desk360.comv1/integrations/:integrationId/conversations/templates`

Get WhatsApp message template and languages list from a product.

#### Path Parameters

| Name                                             | Type    | Description                |
| ------------------------------------------------ | ------- | -------------------------- |
| IntegrationId <mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | String | Your API Token |

{% tabs %}
{% tab title="200 " %}

```json
[
  {
    "id": 75,
    "name": "template_02",
    "category_editable": false,
    "sendable": true,
    "category": {
      "value": 2,
      "label": "template-messages.new.custom",
      "subLabel": "template-messages.new.custom-subtitle",
      "status": 1,
      "children": []
    },
    "category_label": "template-messages.new.custom",
    "supported_languages": [
      {
        "label": "English",
        "value": 1,
        "filled": true
      },
      {
        "label": "Türkçe",
        "value": 2,
        "filled": true
      }
    ],
    "translations": [
      {
        "language_id": 1,
        "language": "English",
        "header_type": null,
        "header_variables": null,
        "header": null,
        "header_file": null,
        "body": "English content test",
        "body_variables": null,
        "footer": null,
        "variables": [],
        "buttons": [],
        "editable": true,
        "status": "template-messages.in-review",
        "status_value": 1,
        "quality": "template-messages.quality-unavailable",
        "updated_at": "2024-05-31T06:33:30.000000Z"
      },
      {
        "language_id": 2,
        "language": "Türkçe",
        "header_type": {
          "value": 4,
          "label": "TEXT"
        },
        "header_variables": [
          {
            "id": "",
            "key": "1",
            "value": "Header 1"
          }
        ],
        "header": "Merhaba {{1}} ,",
        "header_file": null,
        "body": "Merhaba {{1}}, Sipariş takip numaranız: {{2}} Bu takip numarası ile siparişinizin durumunu sorgulayabilirsiniz.",
        "body_variables": [
          {
            "id": "",
            "key": "1",
            "value": "Ahmet Kara"
          },
          {
            "id": "",
            "key": "2",
            "value": "SP123456789"
          }
        ],
        "footer": null,
        "variables": [
          "header-1",
          "body-1",
          "body-2"
        ],
        "buttons": [],
        "editable": true,
        "status": "template-messages.active",
        "status_value": 2,
        "quality": "template-messages.quality-unavailable",
        "updated_at": "2024-05-30T12:16:37.000000Z"
      }
    ],
    "created_at": "2024-05-30T12:14:28.000000Z",
    "updated_at": "2024-05-31T06:33:30.000000Z"
  }
]
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request GET 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/?page=1' \--header 'Authorization: Bearer YOUR_API_TOKEN'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new RestClientRestClient("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates")
  .method("GET", null)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates',
  headers: { 
    'Authorization': 'Bearer YOUR_API_TOKEN', 
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_TOKEN',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates"

payload={}
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN',
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Send WhatsApp Message Template

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationsId/conversations/templates/send`

Send active WhatsApp message template to a WhatsApp number. If you send with attachments, use form-data. You can also send other body parameters with form-data as well.&#x20;

#### Path Parameters

| Name                                             | Type    | Description                |
| ------------------------------------------------ | ------- | -------------------------- |
| IntegrationId <mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

#### Request Body

<table><thead><tr><th width="261">Name</th><th width="109">Type</th><th>Description</th></tr></thead><tbody><tr><td>template_id <mark style="color:red;">*</mark></td><td>Integer</td><td>The template id of the template to be sent.</td></tr><tr><td>language_id <mark style="color:red;">*</mark></td><td>Integer</td><td>The language id of the template to be sent.</td></tr><tr><td>destinations[] <mark style="color:red;">*</mark></td><td>array</td><td>Required parameters for the template. The key list received in the template list should be used as a key during submission.</td></tr><tr><td>destinations.*.phone <mark style="color:red;">*</mark></td><td>string</td><td>WhatsApp number to be sent. It should start with (+) and a country code.</td></tr><tr><td>destinations.*.parameters</td><td>object</td><td>Required parameters for the template. The key list received in the template list should be used as a key during submission.</td></tr><tr><td>attachment </td><td>file</td><td>Attachment for the message template (only allowed in form-data).</td></tr></tbody></table>

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_id": "gBEGkFBXUQRnAglW0luHY8xsrFk"
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send' \
--header 'Authorization: YOUR_API_TOKEN' \
--form 'template_id="1"' \
--form 'language_id="1"' \
--form 'destinations[0][phone]="+905555555555"' \
--form 'destinations[0][parameters][header-1]="Header 1"' \
--form 'destinations[0][parameters][body-1]="Body 1"' \
--form 'destinations[0][parameters][body-2]="Body 2"' \
--form 'attachment=@"/test_image.jpg"'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/integrationId/conversations/templates/send", Method.Post);
request.AddHeader("Authorization", "YOUR_API_TOKEN");
request.AlwaysMultipartFormData = true;
request.AddParameter("template_id", "1");
request.AddParameter("language_id", "1");
request.AddParameter("destinations[0][phone]", "+905555555555");
request.AddParameter("destinations[0][parameters][header-1]", "Header 1");
request.AddParameter("destinations[0][parameters][body-1]", "Body 1");
request.AddParameter("destinations[0][parameters][body-2]", "Body 2");
request.AddFile("attachment", "/test_image.jpg");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("template_id","1")
  .addFormDataPart("language_id","1")
  .addFormDataPart("destinations[0][phone]","+905555555555")
  .addFormDataPart("destinations[0][parameters][header-1]","Header 1")
  .addFormDataPart("destinations[0][parameters][body-1]","Body 1")
  .addFormDataPart("destinations[0][parameters][body-2]","Body 2")
  .addFormDataPart("attachment","test_image.jpg",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("/test_image.jpg")))
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send")
  .method("POST", body)
  .addHeader("Authorization", "YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('template_id', '1');
data.append('language_id', '1');
data.append('destinations[0][phone]', '+905555555555');
data.append('destinations[0][parameters][header-1]', 'Header 1');
data.append('destinations[0][parameters][body-1]', 'Body 1');
data.append('destinations[0][parameters][body-2]', 'Body 2');
data.append('attachment', fs.createReadStream('/test_image.jpg'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send',
  headers: { 
    'Authorization': 'YOUR_API_TOKEN', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('template_id' => '1','language_id' => '1','destinations[0][phone]' => '+905555555555','destinations[0][parameters][header-1]' => 'Header 1','destinations[0][parameters][body-1]' => 'Body 1','destinations[0][parameters][body-2]' => 'Body 2','attachment'=> new CURLFILE('/test_image.jpg')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send"

payload = {'template_id': '1',
'language_id': '1',
'destinations[0][phone]': '+905555555555',
'destinations[0][parameters][header-1]': 'Header 1',
'destinations[0][parameters][body-1]': 'Body 1',
'destinations[0][parameters][body-2]': 'Body 2'}
files=[
  ('attachment',('test_image.jpg',open('/test_image.jpg','rb'),'image/png'))
]
headers = {
  'Authorization': 'YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Bulk Send WhatsApp Message Template

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send/bulk`

Send active WhatsApp message template to multiple WhatsApp number. If you send with attachments, use form-data. You can also send other body parameters with form-data as well.&#x20;

#### Path Parameters

| Name                                             | Type    | Description                |
| ------------------------------------------------ | ------- | -------------------------- |
| IntegrationId <mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

#### Request Body

<table><thead><tr><th width="219">Name</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td>template_id <mark style="color:red;">*</mark></td><td>Integer</td><td>The template id of the template to be sent.</td></tr><tr><td>language_id <mark style="color:red;">*</mark></td><td>Integer</td><td>The language id of the template to be sent.</td></tr><tr><td>destinations[]</td><td>array</td><td>Destinations for the template.</td></tr><tr><td>destinations.*.phone</td><td>string</td><td>WhatsApp number to be sent. It should start with (+) and a country code.</td></tr><tr><td>parameters</td><td>object</td><td>Required parameters for the template. The key list received in the template list should be used as a key during submission.</td></tr><tr><td>attachment </td><td>file</td><td>Attachment for the message template (only allowed in form-data).</td></tr><tr><td>destinations_file</td><td>file</td><td>WhatsApp numbers csv file to be sent. It should start with (+) and a country code.</td></tr></tbody></table>

{% tabs %}
{% tab title="200 " %}

```json
{
    "phones": [
        "+905555555555"
    ]
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send/bulk' \
--header 'Authorization: YOUR_API_TOKEN' \
--form 'template_id="1"' \
--form 'language_id="1"' \
--form 'destinations[0][phone]="+905555555555"' \
--form 'parameters[header-1]="Header 1"' \
--form 'parameters[body-1]="Body 1"' \
--form 'parameters[body-2]="Body 2"' \
--form 'attachment=@"/test_image.jpg"'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/templates/send/bulk", Method.Post);
request.AddHeader("Authorization", "YOUR_API_TOKEN");
request.AlwaysMultipartFormData = true;
request.AddParameter("template_id", "1");
request.AddParameter("language_id", "1");
request.AddParameter("destinations[0][phone]", "+905555555555");
request.AddParameter("parameters[header-1]", "Header 1");
request.AddParameter("parameters[body-1]", "Body 1");
request.AddParameter("parameters[body-2]", "Body 2");
request.AddFile("attachment", "/test_image.jpg");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("template_id","1")
  .addFormDataPart("language_id","1")
  .addFormDataPart("destinations[0][phone]","+905555555555")
  .addFormDataPart("parameters[header-1]","Header 1")
  .addFormDataPart("parameters[body-1]","Body 1")
  .addFormDataPart("parameters[body-2]","Body 2")
  .addFormDataPart("attachment","test_image.jpg",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("/test_image.jpg")))
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send/bulk")
  .method("POST", body)
  .addHeader("Authorization", "YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('template_id', '1');
data.append('language_id', '1');
data.append('destinations[0][phone]', '+905555555555');
data.append('parameters[header-1]', 'Header 1');
data.append('parameters[body-1]', 'Body 1');
data.append('parameters[body-2]', 'Body 2');
data.append('attachment', fs.createReadStream('/test_image.jpg'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send/bulk',
  headers: { 
    'Authorization': 'YOUR_API_TOKEN', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send/bulk',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('template_id' => '1','language_id' => '1','destinations[0][phone]' => '+905555555555','parameters[header-1]' => 'Header 1','parameters[body-1]' => 'Body 1','parameters[body-2]' => 'Body 2','attachment'=> new CURLFILE('/test_image.jpg')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/templates/send/bulk"

payload = {'template_id': '1',
'language_id': '1',
'destinations[0][phone]': '+905555555555',
'parameters[header-1]': 'Header 1',
'parameters[body-1]': 'Body 1',
'parameters[body-2]': 'Body 2'}
files=[
  ('attachment',('desk360_facebook.png',open('/test_image.jpg','rb'),'image/png'))
]
headers = {
  'Authorization': 'YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}
{% endtabs %}

## WhatsApp Messages

Use the messages node to send text, location, contact, media, interactive, location request and read receipt message to your customers.

### Send WhatsApp Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages`

Send message to an active WhatsApp number.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

#### Request Body

| Name                                    | Type   | Description                                                              |
| --------------------------------------- | ------ | ------------------------------------------------------------------------ |
| to<mark style="color:red;">\*</mark>    | string | WhatsApp number to be sent. It should start with (+) and a country code. |
| text <mark style="color:red;">\*</mark> | string | Message body. It should max 4096 chars.                                  |

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_id": "gBEGkFBXUQRnAgnoOJ1ESPKBwME"
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'to="+90xxxxxxxxxx"' \
--form 'text="Hello!"'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages", Method.Post);
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
request.AlwaysMultipartFormData = true;
request.AddParameter("to", "+90xxxxxxxxxx");
request.AddParameter("text", "Hello!");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("to","+90xxxxxxxxxx")
  .addFormDataPart("text","Hello!")
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages")
  .method("POST", body)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('to', '+90xxxxxxxxxx');
data.append('text', 'hello!');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages',
  headers: { 
    'Authorization': 'Bearer YOUR_API_TOKEN', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('to' => '+90xxxxxxxxxx','text' => 'Hello!'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages"

payload = {'to': '+90xxxxxxxxxx',
'text': 'Hello!'}
files=[

]
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Send WhatsApp Location Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages`

Send location message to an active WhatsApp number.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | String | Your API Token |

#### Request Body

| Name                                                 | Type    | Description                                                              |
| ---------------------------------------------------- | ------- | ------------------------------------------------------------------------ |
| to<mark style="color:red;">\*</mark>                 | String  | WhatsApp number to be sent. It should start with (+) and a country code. |
| location<mark style="color:red;">\*</mark>           | Object  | An object of the message.                                                |
| location.longitude<mark style="color:red;">\*</mark> | Numeric | Longitude of location.                                                   |
| location.latitude<mark style="color:red;">\*</mark>  | Numeric | Latitude of location.                                                    |
| location.name<mark style="color:red;">\*</mark>      | String  | Name of location.                                                        |
| location.address<mark style="color:red;">\*</mark>   | String  | Address of location.                                                     |

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_id": "gBEGkFBXUQRnAgn3kXajlucbaso"
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/locations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
    "to": "+90xxxxxxxxxx",
    "location": {
        "longitude": -122.425332,
        "latitude": 37.758056,
        "name": "Facebook HQ",
        "address": "1 Hacker Way, Menlo Park, CA 94025"
    }
}'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/locations", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
var body = @"{" + "\n" +
@"    ""to"": ""+90xxxxxxxxxx""," + "\n" +
@"    ""location"": {" + "\n" +
@"        ""longitude"": -122.425332," + "\n" +
@"        ""latitude"": 37.758056," + "\n" +
@"        ""name"": ""Facebook HQ""," + "\n" +
@"        ""address"": ""1 Hacker Way, Menlo Park, CA 94025""" + "\n" +
@"    }" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"to\": \"+90xxxxxxxxxx\",\n    \"location\": {\n        \"longitude\": -122.425332,\n        \"latitude\": 37.758056,\n        \"name\": \"Facebook HQ\",\n        \"address\": \"1 Hacker Way, Menlo Park, CA 94025\"\n    }\n}");
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/locations")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "to": "+90xxxxxxxxxx",
  "location": {
    "longitude": -122.425332,
    "latitude": 37.758056,
    "name": "Facebook HQ",
    "address": "1 Hacker Way, Menlo Park, CA 94025"
  }
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/locations',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/locations',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "to": "+90xxxxxxxxxx",
    "location": {
        "longitude": -122.425332,
        "latitude": 37.758056,
        "name": "Facebook HQ",
        "address": "1 Hacker Way, Menlo Park, CA 94025"
    }
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/locations"

payload = json.dumps({
  "to": "+90xxxxxxxxxx",
  "location": {
    "longitude": -122.425332,
    "latitude": 37.758056,
    "name": "Facebook HQ",
    "address": "1 Hacker Way, Menlo Park, CA 94025"
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Send WhatsApp Contact Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/contacts`

Send contact message to an active WhatsApp number.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | String | Your API Token |

#### Request Body

| Name                                                               | Type   | Description                                                              |
| ------------------------------------------------------------------ | ------ | ------------------------------------------------------------------------ |
| to<mark style="color:red;">\*</mark>                               | String | WhatsApp number to be sent. It should start with (+) and a country code. |
| contacts<mark style="color:red;">\*</mark>                         | Array  | An array of the message.                                                 |
| contacts.\*.addresses.\*.street                                    | String | Street of address.                                                       |
| contacts.\*.addresses.\*.city                                      | String | City of address.                                                         |
| contacts.\*.addresses.\*.state                                     | String | State of address.                                                        |
| contacts.\*.addresses.\*.zip                                       | String | Zip code of address.                                                     |
| contacts.\*.addresses.\*.country                                   | String | Country of address.                                                      |
| contacts.\*.addresses.\*.country\_code                             | String | Country code of address.                                                 |
| contacts.\*.addresses.\*.type                                      | String | Type of address.                                                         |
| contacts.\*.birthday                                               | String | Birtday of contacts. Must be "Y-m-d" format.                             |
| contacts.\*.emails.\*.email                                        | String | Email of emails.                                                         |
| contacts.\*.emails.\*.type                                         | String | Type of emails.                                                          |
| contacts.\*.name.formatted\_name<mark style="color:red;">\*</mark> | String | Formatted name of name object.                                           |
| contacts.\*.name.first\_name<mark style="color:red;">\*</mark>     | String | First name of name object.                                               |
| contacts.\*.name.last\_name<mark style="color:red;">\*</mark>      | String | Last name of name object.                                                |
| contacts.\*.name.middle\_name                                      | String | Middle name of name object.                                              |
| contacts.\*.name.suffix                                            | String | Suffix of name.                                                          |
| contacts.\*.name.prefix                                            | String | Prefix of name.                                                          |
| contacts.\*.org.company                                            | String | Company name of organization.                                            |
| contacts.\*.org.department                                         | String | Department of organization.                                              |
| contacts.\*.org.title                                              | String | Title of organization.                                                   |
| contacts.\*.phones.\*.phone                                        | String | Phone number of phones.                                                  |
| contacts.\*.phones.\*.type                                         | String | Type of phones.                                                          |
| contacts.\*.phones.\*.wa\_id                                       | String | WAID of phones                                                           |
| contacts.\*.urls.\*.url                                            | String | Url of urls.                                                             |
| contacts.\*.urls.\*.type                                           | String | Type of urls.                                                            |

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_id": "gBEGkFBXUQRnAgkCL1xSaIMoDz0"
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/contacts' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data-raw '{
    "to": "+90xxxxxxxxxx",
    "contacts": [
        {
            "addresses": [
                {
                    "city": "Menlo Park",
                    "country": "United States",
                    "country_code": "us",
                    "state": "CA",
                    "street": "1 Hacker Way",
                    "type": "HOME",
                    "zip": "94025"
                }
            ],
            "birthday": "2012-08-18",
            "emails": [
                {
                    "email": "test@whatsapp.com",
                    "type": "WORK"
                }
            ],
            "name": {
                "first_name": "John",
                "formatted_name": "John Smith",
                "last_name": "Smith"
            },
            "org": {
                "company": "WhatsApp",
                "department": "Design",
                "title": "Manager"
            },
            "phones": [
                {
                    "phone": "+1 (650) 555-1234",
                    "type": "WORK",
                    "wa_id": "16505551234"
                }
            ],
            "urls": [
                {
                    "url": "https://www.facebook.com",
                    "type": "WORK"
                }
            ]
        }
    ]
}'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/contacts", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
var body = @"{" + "\n" +
@"    ""to"": ""+90xxxxxxxxxx""," + "\n" +
@"    ""contacts"": [" + "\n" +
@"        {" + "\n" +
@"            ""addresses"": [" + "\n" +
@"                {" + "\n" +
@"                    ""city"": ""Menlo Park""," + "\n" +
@"                    ""country"": ""United States""," + "\n" +
@"                    ""country_code"": ""us""," + "\n" +
@"                    ""state"": ""CA""," + "\n" +
@"                    ""street"": ""1 Hacker Way""," + "\n" +
@"                    ""type"": ""HOME""," + "\n" +
@"                    ""zip"": ""94025""" + "\n" +
@"                }" + "\n" +
@"            ]," + "\n" +
@"            ""birthday"": ""2012-08-18""," + "\n" +
@"            ""emails"": [" + "\n" +
@"                {" + "\n" +
@"                    ""email"": ""test@whatsapp.com""," + "\n" +
@"                    ""type"": ""WORK""" + "\n" +
@"                }" + "\n" +
@"            ]," + "\n" +
@"            ""name"": {" + "\n" +
@"                ""first_name"": ""John""," + "\n" +
@"                ""formatted_name"": ""John Smith""," + "\n" +
@"                ""last_name"": ""Smith""" + "\n" +
@"            }," + "\n" +
@"            ""org"": {" + "\n" +
@"                ""company"": ""WhatsApp""," + "\n" +
@"                ""department"": ""Design""," + "\n" +
@"                ""title"": ""Manager""" + "\n" +
@"            }," + "\n" +
@"            ""phones"": [" + "\n" +
@"                {" + "\n" +
@"                    ""phone"": ""+1 (650) 555-1234""," + "\n" +
@"                    ""type"": ""WORK""," + "\n" +
@"                    ""wa_id"": ""16505551234""" + "\n" +
@"                }" + "\n" +
@"            ]," + "\n" +
@"            ""urls"": [" + "\n" +
@"                {" + "\n" +
@"                    ""url"": ""https://www.facebook.com""," + "\n" +
@"                    ""type"": ""WORK""" + "\n" +
@"                }" + "\n" +
@"            ]" + "\n" +
@"        }" + "\n" +
@"    ]" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"to\": \"+90xxxxxxxxxx\",\n    \"contacts\": [\n        {\n            \"addresses\": [\n                {\n                    \"city\": \"Menlo Park\",\n                    \"country\": \"United States\",\n                    \"country_code\": \"us\",\n                    \"state\": \"CA\",\n                    \"street\": \"1 Hacker Way\",\n                    \"type\": \"HOME\",\n                    \"zip\": \"94025\"\n                }\n            ],\n            \"birthday\": \"2012-08-18\",\n            \"emails\": [\n                {\n                    \"email\": \"test@whatsapp.com\",\n                    \"type\": \"WORK\"\n                }\n            ],\n            \"name\": {\n                \"first_name\": \"John\",\n                \"formatted_name\": \"John Smith\",\n                \"last_name\": \"Smith\"\n            },\n            \"org\": {\n                \"company\": \"WhatsApp\",\n                \"department\": \"Design\",\n                \"title\": \"Manager\"\n            },\n            \"phones\": [\n                {\n                    \"phone\": \"+1 (650) 555-1234\",\n                    \"type\": \"WORK\",\n                    \"wa_id\": \"16505551234\"\n                }\n            ],\n            \"urls\": [\n                {\n                    \"url\": \"https://www.facebook.com\",\n                    \"type\": \"WORK\"\n                }\n            ]\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/contacts")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "to": "+90xxxxxxxxxx",
  "contacts": [
    {
      "addresses": [
        {
          "city": "Menlo Park",
          "country": "United States",
          "country_code": "us",
          "state": "CA",
          "street": "1 Hacker Way",
          "type": "HOME",
          "zip": "94025"
        }
      ],
      "birthday": "2012-08-18",
      "emails": [
        {
          "email": "test@whatsapp.com",
          "type": "WORK"
        }
      ],
      "name": {
        "first_name": "John",
        "formatted_name": "John Smith",
        "last_name": "Smith"
      },
      "org": {
        "company": "WhatsApp",
        "department": "Design",
        "title": "Manager"
      },
      "phones": [
        {
          "phone": "+1 (650) 555-1234",
          "type": "WORK",
          "wa_id": "16505551234"
        }
      ],
      "urls": [
        {
          "url": "https://www.facebook.com",
          "type": "WORK"
        }
      ]
    }
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/contacts',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/contacts',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "to": "+90xxxxxxxxxx",
    "contacts": [
        {
            "addresses": [
                {
                    "city": "Menlo Park",
                    "country": "United States",
                    "country_code": "us",
                    "state": "CA",
                    "street": "1 Hacker Way",
                    "type": "HOME",
                    "zip": "94025"
                }
            ],
            "birthday": "2012-08-18",
            "emails": [
                {
                    "email": "test@whatsapp.com",
                    "type": "WORK"
                }
            ],
            "name": {
                "first_name": "John",
                "formatted_name": "John Smith",
                "last_name": "Smith"
            },
            "org": {
                "company": "WhatsApp",
                "department": "Design",
                "title": "Manager"
            },
            "phones": [
                {
                    "phone": "+1 (650) 555-1234",
                    "type": "WORK",
                    "wa_id": "16505551234"
                }
            ],
            "urls": [
                {
                    "url": "https://www.facebook.com",
                    "type": "WORK"
                }
            ]
        }
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/contacts"

payload = json.dumps({
  "to": "+90xxxxxxxxxx",
  "contacts": [
    {
      "addresses": [
        {
          "city": "Menlo Park",
          "country": "United States",
          "country_code": "us",
          "state": "CA",
          "street": "1 Hacker Way",
          "type": "HOME",
          "zip": "94025"
        }
      ],
      "birthday": "2012-08-18",
      "emails": [
        {
          "email": "test@whatsapp.com",
          "type": "WORK"
        }
      ],
      "name": {
        "first_name": "John",
        "formatted_name": "John Smith",
        "last_name": "Smith"
      },
      "org": {
        "company": "WhatsApp",
        "department": "Design",
        "title": "Manager"
      },
      "phones": [
        {
          "phone": "+1 (650) 555-1234",
          "type": "WORK",
          "wa_id": "16505551234"
        }
      ],
      "urls": [
        {
          "url": "https://www.facebook.com",
          "type": "WORK"
        }
      ]
    }
  ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Send WhatsApp Media Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias`

Send media messages to an active WhatsApp number.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

#### Request Body

| Name                                             | Type   | Description                                                                                       |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------- |
| to<mark style="color:red;">\*</mark>             | string | WhatsApp number to be sent. It should start with (+) and a country code.                          |
| attachments\[]<mark style="color:red;">\*</mark> | object | <p>Attachment for the message (Only allowed in form-data).</p><p>Max Count: 5, Max Size: 20MB</p> |

{% tabs %}
{% tab title="200 " %}

```json
{
    "medias": {
        "images": [
            {
                "url": "https://my-cdn.desk360.com/integrations/integrationId/attachments/bTARCYuscrcWU20t0dA8aesXufZKVuS0INd8rR5L.png",
                "name": "desk360.png",
                "type": "image",
                "aws": true,
                "content_type": "image/png",
                "message_id": "gBEGkFBXUQRnAgkEg3us4YW8UJE",
                "media_id": "cae26b43-1463-44f5-9a81-f4119afbf6d9"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'to="+90xxxxxxxxxx"' \
--form 'attachments[]=@"/path/to/file"'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/medias", Method.Post);
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
request.AlwaysMultipartFormData = true;
request.AddParameter("to", "+90xxxxxxxxxx");
request.AddFile("attachments[]", "/path/to/file");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("to","+90xxxxxxxxxx")
  .addFormDataPart("attachments[]","file",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("/path/to/file")))
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias")
  .method("POST", body)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('to', '+90xxxxxxxxxx');
data.append('attachments[]', fs.createReadStream('/path/to/file'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias',
  headers: { 
    'Authorization': 'Bearer YOUR_API_TOKEN', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('to' => '+90xxxxxxxxxx','attachments[]'=> new CURLFILE('/path/to/file')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias"

payload = {'to': '+90xxxxxxxxxx'}
files=[
  ('attachments[]',('file',open('/path/to/file','rb'),'application/octet-stream'))
]
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Get WhatsApp Media

<mark style="color:blue;">`GET`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias/:mediaId`

Get whatsapp media by media id.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |
| MediaId<mark style="color:red;">\*</mark>       | String  | The ID of media            |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

{% tabs %}
{% tab title="200 " %}

```json
{fileObject}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request GET 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias/:mediaId' \
--header 'Authorization: Bearer YOUR_API_TOKEN'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/medias/:mediaId", Method.Get);
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, "{}");
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias/:mediaId")
  .method("GET", body)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias/:mediaId',
  headers: { 
    'Authorization': 'Bearer YOUR_API_TOKEN', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias/:mediaId',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/medias/:mediaId"

payload = {}
files={}
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("GET", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Send WhatsApp Interactive Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive`

Send interactive message to an active WhatsApp number.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

#### Request Body

| Name                                               | Type   | Description                                                                                                                                        |
| -------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| to<mark style="color:red;">\*</mark>               | String | WhatsApp number to be sent. It should start with (+) and a country code.                                                                           |
| body<mark style="color:red;">\*</mark>             | String | Message body. It must be max 1024 chars.                                                                                                           |
| buttons\[]<mark style="color:red;">\*</mark>       | Array  | Required parameters for the interactive message. It must be max 10 button object item.                                                             |
| buttons.\*.id<mark style="color:red;">\*</mark>    | String | Unique identifier for your button. This ID is returned in the webhook when the button is clicked by the user. Maximum length: 200 chars.           |
| buttons.\*.title<mark style="color:red;">\*</mark> | String | Button title. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 chars. |
| header                                             | Object | An object with the header of the message.                                                                                                          |
| header.type                                        | String | Required if header is set. Supported values: text, image, video or document.                                                                       |
| header.text                                        | String | Required if header's type is text. It must be max 60 chars.                                                                                        |
| header.document.link                               | String | Required if header's type is document.                                                                                                             |
| header.document.filename                           | String | Header's document filename.                                                                                                                        |
| header.video.link                                  | String | Required if header's type is video.                                                                                                                |
| header.image.link                                  | String | Required if header's type is image.                                                                                                                |
| footer                                             | Object | An object with the footer of the message.                                                                                                          |
| footer.text                                        | String | Required if footer object. It must be max 60 chars.                                                                                                |

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_id": "gBEGkFBXUQRnAglHuQTBEMHpUdo"
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
    "to": "+90xxxxxxxxxx",
    "header": {
        "type": "image",
        "image": {
            "link": "https://fastly.picsum.photos/id/879/200/300.jpg?hmac=07llkorYxtpw0EwxaeqFKPC5woveWVLykQVnIOyiwd8"
        }
    },
    "body": "<p>Hello</p>",
    "footer": {
        "text": "<b>Bye</b>"
    },
    "buttons": [
        {
            "id": "ID 1.1",
            "title": "Button 1"
        },
        {
            "id": "ID 1.2",
            "title": "Button 2"
        },
        {
            "id": "ID 1.3",
            "title": "Button 3"
        }
    ]
}'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/interactive", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
var body = @"{" + "\n" +
@"    ""to"": ""+90xxxxxxxxxx""," + "\n" +
@"    ""header"": {" + "\n" +
@"        ""type"": ""image""," + "\n" +
@"        ""image"": {" + "\n" +
@"            ""link"": ""https://fastly.picsum.photos/id/879/200/300.jpg?hmac=07llkorYxtpw0EwxaeqFKPC5woveWVLykQVnIOyiwd8""" + "\n" +
@"        }" + "\n" +
@"    }," + "\n" +
@"    ""body"": ""<p>Hello</p>""," + "\n" +
@"    ""footer"": {" + "\n" +
@"        ""text"": ""<b>Bye</b>""" + "\n" +
@"    }," + "\n" +
@"    ""buttons"": [" + "\n" +
@"        {" + "\n" +
@"            ""id"": ""ID 1.1""," + "\n" +
@"            ""title"": ""Button 1""" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""id"": ""ID 1.2""," + "\n" +
@"            ""title"": ""Button 2""" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""id"": ""ID 1.3""," + "\n" +
@"            ""title"": ""Button 3""" + "\n" +
@"        }" + "\n" +
@"    ]" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"to\": \"+90xxxxxxxxxx\",\n    \"header\": {\n        \"type\": \"image\",\n        \"image\": {\n            \"link\": \"https://fastly.picsum.photos/id/879/200/300.jpg?hmac=07llkorYxtpw0EwxaeqFKPC5woveWVLykQVnIOyiwd8\"\n        }\n    },\n    \"body\": \"<p>Hello</p>\",\n    \"footer\": {\n        \"text\": \"<b>Bye</b>\"\n    },\n    \"buttons\": [\n        {\n            \"id\": \"ID 1.1\",\n            \"title\": \"Button 1\"\n        },\n        {\n            \"id\": \"ID 1.2\",\n            \"title\": \"Button 2\"\n        },\n        {\n            \"id\": \"ID 1.3\",\n            \"title\": \"Button 3\"\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "to": "+90xxxxxxxxxx",
  "header": {
    "type": "image",
    "image": {
      "link": "https://fastly.picsum.photos/id/879/200/300.jpg?hmac=07llkorYxtpw0EwxaeqFKPC5woveWVLykQVnIOyiwd8"
    }
  },
  "body": "<p>Hello</p>",
  "footer": {
    "text": "<b>Bye</b>"
  },
  "buttons": [
    {
      "id": "ID 1.1",
      "title": "Button 1"
    },
    {
      "id": "ID 1.2",
      "title": "Button 2"
    },
    {
      "id": "ID 1.3",
      "title": "Button 3"
    }
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "to": "+90xxxxxxxxxx",
    "header": {
        "type": "image",
        "image": {
            "link": "https://fastly.picsum.photos/id/879/200/300.jpg?hmac=07llkorYxtpw0EwxaeqFKPC5woveWVLykQVnIOyiwd8"
        }
    },
    "body": "<p>Hello</p>",
    "footer": {
        "text": "<b>Bye</b>"
    },
    "buttons": [
        {
            "id": "ID 1.1",
            "title": "Button 1"
        },
        {
            "id": "ID 1.2",
            "title": "Button 2"
        },
        {
            "id": "ID 1.3",
            "title": "Button 3"
        }
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive"

payload = json.dumps({
  "to": "+90xxxxxxxxxx",
  "header": {
    "type": "image",
    "image": {
      "link": "https://fastly.picsum.photos/id/879/200/300.jpg?hmac=07llkorYxtpw0EwxaeqFKPC5woveWVLykQVnIOyiwd8"
    }
  },
  "body": "<p>Hello</p>",
  "footer": {
    "text": "<b>Bye</b>"
  },
  "buttons": [
    {
      "id": "ID 1.1",
      "title": "Button 1"
    },
    {
      "id": "ID 1.2",
      "title": "Button 2"
    },
    {
      "id": "ID 1.3",
      "title": "Button 3"
    }
  ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Send WhatsApp Location Request Interactive Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive/location-request`

Send location request interactive message to an active WhatsApp number.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | String | Your API Token |

#### Request Body

| Name                                   | Type   | Description                                                              |
| -------------------------------------- | ------ | ------------------------------------------------------------------------ |
| to<mark style="color:red;">\*</mark>   | String | WhatsApp number to be sent. It should start with (+) and a country code. |
| body<mark style="color:red;">\*</mark> | String | Message body. It must be max 1024 chars.                                 |

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_id": "gBEGkFBXUQRnAgn6gWf5CzaF6Ko"
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive/location-request' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
    "to": "+90xxxxxxxxxx",
    "body": "<i>Send Location</i>"
}'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/interactive/location-request", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
var body = @"{" + "\n" +
@"    ""to"": ""+90xxxxxxxxxx""," + "\n" +
@"    ""body"": ""<i>Send Location</i>""" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"to\": \"+90xxxxxxxxxx\",\n    \"body\": \"<i>Send Location</i>\"\n}");
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive/location-request")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "to": "+90xxxxxxxxxx",
  "body": "<i>Send Location</i>"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive/location-request',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive/location-request',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "to": "+90xxxxxxxxxx",
    "body": "<i>Send Location</i>"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/interactive/location-request"

payload = json.dumps({
  "to": "+90xxxxxxxxxx",
  "body": "<i>Send Location</i>"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

### Read WhatsApp Message

<mark style="color:green;">`POST`</mark> `https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/reads`

Mark messages from webhook as read.

#### Path Parameters

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| IntegrationId<mark style="color:red;">\*</mark> | Integer | The ID of your integration |

#### Headers

| Name                                             | Type   | Description    |
| ------------------------------------------------ | ------ | -------------- |
| Authorization <mark style="color:red;">\*</mark> | string | Your API Token |

#### Request Body

| Name                                              | Type   | Description                                                              |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------ |
| message\_ids\[]<mark style="color:red;">\*</mark> | object | Message ids to mark as read                                              |
| to<mark style="color:red;">\*</mark>              | String | WhatsApp number to be read. It should start with (+) and a country code. |

{% tabs %}
{% tab title="200 " %}

```json
{
    "message_ids": [
        "gBEGkFBXUQRnAgn6gWf5CzaF6Ko",
        "gBEGkFBXUQRnAglHuQTBEMHpUdo"
    ]
}
```

{% endtab %}
{% endtabs %}

**Code Samples**

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/reads' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'to="+90xxxxxxxxxx"' \
--form 'message_ids[]="xxxxxxxxxxxxxxxx"'
```

{% endtab %}

{% tab title="C#" %}

```csharp
var options = new RestClientOptions("https://public-api.desk360.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v1/integrations/:integrationId/conversations/messages/reads", Method.Post);
request.AddHeader("Authorization", "Bearer YOUR_API_TOKEN");
request.AlwaysMultipartFormData = true;
request.AddParameter("to", "+90xxxxxxxxxx");
request.AddParameter("message_ids[]", "xxxxxxxxxxxxxxxx");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("to","+90xxxxxxxxxx")
  .addFormDataPart("message_ids[]","xxxxxxxxxxxxxxxx")
  .build();
Request request = new Request.Builder()
  .url("https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/reads")
  .method("POST", body)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('to', '+90xxxxxxxxxx');
data.append('message_ids[]', 'xxxxxxxxxxxxxxxx');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/reads',
  headers: { 
    'Authorization': 'Bearer YOUR_API_TOKEN', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/reads',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('message_ids[]' => 'xxxxxxxxxxxxxxxx','to' => '+90xxxxxxxxxx'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages/reads"

payload = {'message_ids[]': 'xxxxxxxxxxxxxxxx', 'to': '+90xxxxxxxxxx'}
files=[

]
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}
{% endtabs %}

## WhatsApp Webhooks

Subscribe to Webhooks to be notified about messages and message status updates your business receives.

### Received Messages Examples <a href="#received-messages-examples" id="received-messages-examples"></a>

**Text Messages**

```json
{
  "messages": {
    "id": "ABEGkFMIcyRoAgo-sGaD-H6MgPEt",
    "text": "Hello",
    "from": "90xxxxxxxxxx",
    "timestamp": "1630913975",
    "name": "John Doe",
    "type": "text"
  }
}
```

**Location Messages**

```json
{
  "messages": {
    "id": "ABEGkFBXUQRnAgo6cHkZc1yy0dAx",
    "text": "Main Street Beach - Main Street Beach, Santa Cruz, CA, latitude: 38.9806263495, longitude: -131.9428612257",
    "from": "90xxxxxxxxxx",
    "timestamp": "1700052659",
    "name": "John Doe",
    "location": {
      "address": "Main Street Beach, Santa Cruz, CA",
      "latitude": 38.9806263495,
      "longitude": -131.9428612257,
      "name": "Main Street Beach"
    },
    "type": "location"
  }
}
```

**Contact Messages**

```json
{
  "messages": {
    "id": "ABEGkFBXUQRnAgo6PXn8aI1fmlOm",
    "from": "90xxxxxxxxxx",
    "timestamp": "1700052797",
    "name": "John Doe",
    "type": "contacts",
    "contacts": [
      {
        "addresses": [
          {
            "city": "Menlo Park",
            "country": "United States",
            "country_code": "us",
            "state": "CA",
            "street": "1 Hacker Way",
            "type": "WORK",
            "zip": "94025"
          }
        ],
        "birthday": "2012-08-18",
        "emails": [
          {
            "email": "kfish@fb.com",
            "type": "WORK"
          }
        ],
        "ims": [
          {
            "service": "AIM",
            "user_id": "kfish"
          }
        ],
        "name": {
          "first_name": "Kerry",
          "formatted_name": "Kerry Fisher",
          "last_name": "Fisher"
        },
        "org": {
          "company": "Meta",
          "department": "WhatsApp"
        },
        "phones": [
          {
            "phone": "+1 (650) 555-1234",
            "type": "WORK",
            "wa_id": "16505551234"
          }
        ],
        "urls": [
          {
            "url": "https://www.facebook.com",
            "type": "WORK"
          }
        ]
      }
    ]
  }
}
```

**Media Messages**

```json
{
  "messages": {
    "id": "ABEGkFBXUQRnAgo6xTEQCONO2nW9",
    "from": "90xxxxxxxxxx",
    "timestamp": "1689756449",
    "name": "John Doe",
    "image": {
      "message": null,
      "media_id": "83518734-56a9-4b51-8372-93f1432cfa9b",
      "mime_type": "image/jpeg",
      "sha": "7e18d97d50eea65a50d9fa93db26e1c689da7c7de64d829b22aad38c4f541510"
    },
    "attachments": {
      "images": [
        {
          "url": "https://path/to/file/9oCtWHWxkv4E0PQhtHA4uW4NRinIROKCO8NEae5p.jpeg",
          "name": "9oCtWHWxkv4E0PQhtHA4uW4NRinIROKCO8NEae5p.jpeg",
          "type": "image",
          "aws": true
        }
      ]
    },
    "type": "image"
  }
}
```

**Messages Triggered by WhatsApp Ads**

```json
{
  "messages": {
    "id": "wamid.HBgMOTA1MDU3NTExxxxxxxxxxxxxxx",
    "from": "90xxxxxxxxxx",
    "name": "John Doe",
    "text": "Hello",
    "type": "text",
    "referral": {
      "id": "AD_OR_POST_ID",
      "url": "AD_OR_POST_FB_URL",
      "body": "AD_OR_POST_DESCRIPTION",
      "type": "ad or post",
      "header": "AD_OR_POST_TITLE",
      "media_url": "RAW_MEDIA_URL",
      "media_type": "image or video",
      "thumbnail_url": "RAW_THUMBNAIL_URL"
    },
    "timestamp": "1741867567"
  }
}
```

### Status Updates <a href="#received-messages-examples" id="received-messages-examples"></a>

{% code fullWidth="false" %}

```json
{
  "statuses": {
    "id": "gBEGkFBXUQRnAglM82HET_hbwJs",
    "from": "90xxxxxxxxxx",
    "status": "delivered|read"
  }
}
```

{% endcode %}

&#x20;                                                     [<mark style="color:blue;">**Homepage**</mark>](https://desk360.com/)                                         [ ](https://desk360.com/pricing)[<mark style="color:blue;">**Pricing**</mark>](https://desk360.com/pricing)
