# Make an outbound phone call V2

<mark style="color:green;">`POST`</mark> `https://app.ringly.io/api/1.1/wf/make-outbound-call-v2`

***

### Headers

&#x20;You can find your Ringly.io API key in Settings > API key and then generate an API key.

<table data-full-width="false"><thead><tr><th>Name</th><th>Value</th></tr></thead><tbody><tr><td><strong>Content-Type</strong></td><td><code>application/json</code></td></tr><tr><td><strong>Authorization</strong></td><td><code>&#x3C;Your Ringly.io API key></code></td></tr></tbody></table>

{% hint style="success" %}
**What is new in V2?** Instead of just sending the customer name, you can now send as many info as you like to use in the phone call with the new dynamic\_variables!
{% endhint %}

### Body

***

**`from_number`** <mark style="color:yellow;">string</mark> <mark style="color:red;">required</mark>

A phone number you own in Ringly.io, in E.164 format. Example: "`+12153331234`".

***

**`to_number`** <mark style="color:yellow;">string</mark>  <mark style="color:red;">required</mark>

The number you want to call, in E.164 format. Example: "`+12153331234`".

***

**`agent_tag`** <mark style="color:yellow;">string</mark>  <mark style="color:red;">required</mark>

The tag of one your AI phone agents. Does not need to have a phone number, as long as the 'from\_number' is yours. Example: "`agent_124532h23i5ad2543b3289bsj3`". You can find the `agent_tag` by going to your agent, and scroll all the way down. Note: not all `agent_tag`'s start with "`agent_`"

***

**`dynamic_variables`** <mark style="color:yellow;">object</mark> <mark style="color:green;">optional</mark>

Add dynamic variables in key-value pairs of string that you can use in the phone call.

Example: *"Hey, am I speaking with {{customer\_name}} from the {{property}} at {{address}}?"*

Ringly.io automatically replace the variables with the actual values: "*Hey, am I speaking with Ruben from the apartment at Fifth Avenue 138?"*

{% hint style="info" %}
Keys in dynamic\_variables must use only letters and underscores: `customer_name` (No spaces or special characters).

When adding it to your agent's instructions or greeting, add 2 curly braces around it: `{{customer_name}}`
{% endhint %}

***

### Example requests

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

```sh
curl --request POST \
  --url https://app.ringly.io/api/1.1/wf/make-outbound-call-v2 \
  --header 'Authorization: Your_Ringly_API_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "from_number": "+1234567890",
  "to_number": "+19876543210",
  "agent_tag": "agent_1234abcd",
  "dynamic_variables": {
      "customer_name": "Jack",
      "property": "apartment",
      "address": "Fifth Avenue 138",
      "company_name": "Ringly.io",
      "outstanding_payment": "$3605.20"
   }
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://app.ringly.io/api/1.1/wf/make-outbound-call-v2"

payload = {
    "from_number": "+1234567890",
    "to_number": "+19876543210",
    "agent_tag": "agent_1234abcd",
    "dynamic_variables": {
      "customer_name": "Jack",
      "property": "apartment",
      "address": "Fifth Avenue 138",
      "company_name": "Ringly.io",
      "outstanding_payment": "$3605.20"
   }
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Your_Ringly_API_key"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'
require 'uri'
require 'json'

url = URI.parse("https://app.ringly.io/api/1.1/wf/make-outbound-call-v2")

payload = {
  from_number: "+1234567890",
  to_number: "+19876543210",
  agent_tag: "agent_1234abcd",
  dynamic_variables: {
    customer_name: "Jack",
    property: "apartment",
    address: "Fifth Avenue 138",
    company_name: "Ringly.io",
    outstanding_payment: "$3605.20"
  }
}

headers = {
  "Content-Type" => "application/json",
  "Authorization" => "Bearer Your_Ringly_API_key"
}

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

request = Net::HTTP::Post.new(url.path, headers)
request.body = payload.to_json

response = http.request(request)
puts JSON.parse(response.body)

```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const url = "https://app.ringly.io/api/1.1/wf/make-outbound-call-v2";

const payload = {
  from_number: "+1234567890",
  to_number: "+19876543210",
  agent_tag: "agent_1234abcd",
  dynamic_variables: {
    customer_name: "Jack",
    property: "apartment",
    address: "Fifth Avenue 138",
    company_name: "Ringly.io",
    outstanding_payment: "$3605.20"
  }
};

const headers = {
  "Content-Type": "application/json",
  Authorization: "Your_Ringly_API_key"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));

```

{% endtab %}
{% endtabs %}

### Response

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

```json
{
  "from_number": "+12137771234",
  "to_number": "+12137771235",
  "agent_tag": "agent_b7893d54b31985d73b459",
  "call_status": "registered",
  "dynamic_variables": {
      "customer_name": "Jack",
      "property": "apartment",
      "address": "Fifth Avenue 138",
      "company_name": "Ringly.io",
      "outstanding_payment": "$3605.20",
   }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error_message": "Invalid request format, please check API reference."
}
```

{% endtab %}

{% tab title="401" %}

```json
{ 
  "error_message": "API key is missing or invalid." 
}
```

{% endtab %}

{% tab title="402" %}

```json
{ 
  "error_message": "Trial has ended, please add payment method." 
}
```

{% endtab %}

{% tab title="422" %}

<pre class="language-json"><code class="lang-json">{ 
<strong>  "error_message": "Cannot find requested asset under given api key." 
</strong>}
</code></pre>

{% endtab %}

{% tab title="429" %}

<pre class="language-json"><code class="lang-json">{ 
<strong>  "error_message": "Account rate limited, please throttle your requests." 
</strong>}
</code></pre>

{% endtab %}

{% tab title="500" %}

```json
{ 
  "error_message": "An unexpected server error occurred."
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Make sure you adhere to local laws and regulations when making outbound phone calls. Read our [Terms of Service](https://www.ringly.io/terms-of-service) for more.
{% endhint %}
