---
title: "Sync Dispatch Rules"
method: POST
path: "/api/v1/admin/livekit/phone-assignments/sync"
tags: ["livekit-phone-admin"]
---

# Sync Dispatch Rules

`POST /api/v1/admin/livekit/phone-assignments/sync`

Synchronize dispatch rules between database and LiveKit Cloud.

Detects:
- Orphaned rules: in LiveKit but not in DB (can auto-adopt)
- Missing rules: in DB but not in LiveKit (can auto-recreate)

Auto-adopt matches orphaned rules to existing phone numbers by comparing
the rule's inbound_numbers against the PhoneNumber table, then links them
by populating inbound_voice_agent_id and livekit_dispatch_rule_id.

Run this if dispatch rules were manually created via LiveKit dashboard
or if you suspect the database is out of sync.

## Request body

- DispatchRuleSyncRequest — Request to sync dispatch rules.
  - `auto_recreate_missing` boolean — Recreate rules in DB but not in LiveKit
  - `auto_adopt_orphaned` boolean — Adopt orphaned rules by matching their trunk numbers to PhoneNumber rows and linking them

## Response `200`

Successful Response

- DispatchRuleSyncResponse — Result of dispatch rule sync operation.
  - `checked` integer, required — Number of DB rules checked
  - `orphaned_count` integer, required — Rules in LiveKit but not in DB
  - `missing_count` integer, required — Rules in DB but not in LiveKit
  - `deleted_orphaned` integer, required — Orphaned rules deleted (if auto)
  - `recreated_missing` integer, required — Missing rules recreated (if auto)
  - `adopted_count` integer — Orphaned rules adopted (linked to existing phones)
  - `orphaned_rule_ids` string[] — IDs of orphaned rules
  - `missing_rule_ids` string[] — IDs of missing rules
  - `adopted_rule_ids` string[] — IDs of adopted rules
  - `errors` string[] — Any errors

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/getanana/apis/cleon-api.md) · [All operations](https://skmtc.dev/getanana/apis/cleon-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/getanana/cleon-api/revisions/c0f54348e251/schema)
