# Create an inbound route

`POST https://api.morevoice.ai/v1/inbound_routes`

Adds a rule that answers inbound calls. `target` is required: an assistant, a published flow, a queue, a person or a conference room. The other fields default: enabled, priority 100, any connection, any dialled number and any caller. `match_did` and `match_caller` take an exact number, a prefix ending in `*`, or nothing for any. The next call uses the new rule.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `inbound_routes_create`.

## Parameters

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `Idempotency-Key` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |

## Request body

Optional, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `assistant_request_timeout_ms` | `integer` | no | 200–5000 ms (default 1500): after this, the route's own target answers. |
| `assistant_request_url` | `string \| null` | no | A public https URL asked which assistant answers each matching call (see the assistant-request guide); null turns it off. |
| `connection_id` | `string \| null` | no | `conn_…` ID. |
| `enabled` | `boolean` | no | — |
| `fallback_assistant_id` | `string \| null` | no | `asst_…` ID. |
| `match_caller` | `string` | no | The caller's number: exact, a prefix ending in `*`, or empty for any. |
| `match_did` | `string` | no | The dialled number: exact, a prefix ending in `*`, or empty for any. |
| `name` | `string` | no | — |
| `priority` | `integer` | no | — |
| `stream` | `RouteStreamParamsInput \| null` | no | Your own bot answers the route's calls over a media stream (connect mode), instead of a `target`; null removes it. Needs media streams on your plan. |
| `stream.url` | `string` | yes | Your bot's WebSocket URL (`wss://`). The upgrade is signed with your signing secret (`webhook-id`, `webhook-timestamp`, `webhook-signature` over the path and query). |
| `stream.custom_parameters` | `Record<string, string>` | no | Up to 20 string key/values the receiver gets in `start.customParameters` (as Twilio's stream parameters). |
| `stream.format` | `"mulaw_8000" \| "l16_16000" \| "l16_8000"` | no | `mulaw_8000` (the default): G.711 μ-law at 8 kHz, Twilio's; `l16_16000` / `l16_8000`: signed 16-bit PCM, little-endian. |
| `stream.language` | `"he" \| "en"` | no | The language of what the platform itself says on the call: the AI disclosure before your bot hears the caller, and the apology if your bot drops with no fallback (default: the fallback assistant's, else Hebrew). |
| `stream.transcribe` | `boolean` | no | Also transcribe the caller and your bot (default false: the call is recorded, with no transcript). |
| `target` | `RouteTargetParamsInput` | no | Where a matching call goes: `type`, and the ID in `<type>_id`. |
| `target.type` | `"assistant" \| "flow" \| "queue" \| "user" \| "conference_room"` | yes | What answers: `assistant` — an AI assistant answers; `flow` — a published voice flow (IVR) runs; `queue` — the call waits in a queue for a human agent; `user` — one person's direct line (their forwarding rules apply); `conference_room` — a conference room (PIN prompt, then join). The ID goes in the field `<type>_id`. |
| `target.assistant_id` | `string` | no | With `type: assistant`. |
| `target.conference_room_id` | `string` | no | With `type: conference_room`. |
| `target.flow_id` | `string` | no | With `type: flow` (a published voice flow). |
| `target.queue_id` | `string` | no | With `type: queue`. |
| `target.user_id` | `string` | no | With `type: user`. |

Example:

```json
{
  "fallback_assistant_id": "asst_3cYbE6uYvGkH8w4ZK1rTqd",
  "match_did": "+97231234567",
  "name": "Sales line",
  "target": {
    "queue_id": "q_4Gk2LmN9pQ4rS6tV8wX0yZ",
    "type": "queue"
  }
}
```

## Responses

### 201 Created

The new route. Returns `InboundRoute`.

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The route's ID. |
| `object` | `"inbound_route"` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `enabled` | `boolean` | — |
| `priority` | `integer` | Lower runs first; the first matching route wins. |
| `connection_id` | `string \| null` | `conn_…` ID. |
| `match_did` | `string` | The dialled number: exact, a prefix ending in `*`, or empty for any. |
| `match_caller` | `string` | The caller's number: exact, a prefix ending in `*`, or empty for any. |
| `target` | `RouteTarget \| null` | Where matching calls go (null: the connection's inbound assistant answers). |
| `target.type` | `"assistant" \| "flow" \| "queue" \| "user" \| "conference_room"` | What answers: `assistant` — an AI assistant answers; `flow` — a published voice flow (IVR) runs; `queue` — the call waits in a queue for a human agent; `user` — one person's direct line (their forwarding rules apply); `conference_room` — a conference room (PIN prompt, then join). The ID goes in the field `<type>_id`. |
| `target.assistant_id` | `string` | With `type: assistant`. |
| `target.conference_room_id` | `string` | With `type: conference_room`. |
| `target.flow_id` | `string` | With `type: flow`. |
| `target.queue_id` | `string` | With `type: queue`. |
| `target.user_id` | `string` | With `type: user`. |
| `fallback_assistant_id` | `string \| null` | `asst_…` ID. |
| `assistant_request_url` | `string \| null` | When set, this URL is asked (a signed POST, `assistant.request`) which assistant, flow or queue answers each matching call, and with which variables; the route's own target answers when it does not reply in time. Null: off. |
| `assistant_request_timeout_ms` | `integer` | How long the assistant request may take (200–5000 ms) before the route's own target answers. |
| `stream` | `RouteStream \| null` | When set, your own bot answers the route's calls over a media stream (connect mode) and `target` is null; `fallback_assistant_id` takes the calls your bot can't (unreachable, or it drops). Null: off. |
| `stream.url` | `string` | — |
| `stream.format` | `"mulaw_8000" \| "l16_16000" \| "l16_8000"` | — |
| `stream.custom_parameters` | `Record<string, string>` | — |
| `stream.transcribe` | `boolean` | — |
| `stream.language` | `"he" \| "en" \| null` | — |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

Example:

```json
{
  "assistant_request_timeout_ms": 1500,
  "assistant_request_url": null,
  "connection_id": "conn_2Wq8RfLx0bZt7nKp1VdYhC",
  "created": "2026-11-03T09:14:22.000Z",
  "enabled": true,
  "fallback_assistant_id": "asst_3cYbE6uYvGkH8w4ZK1rTqd",
  "id": "rte_5Hn3MpO0qR5sT7uW9xY1zA",
  "livemode": true,
  "match_caller": "",
  "match_did": "+97231234567",
  "name": "Sales line",
  "object": "inbound_route",
  "priority": 100,
  "stream": null,
  "target": {
    "queue_id": "q_4Gk2LmN9pQ4rS6tV8wX0yZ",
    "type": "queue"
  }
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID (in the path or the body) exists in this organisation and mode. Returns `ErrorEnvelope`.

### 409 Conflict

The request conflicts with the object's state, or the Idempotency-Key was reused with other parameters. Returns `ErrorEnvelope`.

### 413 Payload Too Large

The request body is larger than the endpoint accepts, or has more parts or files than it takes. Returns `ErrorEnvelope`.

### 415 Unsupported Media Type

The request body's Content-Type is not one the endpoint takes. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const inboundRoute = await mv.inboundRoutes.create({
	fallback_assistant_id: "asst_3cYbE6uYvGkH8w4ZK1rTqd",
	match_did: "+97231234567",
	name: "Sales line",
	target: {
		queue_id: "q_4Gk2LmN9pQ4rS6tV8wX0yZ",
		type: "queue",
	},
});
console.log(inboundRoute);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

inbound_route = client.inbound_routes.create({
    "fallback_assistant_id": "asst_3cYbE6uYvGkH8w4ZK1rTqd",
    "match_did": "+97231234567",
    "name": "Sales line",
    "target": {
        "queue_id": "q_4Gk2LmN9pQ4rS6tV8wX0yZ",
        "type": "queue",
    },
})
print(inbound_route)
```

**cURL**

```sh
curl -X POST https://api.morevoice.ai/v1/inbound_routes \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "fallback_assistant_id": "asst_3cYbE6uYvGkH8w4ZK1rTqd",
  "match_did": "+97231234567",
  "name": "Sales line",
  "target": {
    "queue_id": "q_4Gk2LmN9pQ4rS6tV8wX0yZ",
    "type": "queue"
  }
}'
```
