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

# 발신 전화 생성

POST https://api.claw-ops.com/v1/accounts/{accountId}/calls
Content-Type: application/json

아웃바운드 전화를 발신합니다. From 번호는 계정에 등록된 번호여야 합니다.

**전화 발신**: To에 전화번호를 입력하면 일반 전화로 발신됩니다.

* 예: `"To": "01012345678"`

**매니지드 에이전트**: `AgentId`를 지정하면 콘솔에서 만든 AI 에이전트가 통화를 처리합니다.
이때 `CallContext`로 **이번 통화에만** 적용되는 요구사항(`Instruction`)과 참조 데이터
(`Variables`)를 얹을 수 있습니다. 콘솔에 저장된 에이전트 설정은 바뀌지 않으므로 같은
에이전트로 동시에 거는 다른 통화에는 영향이 없습니다. `AgentId` 모드 전용이라 다른
모드와 함께 보내면 400으로 거절됩니다.

**Agent SDK**: `Url`, `AgentId`, `CallFlowId`를 모두 생략하면 From 번호에 연결된
Agent SDK로 통화가 연결됩니다. Agent가 연결되어 있지 않으면 409 에러를 반환합니다.

`Url`, `AgentId`, `CallFlowId`는 서로 배타적입니다. `201 Created`는 발신 요청이
큐에 들어갔다는 뜻이며 통화 연결 성공을 뜻하지 않습니다. 반환된 `callId`를
`GET /v1/accounts/{accountId}/calls/{callId}`로 조회해 최종 상태를 확인하세요.

**AI Completion 모드는 종료되었습니다.** AI 필드를 포함한 요청은 410으로 거절됩니다.
Url(VoiceML), AgentId, CallFlowId 또는 Agent SDK를 사용하세요.

Reference: https://docs.claw-ops.com/api-레퍼런스/claw-ops-api/calls/create-call

## Authentication

- `Authorization` header (bearer token, required) — API Key를 Bearer 토큰으로 전달

## Request

### Path parameters

- `accountId` (string, required) — 계정 ID

### Body (application/json)

- `To` (string, required) — 수신 전화번호
- `From` (string, required) — 발신 번호 (계정에 등록된 번호)
- `Url` (string, optional) — 통화 연결 시 VoiceML을 반환할 URL. AgentId·CallFlowId와 배타.
- `AgentId` (string, optional) — 콘솔에서 만든 매니지드 에이전트 ID. Url·CallFlowId와 배타.
- `CallContext` (object, optional) — AgentId 에이전트의 이번 통화에만 적용되는 컨텍스트.
  - `Instruction` (string, required) — 이번 통화에서 수행할 실행 요구사항.
  - `Variables` (map from string to string or double or boolean, optional) — 요구사항에서 참조할 통화별 구조화 데이터.
- `CallFlowId` (string, optional) — 콜 플로우(결정적 ARS) ID. 지정하면 그 플로우가 통화를 진행합니다. Url·AgentId와 동시에 사용할 수 없습니다. ID는 `GET /v1/accounts/{accountId}/call-flows`로 조회합니다.
- `Variables` (map from string to string or double or boolean, optional) — 콜 플로우 시작 변수. 멘트·URL·본문의 `{{이름}}`이 이 값으로 치환됩니다. CallFlowId와 함께일 때만 사용할 수 있습니다(단독 지정 시 400). 값은 문자열로 정규화되며 숫자·불리언도 허용합니다. 이름은 영문/숫자/밑줄이어야 하고 숫자로 시작할 수 없습니다. 최대 50개, 전체 8KB. `caller`·`callee`·`recording_url`·`recording_duration`·`http_status`는 통화 중 자동으로 채워지는 예약 변수라 지정할 수 없습니다(400). 지정하지 않은 `{{변수}}`는 빈 문자열로 치환됩니다.
- `Timeout` (integer, optional) — 벨 대기 시간 (초). 상대가 받지 않으면 이 시간 뒤 `no-answer` 로 종료됩니다. 미지정이거나 유효하지 않으면 30초, 600초를 넘으면 600초로 제한됩니다.
- `StatusCallback` (string, optional) — 통화 상태 변경 시 콜백을 받을 URL
- `StatusCallbackEvent` (string, optional) — 수신할 상태 이벤트 목록 (공백 구분). 기본값: initiated ringing answered completed
- `MachineDetection` (enum, optional) — 자동응답기/음성사서함 감지(AMD). Enable=감지 후 AnsweredBy 통보(통화 계속), Hangup=음성사서함이면 자동 종료. 미설정 시 비활성(기본).
  - Allowed values: `Enable`, `Hangup`

