> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getraya.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getraya.app/_mcp/server.

# Initiate a call

POST https://v1.getraya.app/api/call
Content-Type: application/json

Initiates a call using the specified agent. Requires API key authentication. Call initiation is rate limited per API key (default: 1 per 20 seconds; configurable per key). Other endpoints: 1 request per second per API key. Request body may include agent\_args as a JSON object \{} (e.g. \{"contact\_name": "John", "order\_id": "123"}); agent\_args is not an array.

**Calling hours.** An immediate call (no `scheduled_at`) is placed only between 09:05 and 20:55 local time of the called number's country; for a country with several time zones the window must hold in all of them. Outside it the request gets a 400 with `code: "OUTSIDE_CALLING_HOURS"` and `next_allowed_at` (ISO time when it would be allowed). Scheduled calls are not affected. Accounts that need other hours can ask us to switch this off.

Reference: https://docs.getraya.app/api-reference/calls/initiate-a-call

## Authentication

- `X-API-Key` header (required) — API key for authentication. Example: raya_ABCD1234567890abcdef

## Request

### Body (application/json)

This endpoint expects a CallRequest.

- `agent_id` (string, required) — The agent ID to use for the call
- `to_number` (string, required) — Phone number - must be exactly 10 digits
- `agent_args` (map from string to any, optional) — Optional JSON object with agent-specific arguments (e.g. contact\_name, order\_id). Must be an object , not an array.
- `out_did` (string, optional) — Outbound DID (must be assigned to the customer)
- `country_code` (string, optional, default: 91) — Country code (only "91" is currently supported, defaults to "91")
- `timezone` (string, optional, default: Asia/Kolkata) — IANA timezone (e.g., "Asia/Kolkata" for IST, defaults to "Asia/Kolkata")

## Response

### 200

Call initiated successfully

- `message` (string, required)
- `uuid` (string, required) — The UUID of the originated call

## Errors

### 400 Bad Request Error

Validation error

- `error` (string, optional)
- `message` (string, optional)

### 401 Unauthorized Error

Unauthorized - Invalid or missing API key

- `error` (string, optional)
- `message` (string, optional)

### 429 Too Many Requests Error

Rate limit exceeded or Concurrency limit exceeded

- `InitiateACallRequestTooManyRequestsError`
  - RateLimitError: RateLimitError
  - ConcurrencyLimitError: ConcurrencyLimitError

### 500 Internal Server Error

Internal server error

- `error` (string, optional)
- `message` (string, optional)

## Types

### RateLimitError

- `error` (string, optional)
- `message` (string, optional)
- `retry_after` (double, optional) — Seconds to wait before retrying

### ConcurrencyLimitError

- `error` (string, optional)
- `message` (string, optional)
- `pending_calls` (double, optional) — Number of currently pending calls
- `concurrency_limit` (double, optional) — Maximum allowed concurrent calls

## Examples

**Request**

```json
{
  "agent_id": "123e4567-e89b-12d3-a456-426614174000",
  "to_number": "1234567890"
}
```

**Response**

```json
{
  "message": "Call initiated successfully",
  "uuid": "123e4567e89b12d3a456426614174000"
}
```

**SDK Code**

```python
import requests

url = "https://v1.getraya.app/api/call"

payload = {
    "agent_id": "123e4567-e89b-12d3-a456-426614174000",
    "to_number": "1234567890"
}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://v1.getraya.app/api/call';
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"agent_id":"123e4567-e89b-12d3-a456-426614174000","to_number":"1234567890"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://v1.getraya.app/api/call"

	payload := strings.NewReader("{\n  \"agent_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n  \"to_number\": \"1234567890\"\n}")

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

	req.Header.Add("X-API-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://v1.getraya.app/api/call")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"agent_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n  \"to_number\": \"1234567890\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://v1.getraya.app/api/call")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"agent_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n  \"to_number\": \"1234567890\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://v1.getraya.app/api/call', [
  'body' => '{
  "agent_id": "123e4567-e89b-12d3-a456-426614174000",
  "to_number": "1234567890"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://v1.getraya.app/api/call");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"agent_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n  \"to_number\": \"1234567890\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "agent_id": "123e4567-e89b-12d3-a456-426614174000",
  "to_number": "1234567890"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://v1.getraya.app/api/call")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```