# Rebase an agent branch

Execute a previously previewed rebase against unchanged branch tips.

## Endpoint

`POST /api/v1/workspaces/{workspace_id}/agents/{agent_id}/branches/{branch_id}/rebase`

## Authentication

| Class | Authentication | Minimum role | API key |
| --- | --- | --- | --- |
| customer-api | Bearer API key or dashboard session cookie; dashboard mutations also require X-CX-Request: 1. | member | Allowed |

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | path | `string` | Yes | — |
| `agent_id` | path | `string` | Yes | — |
| `branch_id` | path | `string` | Yes | — |

## Request body

### application/json request schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | PermintaanRebase | — | No | Yes | — | — |
| `description` | `string` | — | — | No | No | — | — |
| `preview_hash` | `string` | — | — | No | Yes | — | — |
| `source_tip_version_id` | `string` | — | — | No | Yes | — | — |
| `target_tip_version_id` | `string` | — | — | No | Yes | — | — |

## Example

```bash
curl --request POST 'https://operade.ai/api/v1/workspaces/ws_demo/agents/agt_demo/branches/br_demo/rebase' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{"description":"Example rebase","source_tip_version_id":"ver_source","target_tip_version_id":"ver_target","preview_hash":"sha256:0000000000000000000000000000000000000000000000000000000000000000"}'
```

## Responses

| Status | Description | Content |
| --- | --- | --- |
| 4XX | Handled client error | application/json: `ErrorResponse` |
| 201 | Successful Response | application/json: `BranchRebaseResponse` |

### 4XX application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | ErrorResponse | — | No | Yes | — | — |
| `error` | `object` | ErrorItem | — | No | Yes | — | — |
| `error.code` | `string` | — | — | No | Yes | — | — |
| `error.details` | `object` | — | — | No | No | — | — |
| `error.message` | `string` | — | — | No | Yes | — | — |

