Skip to main content
POST
/
v2
/
create-phone-call
Create an outbound phone call
curl --request POST \
  --url https://api.openmic.ai/v2/create-phone-call \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "from_number": "+12025551234",
  "to_number": "+14155559876",
  "dynamic_variables": {
    "customer_name": "John Doe",
    "order_id": "ORD-8821"
  },
  "callback_url": "https://yourapp.com/webhooks/call-status"
}
'
import requests

url = "https://api.openmic.ai/v2/create-phone-call"

payload = {
    "from_number": "+12025551234",
    "to_number": "+14155559876",
    "dynamic_variables": {
        "customer_name": "John Doe",
        "order_id": "ORD-8821"
    },
    "callback_url": "https://yourapp.com/webhooks/call-status"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    from_number: '+12025551234',
    to_number: '+14155559876',
    dynamic_variables: {customer_name: 'John Doe', order_id: 'ORD-8821'},
    callback_url: 'https://yourapp.com/webhooks/call-status'
  })
};

fetch('https://api.openmic.ai/v2/create-phone-call', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.openmic.ai/v2/create-phone-call",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'from_number' => '+12025551234',
    'to_number' => '+14155559876',
    'dynamic_variables' => [
        'customer_name' => 'John Doe',
        'order_id' => 'ORD-8821'
    ],
    'callback_url' => 'https://yourapp.com/webhooks/call-status'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

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

func main() {

	url := "https://api.openmic.ai/v2/create-phone-call"

	payload := strings.NewReader("{\n  \"from_number\": \"+12025551234\",\n  \"to_number\": \"+14155559876\",\n  \"dynamic_variables\": {\n    \"customer_name\": \"John Doe\",\n    \"order_id\": \"ORD-8821\"\n  },\n  \"callback_url\": \"https://yourapp.com/webhooks/call-status\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.openmic.ai/v2/create-phone-call")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"from_number\": \"+12025551234\",\n  \"to_number\": \"+14155559876\",\n  \"dynamic_variables\": {\n    \"customer_name\": \"John Doe\",\n    \"order_id\": \"ORD-8821\"\n  },\n  \"callback_url\": \"https://yourapp.com/webhooks/call-status\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.openmic.ai/v2/create-phone-call")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"from_number\": \"+12025551234\",\n  \"to_number\": \"+14155559876\",\n  \"dynamic_variables\": {\n    \"customer_name\": \"John Doe\",\n    \"order_id\": \"ORD-8821\"\n  },\n  \"callback_url\": \"https://yourapp.com/webhooks/call-status\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "from_number": "<string>",
  "to_number": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "agent_uid": "<string>",
  "customer_id": "<string>",
  "dynamic_variables": {},
  "callback_url": "<string>"
}
{
  "error": "<string>",
  "details": "<string>"
}
{
  "error": "<string>",
  "details": "<string>"
}
{
  "error": "<string>",
  "details": "<string>"
}
{
  "success": true,
  "message": "<string>",
  "error": "<string>",
  "retryAfter": 123
}
{
  "error": "<string>",
  "details": "<string>"
}

Authorizations

Authorization
string
header
required

API key obtained from the OpenMic dashboard.

Body

application/json
from_number
string
required

E.164 format caller number (e.g. +12025551234).

Pattern: ^\+[1-9]\d{1,14}$
to_number
string
required

E.164 format destination number.

Pattern: ^\+[1-9]\d{1,14}$
override_agent_uid
string

Override the default agent assigned to the from_number.

customer_id
string

Your internal customer reference. Stored with the call record.

dynamic_variables
object

Key-value pairs injected into the agent prompt as template variables at call time.

callback_url
string<uri>

Webhook URL called with call status updates.

Response

Call created and queued.

id
string
required

CUID call identifier.

from_number
string
required
to_number
string
required
call_status
enum<string>
required
Available options:
registered,
ongoing,
ended,
error
created_at
string<date-time>
required
updated_at
string<date-time>
required
call_type
enum<string>
Available options:
phonecall,
webcall
agent_uid
string
customer_id
string
dynamic_variables
object
callback_url
string