# client.inbound_routes

> The inbound_routes methods of the morevoice Python SDK: How inbound calls to your numbers are routed.

How inbound calls to your numbers are routed. These methods are on `client.inbound_routes`, where `client` is a `MoreVoice` client (see [the Python SDK](https://docs.morevoice.ai/sdk/python/#connect)). On `AsyncMoreVoice` the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

## `create()`

**Create an inbound route.** 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.

```python
# client.inbound_routes
def create(self, body: _m.InboundRouteCreateParamsInput | Mapping[str, Any], *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.InboundRoute
```

`client.inbound_routes.create()` · `await async_client.inbound_routes.create()` · `POST /inbound_routes` · [API reference](https://docs.morevoice.ai/api/operations/inbound_routes_create/)

### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `target` | `RouteTargetParamsInput` | yes | Where a matching call goes: `type`, and the ID in `<type>_id`. |
| `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 | — |

### Returns

`InboundRoute`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The route's ID. |
| `object` | `"inbound_route"` | Always `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). |
| `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. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```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)
```

## `delete()`

**Delete an inbound route.** Deletes an inbound route. Calls already in progress are not affected; the next call is routed by the remaining rules.

```python
# client.inbound_routes
def delete(self, id: str, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.DeletedInboundRoute
```

`client.inbound_routes.delete()` · `await async_client.inbound_routes.delete()` · `DELETE /inbound_routes/{id}` · [API reference](https://docs.morevoice.ai/api/operations/inbound_routes_delete/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A inbound route ID (`rte_…`). |

### Returns

`DeletedInboundRoute`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | A inbound route ID (prefix `rte_`). |
| `object` | `"inbound_route"` | Always `inbound_route`. |
| `deleted` | `true` | — |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

deleted_inbound_route = client.inbound_routes.delete("rte_7Hk2Lm9Qp")
print(deleted_inbound_route)
```

## `list()`

**List inbound routes.** Your routes in evaluation order: priority, then age. The first enabled route that matches a call wins.

```python
# client.inbound_routes
def list(self, *, limit: int | Unset = 20, starting_after: str | Unset = UNSET, ending_before: str | Unset = UNSET, more_voice_version: str | Unset = UNSET) -> AsyncPage[_m.InboundRoute]
```

`client.inbound_routes.list()` · `await async_client.inbound_routes.list()` · `GET /inbound_routes` · [API reference](https://docs.morevoice.ai/api/operations/inbound_routes_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |

### Returns

A page of results (`InboundRouteList`): `data`, `has_more` and `next_cursor`.

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

for inbound_route in client.inbound_routes.list():
    print(inbound_route)
```

## `retrieve()`

**Retrieve an inbound route.** Returns an inbound route: what it matches (`connection_id`, `match_did`, `match_caller`), its `priority`, whether it is `enabled`, and its `target`.

```python
# client.inbound_routes
def retrieve(self, id: str, *, more_voice_version: str | Unset = UNSET) -> _m.InboundRoute
```

`client.inbound_routes.retrieve()` · `await async_client.inbound_routes.retrieve()` · `GET /inbound_routes/{id}` · [API reference](https://docs.morevoice.ai/api/operations/inbound_routes_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A inbound route ID (`rte_…`). |

### Returns

`InboundRoute`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The route's ID. |
| `object` | `"inbound_route"` | Always `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). |
| `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. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

inbound_route = client.inbound_routes.retrieve("rte_7Hk2Lm9Qp")
print(inbound_route)
```

## `update()`

**Update an inbound route.** Changes the fields you send. A new `target` replaces the old one (and drops `fallback_assistant_id` when the new target is an assistant).

```python
# client.inbound_routes
def update(self, id: str, body: _m.InboundRouteUpdateParamsInput | Mapping[str, Any] | Unset = UNSET, *, more_voice_version: str | Unset = UNSET) -> _m.InboundRoute
```

`client.inbound_routes.update()` · `await async_client.inbound_routes.update()` · `PATCH /inbound_routes/{id}` · [API reference](https://docs.morevoice.ai/api/operations/inbound_routes_update/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A inbound route ID (`rte_…`). |

### Request body

| 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 | — |
| `target` | `RouteTargetParamsInput` | no | Where a matching call goes: `type`, and the ID in `<type>_id`. |

### Returns

`InboundRoute`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The route's ID. |
| `object` | `"inbound_route"` | Always `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). |
| `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. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

inbound_route = client.inbound_routes.update("rte_7Hk2Lm9Qp", {
    "enabled": False,
})
print(inbound_route)
```