### 201 application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | BranchRebaseResponse | — | No | Yes | — | — |
| `branch_id` | `string` | — | — | No | Yes | — | — |
| `config` | `object` | ConfigAgen | — | No | Yes | — | — |
| `config.agent` | `object` | AgentConfig | — | No | No | — | — |
| `config.agent.first_message` | `string` | — | — | No | No | — | — |
| `config.agent.language` | `string` | — | — | No | No | "id", "en" | — |
| `config.agent.prompt` | `object` | PromptConfig | — | No | No | — | — |
| `config.agent.prompt.built_in_tools` | `object` | BuiltInTools | — | No | No | — | `None` berarti mati. Bentuk ini ikut ElevenLabs, dan ia bertetangga dengan `tool_ids` di dalam `agent.prompt` — bukan di `agent` — sesuai kontrak resminya. Cuma `end_call` yang ada. Sisanya (`transfer_to_number`, `play_keypad_touch_tone`, `voicemail_detection`) semuanya soal telepon, `transfer_to_agent` butuh F6, dan `language_detection` butuh multi-bahasa yang sengaja ditunda. |
| `config.agent.prompt.built_in_tools.end_call` | `object or null` | SystemTool | — | Yes | No | — | Tool bawaan platform: tidak punya URL, tidak punya rahasia, dan tidak bisa dibuat pelanggan. `description` kosong berarti pakai kalimat bawaan kita — bentuk yang sama dengan ElevenLabs (docs/03 `SystemToolConfig`). |
| `config.agent.prompt.built_in_tools.end_call.description` | `string` | — | — | No | No | — | — |
| `config.agent.prompt.ignore_default_personality` | `boolean` | — | — | No | No | — | — |
| `config.agent.prompt.knowledge_base` | `array<DokumenTerpasang>` | — | — | No | No | — | — |
| `config.agent.prompt.knowledge_base[]` | `object` | DokumenTerpasang | — | No | Yes | — | Satu dokumen knowledge base yang dipasang ke agen ini. Nama field mengikuti `KnowledgeBaseLocator` ElevenLabs (docs/03), termasuk menyimpan `name` di sini walau bisa dibaca dari tabel dokumen. Itu disengaja: versi agen harus tetap terbaca enam bulan kemudian, bahkan kalau dokumennya sudah dihapus — tanpa nama, riwayat versinya cuma memuat id yang tidak berarti apa-apa bagi siapa pun. |
| `config.agent.prompt.knowledge_base[].id` | `string` | — | — | No | Yes | — | — |
| `config.agent.prompt.knowledge_base[].name` | `string` | — | — | No | No | — | — |
| `config.agent.prompt.knowledge_base[].type` | `string` | — | — | No | No | "text", "file", "url" | — |
| `config.agent.prompt.knowledge_base[].usage_mode` | `string` | — | — | No | No | "auto", "prompt" | — |
| `config.agent.prompt.llm` | `string` | — | — | No | No | "gpt-5-mini", "gpt-5", "deepseek-v4-flash", "claude-haiku-4-5", "claude-sonnet-4-5", "gemini-2.5-flash" | — |
| `config.agent.prompt.max_tokens` | `integer` | — | — | No | No | — | — |
| `config.agent.prompt.prompt` | `string` | — | — | No | No | — | — |
| `config.agent.prompt.rag` | `object` | RagConfig | — | No | No | — | Angka bawaannya sama persis dengan ElevenLabs (docs/03 `RagConfig`), kecuali jumlah potongan yang mereka biarkan sampai 20. Lima cukup untuk pertanyaan CS, dan tiap potongan tambahan dibayar tiap giliran. |
| `config.agent.prompt.rag.enabled` | `boolean` | — | — | No | No | — | — |
| `config.agent.prompt.rag.max_documents_length` | `integer` | — | — | No | No | — | — |
| `config.agent.prompt.rag.max_retrieved_rag_chunks_count` | `integer` | — | — | No | No | — | — |
| `config.agent.prompt.rag.max_vector_distance` | `number` | — | — | No | No | — | — |
| `config.agent.prompt.temperature` | `number` | — | — | No | No | — | — |
| `config.agent.prompt.tool_ids` | `array<string>` | — | — | No | No | — | — |
| `config.agent.prompt.tool_ids[]` | `string` | — | — | No | Yes | — | — |
| `config.conversation` | `object` | ConversationConfig | — | No | No | — | — |
| `config.conversation.max_duration_seconds` | `integer` | — | — | No | No | — | — |
| `config.conversation.text_only` | `boolean` | — | — | No | No | — | — |
| `config.guardrails` | `object` | GuardrailsConfig | — | No | No | — | — |
| `config.guardrails.content` | `object` | ContentGuardrails | — | No | No | — | — |
| `config.guardrails.content.categories` | `object` | ContentCategories | — | No | No | — | — |
| `config.guardrails.content.categories.harassment` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.harassment.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.harassment.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.categories.medical_and_legal_information` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.medical_and_legal_information.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.medical_and_legal_information.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.categories.profanity` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.profanity.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.profanity.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.categories.religion_or_politics` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.religion_or_politics.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.religion_or_politics.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.categories.self_harm` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.self_harm.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.self_harm.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.categories.sexual` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.sexual.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.sexual.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.categories.violence` | `object` | ContentCategory | — | No | No | — | — |
| `config.guardrails.content.categories.violence.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.content.categories.violence.threshold` | `string` | — | — | No | No | "low", "medium", "high" | — |
| `config.guardrails.content.execution_mode` | `string` | — | — | No | No | "streaming", "blocking" | — |
| `config.guardrails.content.trigger_action` | `object` | TriggerAction | — | No | No | — | — |
| `config.guardrails.content.trigger_action.feedback` | `string` | — | — | No | No | — | — |
| `config.guardrails.content.trigger_action.type` | `string` | — | — | No | No | "end_call", "retry" | — |
| `config.guardrails.custom` | `object` | CustomGuardrails | — | No | No | — | — |
| `config.guardrails.custom.configs` | `array<CustomGuardrail>` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[]` | `object` | CustomGuardrail | — | No | Yes | — | — |
| `config.guardrails.custom.configs[].execution_mode` | `string` | — | — | No | No | "streaming", "blocking" | — |
| `config.guardrails.custom.configs[].history_message_count` | `integer` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[].id` | `string` | — | — | No | Yes | — | — |
| `config.guardrails.custom.configs[].is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[].model` | `string` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[].name` | `string` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[].prompt` | `string` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[].trigger_action` | `object` | TriggerAction | — | No | No | — | — |
| `config.guardrails.custom.configs[].trigger_action.feedback` | `string` | — | — | No | No | — | — |
| `config.guardrails.custom.configs[].trigger_action.type` | `string` | — | — | No | No | "end_call", "retry" | — |
| `config.guardrails.focus` | `object` | ToggleGuardrail | — | No | No | — | — |
| `config.guardrails.focus.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.prompt_injection` | `object` | ToggleGuardrail | — | No | No | — | — |
| `config.guardrails.prompt_injection.is_enabled` | `boolean` | — | — | No | No | — | — |
| `config.guardrails.version` | `string` | — | — | No | No | "1" | — |
| `config.platform_settings` | `object` | PlatformSettings | — | No | No | — | — |
| `config.platform_settings.analysis_llm` | `string` | — | — | No | No | "gpt-5-mini", "gpt-5" | — |
| `config.platform_settings.data_collection` | `object` | — | — | No | No | — | — |
| `config.platform_settings.evaluation` | `object` | EvaluationSettings | — | No | No | — | — |
| `config.platform_settings.evaluation.criteria` | `array<EvaluationCriterion>` | — | — | No | No | — | — |
| `config.platform_settings.evaluation.criteria[]` | `object` | EvaluationCriterion | — | No | Yes | — | — |
| `config.platform_settings.evaluation.criteria[].conversation_goal_prompt` | `string` | — | — | No | Yes | — | — |
| `config.platform_settings.evaluation.criteria[].id` | `string` | — | — | No | Yes | — | — |
| `config.platform_settings.evaluation.criteria[].name` | `string` | — | — | No | Yes | — | — |
| `config.platform_settings.sentiment_analysis` | `object` | SentimentAnalysisSettings | — | No | No | — | — |
| `config.platform_settings.sentiment_analysis.enabled` | `boolean` | — | — | No | No | — | — |
| `config.platform_settings.testing` | `object` | TestingSettings | — | No | No | — | — |
| `config.platform_settings.testing.attached_tests` | `array<AttachedTest>` | — | — | No | No | — | — |
| `config.platform_settings.testing.attached_tests[]` | `object` | AttachedTest | — | No | Yes | — | — |
| `config.platform_settings.testing.attached_tests[].test_id` | `string` | — | — | No | Yes | — | — |
| `config.platform_settings.testing.attached_tests[].workflow_node_id` | `string or null` | — | — | Yes | No | — | — |
| `config.platform_settings.topic_discovery` | `object` | TopicDiscoverySettings | — | No | No | — | — |
| `config.platform_settings.topic_discovery.enabled` | `boolean` | — | — | No | No | — | — |
| `config.procedures` | `array<object>` | — | — | No | No | — | — |
| `config.procedures[]` | `object` | — | — | No | Yes | — | — |
| `config.workflow` | `object or null` | — | — | Yes | No | — | — |
| `conflicts` | `array<ConflictValue>` | — | — | No | Yes | — | — |
| `conflicts[]` | `object` | ConflictValue | — | No | Yes | — | — |
| `conflicts[].base` | `reference or null` | JsonValue | — | Yes | No | — | — |
| `conflicts[].base_present` | `boolean` | — | — | No | Yes | — | — |
| `conflicts[].path` | `string` | — | — | No | Yes | — | — |
| `conflicts[].source` | `reference or null` | JsonValue | — | Yes | No | — | — |
| `conflicts[].source_last_changed_at` | `string or null` | — | date-time | Yes | No | — | — |
| `conflicts[].source_last_changed_version_id` | `string or null` | — | — | Yes | No | — | — |
| `conflicts[].source_present` | `boolean` | — | — | No | Yes | — | — |
| `conflicts[].target` | `reference or null` | JsonValue | — | Yes | No | — | — |
| `conflicts[].target_last_changed_at` | `string or null` | — | date-time | Yes | No | — | — |
| `conflicts[].target_last_changed_version_id` | `string or null` | — | — | Yes | No | — | — |
| `conflicts[].target_present` | `boolean` | — | — | No | Yes | — | — |
| `conflicts[].winner` | `string or null` | — | — | Yes | No | "source", "target" | — |
| `description` | `string` | — | — | No | Yes | — | — |
| `lineage_only` | `boolean` | — | — | No | Yes | — | — |
| `overridden_fields` | `array<string>` | — | — | No | Yes | — | — |
| `overridden_fields[]` | `string` | — | — | No | Yes | — | — |
| `parent_version_id` | `string` | — | — | No | Yes | — | — |
| `rebased_from_version_id` | `string` | — | — | No | Yes | — | — |
| `version_id` | `string` | — | — | No | Yes | — | — |

### Response example

```json
{
  "version_id": "string",
  "branch_id": "string",
  "parent_version_id": "string",
  "rebased_from_version_id": "string",
  "description": "string",
  "config": {},
  "overridden_fields": [],
  "conflicts": [],
  "lineage_only": false
}
```

## Errors

Reviewed common and route-declared errors are summarized here; the list is not exhaustive. Start with the [distributed error index](/docs/reference/api/errors) to find each code's canonical domain page.

| Status | Code | Description |
| --- | --- | --- |
| 401 | `unauthenticated` | Authentication is missing, invalid, or revoked. |
| 403 | `forbidden` | The authenticated caller does not have access to this operation. |
| 404 | `not_found` | The requested workspace resource was not found. |
| 422 | `validation_failed` | The request did not pass field or business validation. |

## Related operations

- [Create an agent branch](/docs/api-reference/branches/create-agent-branch) — `POST /api/v1/workspaces/{workspace_id}/agents/{agent_id}/branches`
- [Get an agent branch](/docs/api-reference/branches/get-agent-branch) — `GET /api/v1/workspaces/{workspace_id}/agents/{agent_id}/branches/{branch_id}`
- [List agent branches](/docs/api-reference/branches/list-agent-branches) — `GET /api/v1/workspaces/{workspace_id}/agents/{agent_id}/branches`