## Response

### 201

발신 요청이 큐에 등록됨. 실제 연결 여부는 반환된 callId를 조회해 확인합니다.

- `callId` (string, optional)
- `status` (enum, optional) — 통화 상태. 진행 중: queued(발신 대기) / ringing(벨) / in-progress(통화 중). 종료 상태(실제 종료 사유): completed(응답 후 정상 종료) / no-answer(벨은 울렸으나 무응답, Timeout 초과로 발신 취소) / busy(통화중) / rejected(수신 거절) / canceled(응답 전 발신 측 취소) / failed(시스템·망 오류). completed 만이 통화가 실제로 연결됐음을 의미합니다.
  - Allowed values: `queued`, `ringing`, `in-progress`, `completed`, `failed`, `busy`, `no-answer`, `canceled`, `rejected`
- `to` (string, optional)
- `from` (string, optional)
- `direction` (enum, optional)
  - Allowed values: `outbound`, `inbound`
- `duration` (integer, optional, nullable) — 통화 시간 (초)
- `accountId` (string, optional)
- `answeredBy` (enum, optional, nullable) — AMD(MachineDetection) 결과. MachineDetection 을 켠 발신 통화에만 값이 있으며, 사람 응답=human, 자동응답기/음성사서함=machine, 판정 불가=unknown. 미사용 시 null.
  - Allowed values: `human`, `machine`, `unknown`
- `recordingUrl` (string, optional, nullable) — 녹음 다운로드 경로 (녹음이 있는 통화만)
- `hangupCause` (string, optional, nullable) — 통화 종료 사유. `status` 가 왜 그렇게 끝났는지를 구분합니다. 종료 전이거나 사유 미상이면 null. 네 갈래로 나뉩니다 — 번호 자체가 문제라 재시도해도 소용없는 것(`invalid_number` 등), 일시적이라 재시도 가치가 있는 것(`no_answer`·`user_busy` 등), 번호가 아니라 **계정** 문제인 것(`concurrency_limit_exceeded`·`subscription_inactive` 등), ClawOps 측 오류 (`app_error`·`call_stuck`). **전체 목록과 재시도 판단 기준은 [통화 실패 사유](/docs/call-failure-causes) 가 정본입니다.** 여기 값을 나열하지 않는 이유: 사유가 늘 때마다 spec·문서·대시보드가 각각 갱신돼야 하는데 한 곳만 빠지면 조용히 어긋난다(실제로 그렇게 어긋난 적이 있다).
- `hangupCauseQ850` (integer, optional, nullable) — 통신망 Q.850 cause code. 1·5·28=결번, 16=정상해제, 17=통화중, 18/19/20=무응답, 21=거절, 38=망장애. 사유 미상이면 null.
- `sipResponseCode` (integer, optional, nullable) — 종료를 유발한 SIP 응답코드 (404=없는 번호, 486=통화중, 500=망 오류 등). 응답코드 없이 끝났으면 null.
- `hangupSource` (enum, optional, nullable) — 종료 책임 주체. carrier(통신망) / callee(수신자) / caller(발신자) / app·system(ClawOps 측 오류 — 이 경우 재시도를 권장합니다).
  - Allowed values: `carrier`, `callee`, `caller`, `app`, `system`
- `transferTo` (string, optional, nullable) — 통화 전환 대상 번호 (전환이 없으면 null)
- `transferStatus` (enum, optional, nullable) — 통화 전환 결과
  - Allowed values: `completed`, `failed`, `no-answer`, `busy`, `canceled`
