> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cartesia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SIP トランキング（ベータ）

> SIP トランクを接続して、独自のキャリアを Cartesia エージェントで使用します。

## SIP トランキングの仕組み

SIP トランキングを利用すると、既存のテレフォニーインフラを Cartesia Agents に直接接続できます。

**インバウンド通話** — トランクからのトラフィックは Cartesia の SIP エンドポイントに送信されます。番号へのインバウンド通話は、その番号に割り当てられたエージェントにルーティングされます。

**アウトバウンド通話** — Cartesia はトランクの SIP ホスト名経由で通話を発信するため、発信通話には利用中のキャリアと発信者番号（Caller ID）が使用されます。

**認証** — ダイジェスト認証（ユーザー名とパスワード）や、特定の送信元 IP のみを許可することで、トラフィックの送信元を制限できます。

**シグナリングとメディア** — 通話設定（シグナリング）には TCP または TLS を使用します。暗号化されたシグナリングが必要な場合は TLS を使用してください。通話が確立された後、RTP 音声は `media_encryption` 設定（`disabled`、`allowed`、または `required`）に従って暗号化できます。

## PSTN プロバイダーの設定

利用中の PSTN プロバイダーの SIP トランク設定で、トランクの向き先を Cartesia の SIP エンドポイントに指定します。キャリアがサポートするトランスポートを選択してください。

* **TCP:** `sip:sip.cartesia.ai;transport=tcp`
* **TLS:** `sip:sip.cartesia.ai;transport=tls`（暗号化されたシグナリング）

## トランクを Cartesia にリンクする

キャリア側でトランクを設定したら、Cartesia に登録します。以下では一部のフィールドが省略されています。すべてのフィールドは [Create Provider](/api-reference/agents/providers/create) を参照してください。

```bash theme={null}
curl -X POST "https://api.cartesia.ai/agents/phone-numbers/providers" \
  -H "X-API-Key: $CARTESIA_API_KEY" \
  -H "Cartesia-Version: 2026-03-01" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "sip_trunk",
    "label": "Primary carrier trunk",
    "inbound": {
      "media_encryption": "allowed"
    },
    "outbound": {
      "address": "abcd1234.pstn.twilio.com",
      "transport": "tls",
      "destination_country": "US",
      "media_encryption": "required",
      "credentials": {
        "username": "cartesia-outbound",
        "password": "your-sip-password"
      }
    }
  }'
```

レスポンスにはプロバイダーの `id` と読み取り専用のトランク詳細が含まれます。パスワードは返されません。Cartesia は設定済みのユーザー名を `auth_username` として公開します。

```json theme={null}
{
  "type": "sip_trunk",
  "id": "ata_P4MgdLf1cpaucZJ7xWehCC",
  "label": "Primary carrier trunk",
  "inbound": {
    "allowed_addresses": [],
    "allowed_numbers": [],
    "auth_username": "",
    "media_encryption": "allowed"
  },
  "outbound": {
    "address": "abcd1234.pstn.twilio.com",
    "destination_country": "US",
    "transport": "tls",
    "media_encryption": "required",
    "auth_username": "example_username"
  }
}
```

## 番号のインポート

前の手順で取得したプロバイダーの `id` を使用して、キャリアの番号をインポートします。すべてのフィールドは [Import Phone Number](/api-reference/agents/phone-numbers/import) を参照してください。

```bash theme={null}
curl -X POST "https://api.cartesia.ai/agents/phone-numbers" \
  -H "X-API-Key: $CARTESIA_API_KEY" \
  -H "Cartesia-Version: 2026-03-01" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Support line",
    "number": "+14155551234",
    "provider": { "id": "ata_P4MgdLf1cpaucZJ7xWehCC" }
  }'
```

想定されるレスポンス:

```json theme={null}
{
  "id": "ap_M3gdLf1cpaucZJ7xWehCCa",
  "label": "Support line",
  "number": "+14155551234",
  "agent": null,
  "provider": {
    "type": "sip_trunk",
    "id": "ata_P4MgdLf1cpaucZJ7xWehCC",
    "label": "Primary carrier trunk"
  }
}
```

## エージェントへの割り当て

インポートした番号をエージェントに割り当てて、インバウンド通話がそのエージェントにルーティングされるようにします。

<Note>
  [import](/api-reference/agents/phone-numbers/import) 時に `agent_id` を渡すことで、同じリクエスト内でエージェントを割り当てることもできます。
</Note>

```bash theme={null}
curl -X PATCH "https://api.cartesia.ai/agents/phone-numbers/ap_M3gdLf1cpaucZJ7xWehCCa" \
  -H "X-API-Key: $CARTESIA_API_KEY" \
  -H "Cartesia-Version: 2026-03-01" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_rwh4HGMgyhK7rM5ucVqbiC"
  }'
```

想定されるレスポンス:

```bash theme={null}
{
  "id": "ap_M3gdLf1cpaucZJ7xWehCCa",
  "label": "Support line",
  "number": "+14155551234",
  "agent": {
    "id": "agent_rwh4HGMgyhK7rM5ucVqbiC",
    "name": "example-agent"
  },
  "provider": {
    "type": "sip_trunk",
    "id": "ata_P4MgdLf1cpaucZJ7xWehCC",
    "label": "Primary carrier trunk"
  }
}
```

割り当てを解除するには、`agent_id` を `null` に設定します。

## アウトバウンド通話の発信

インポートした電話番号を使用してアウトバウンド通話をルーティングします。発信者番号（Caller ID）は最終的にキャリアが決定します。すべてのフィールドは [Create Outbound Call](/api-reference/agents/calls/create-outbound-call) を参照してください。

```bash theme={null}
curl -X POST "https://api.cartesia.ai/agents/calls" \
  -H "X-API-Key: $CARTESIA_API_KEY" \
  -H "Cartesia-Version: 2026-03-01" \
  -H "Content-Type: application/json" \
  -d '{
    "from_number_id": "ap_M3gdLf1cpaucZJ7xWehCCa",
    "agent_id": "agent_rwh4HGMgyhK7rM5ucVqbiC",
    "outbound_calls": [
      {
        "to_number": "+14155559876",
        "metadata": {
          "customer_id": "cust_Na9d9f9xK4mN2pQ7vR8wL"
        }
      }
    ]
  }'
```

想定されるレスポンス:

```bash theme={null}
{"calls":[{"number":"+14155559876","agent_call_id":"ac_gqkgRWUz2u64qFUjA1mZyr"}]}
```

レスポンスには宛先ごとに通話 ID が含まれます。通話ステータスを監視するには [Get Call](/api-reference/agents/calls/get-call) を使用してください。
