# Source: https://docs.avaamo.com/user-guide/ref/avaamo-platform-api-documentation/sms-send-api.md

# SMS Send API

{% hint style="success" %}
**Pre-requisite**: You must have an agent with the SMS channel configured. See [SMS channel](https://docs.avaamo.com/user-guide/how-to/build-agents/configure-agents/deploy/sms), for more information.
{% endhint %}

<mark style="color:green;">`POST`</mark> `https://cx.avaamo.com/sms/{{channel_uuid}}/send.json`

Send the agent's greeting message as an SMS to the specified phone number.

#### Path Parameters

| Name          | Type   | Description                                                                                                                                                                                                                                                                                                              |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| channel\_uuid | String | <p>Unique channel identifier generated by the Platform when the SMS channel is configured. </p><p></p><p>This helps to identify the source of the request when an SMS is sent to the user using this API. See <a href="../../how-to/build-agents/configure-agents/deploy/sms">SMS channel</a>, for more information.</p> |

#### Request Body

| Name                | Type                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| to\_phone           | String               | <p>Complete phone number of the user with the country code to which the SMS is sent. </p><p></p><p>Required, if custom user authentication is not enabled in the SMS channel. </p><p></p><p>If custom user authentication is enabled, then you must return <code>to\_phone</code> number along with <code>uuid</code> in the  <strong>User authentication handler</strong> block<strong>.</strong> This provides flexibility to the developers to authenticate the users and then return the phone number to which the SMS must be sent. See <a href="../../../how-to/build-agents/configure-agents/define-settings#sms-channel">User authentication handler</a>, for more information.</p> |
| <\<custom\_params>> | JSON key-value pairs | <p>Any custom parameters such as the first name, last name, and employee id can be included in the body payload as per the requirement. </p><p></p><p>These parameters are available in <code>context.params.<\<custom\_param>></code> and can be used for authenticating the users in the <strong>User authentication handler</strong> when custom user authentication is enabled in the SMS channel.  See <a href="../../../how-to/build-agents/configure-agents/define-settings#user-authentication-handler">User authentication handler</a>, for more information.</p>                                                                                                                  |

{% tabs %}
{% tab title="200: OK Successful request. " %}

```javascript
{
    "success": true
}  

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note**:  After a successful request, a conversation is established and can be tracked using `to_phone` number from the Conversation history page. See [Conversation history](https://docs.avaamo.com/user-guide/how-to/build-agents/debug-agents/conversation-history), for more information.
{% endhint %}

### Code request snippets

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --location --request POST 'https://cx.avaamo.com/sms/3ad87fb7-c43e-4f00-8441-xxxxx/send.json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "first_name": "John",
    "last_name": "Jacob",
    "emp_id": "1234",
    "to_phone": "+1 (xxx) xxx-xxxx"
  }'
```

{% endcode %}
{% endtab %}

{% tab title="node.js" %}
{% code overflow="wrap" %}

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://cx.avaamo.com/sms/3ad87fb7-c43e-4f00-8441-xxxxx/send.json',
  'headers': {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "first_name": "John",
    "last_name": "Jacob",
    "emp_id": "1234",
    "to_phone": "+1 (xxx) xxx-xxxx"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Examples

**Request**: The following is a sample JSON request for posting a simple message to the agent:

```yaml
{
  "first_name": "John",
  "last_name": "Jacob",
  "emp_id": "1234",
  "to_phone": "+1 (xxx) xxx-xxxx"
}
```