- `transferDuration` (integer, optional, nullable) — 전환 후 통화 시간 (초)
- `transferHangupCauseQ850` (integer, optional, nullable) — 전환 leg 의 통신망 Q.850 cause (예: 16=정상해제, 17=통화중, 19=무응답, 21=거절, 38=망장애). 통신망이 SIP 5xx 로 보낸 실패의 실제 사유로 교정된 값. 사유 미상이면 null.
- `transferSipResponseCode` (integer, optional, nullable) — 전환 leg 의 실제 SIP 응답코드 (예 500). 사유 미상이면 null.
- `transferReasonText` (string, optional, nullable) — 전환 실패 원본 진단 텍스트. 사유 미상이면 null.
- `transfers` (list of object, optional) — 전환 leg 정본 체인(sequence 순). 다단계/재시도 전환의 전체 이력을 제공한다. 위 transfer* 단일 필드는 하위호환용 대표 leg(마지막 completed). 단건 조회에만 포함되며(리스트 응답엔 생략), 전환이 없었던 통화는 빈 배열.
  - `sequence` (integer, optional) — 통화 내 전환 순번(1부터)
  - `to` (string, optional, nullable)
  - `mode` (string, optional, nullable) — blind | warm | refer
  - `destinationType` (string, optional, nullable) — pstn | sip | number
  - `status` (string, optional, nullable) — initiated|ringing|connected|completed|failed|no-answer|busy|canceled|interrupted
  - `duration` (integer, optional, nullable) — connected→종료 초(관측용)
  - `billable` (boolean, optional) — 과금 대상 여부(통화당 대표 leg 1건만 true)
  - `billableDuration` (integer, optional, nullable) — 과금 대상 초(completed 대표 leg 만)
  - `hangupCauseQ850` (integer, optional, nullable)
  - `sipResponseCode` (integer, optional, nullable)
  - `reasonText` (string, optional, nullable)
  - `startedAt` (datetime, optional, nullable)
  - `connectedAt` (datetime, optional, nullable)
  - `endedAt` (datetime, optional, nullable)
- `dateCreated` (datetime, optional)
- `dateUpdated` (datetime, optional, nullable) — 통화 종료 시각

## Examples

**Request**

```json
{
  "To": "01012345678",
  "From": "07052358010"
}
```

**Response**

```json
{
  "callId": "CAabcdef1234567890",
  "status": "queued",
  "to": "01012345678",
  "from": "07052358010",
  "direction": "outbound",
  "duration": 30,
  "accountId": "AC1a2b3c4d",
  "answeredBy": "human",
  "recordingUrl": "/v1/accounts/AC1a2b3c4d/recordings/CAabcdef1234567890",
  "hangupCause": "invalid_number",
  "hangupCauseQ850": 1,
  "sipResponseCode": 404,
  "hangupSource": "carrier",
  "transferTo": "01012345678",
  "transferStatus": "completed",
  "transferDuration": 60,
  "transferHangupCauseQ850": 16,
  "transferSipResponseCode": 500,
  "transferReasonText": "CS_NORMAL_RELEASE",
  "transfers": [
    {
      "sequence": 1,
      "to": "string",
      "mode": "string",
      "destinationType": "string",
      "status": "string",
      "duration": 1,
      "billable": true,
      "billableDuration": 1,
      "hangupCauseQ850": 1,
      "sipResponseCode": 1,
      "reasonText": "string",
      "startedAt": "2024-01-15T09:30:00Z",
      "connectedAt": "2024-01-15T09:30:00Z",
      "endedAt": "2024-01-15T09:30:00Z"
    }
  ],
  "dateCreated": "2024-01-15T09:30:00Z",
  "dateUpdated": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls"

payload = {
    "To": "01012345678",
    "From": "07052358010"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"To":"01012345678","From":"07052358010"}'
};

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://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls"

	payload := strings.NewReader("{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\"\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(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls")

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  \"To\": \"01012345678\",\n  \"From\": \"07052358010\"\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://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls', [
  'body' => '{
  "To": "01012345678",
  "From": "07052358010"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "To": "01012345678",
  "From": "07052358010"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/calls")! 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()
```