> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.voicebip.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.voicebip.com/_mcp/server.

# Update an agent

PATCH https://api.voicebip.com/v1/agents/{agent_id}
Content-Type: application/json

Reference: https://docs.voicebip.com/api/agents/update-agent

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://api.voicebip.com` (Production, default)
- `https://sandbox.voicebip.com` (Sandbox)

## Request

### Path parameters

- `agent_id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `display_name` (string, optional)
- `description` (string, optional)
- `language` (string, optional)
- `knowledge_base_id` (string, optional) — Attach a knowledge base (kb_… id, must belong to the workspace) so hosted-AI turns answer from its documents. Empty string detaches.
- `ai_provider` (string, optional) — AI backend. Use `GET /admin/ai/providers` to see available providers (typically `gemini` or `openai`). Set to `byom` to switch to your own webhook; also supply `webhook_url` in the same PATCH. New calls use the new mode immediately; in-flight calls keep the mode they started with.
- `ai_model` (string, optional) — Model ID for the chosen provider. Must be an active model in the platform catalogue (validated against `voicebip_v1.ai_models`). Omit or leave unchanged to keep the current value; field is ignored when `ai_provider` is `byom`.
- `tts_voice` (string, optional) — The voice the agent speaks with. Pass a `voice_id` from `GET /v1/voice/models` (e.g. `aura-asteria-en`). Validated at save time (unknown id → 400). Omit to leave unchanged; send an empty string to reset to the platform-default voice.
- `system_prompt` (string, optional)
- `webhook_url` (string, optional) — Required when `ai_provider` is `byom`. This single URL receives both BYOM turn requests (`BYOMVoiceWebhookRequest`) and lifecycle events (`call.initiated`, `call.transcription`, `call.completed`). Detect lifecycle events by the presence of `event_type` in the body and return `{"received": true}`; for turn requests return a `BYOMVoiceWebhookResponse`. See the [BYOM guide](/guides/byom).
- `greeting_text` (string, optional) — Custom greeting played via TTS when a call connects
- `greeting_audio_url` (string, optional) — URL of a hosted WAV to play as the greeting instead of greeting_text. Must be 8 kHz mono 16-bit linear-PCM (telephony format); validated and stored at save time, so a bad URL or wrong format fails this request, never mid-call. Send an empty string to clear it. Omit to leave it unchanged (omitting avoids a needless re-fetch + re-upload).
- `tool_definitions` (string, optional) — JSON array of OpenAI-compatible tool definitions. Defaults to '[]'.
- `shareable` (boolean, optional) — Enable or disable the public 'try my agent' shareable link
- `call_window_start` (string, optional)
- `call_window_end` (string, optional)
- `call_window_timezone` (string, optional)
- `pre_call_announcement` (string, optional)
- `recording_enabled` (boolean, optional) — Enable or disable call recording for this agent.
- `consent_required` (boolean, optional) — Whether a DTMF consent prompt is played before recording starts. Audit-logged on every change.
- `screening_enabled` (boolean, optional) — BYOM only. Enable/disable the synchronous pre-greeting `call.screening` webhook for inbound calls.
- `screening_fail_closed` (boolean, optional) — Screening failure policy: false = fail-open (allow on webhook error), true = fail-closed (reject).
- `status` (enum, optional)
  - Allowed values: `active`, `suspended`

## Response

### 200

Agent updated

- `agent_id` (string, optional)
- `workspace_id` (string, optional)
- `display_name` (string, optional)
- `description` (string, optional)
- `language` (string, optional)
- `ai_provider` (string, optional)
- `ai_model` (string, optional)
- `tts_voice` (string, optional) — The voice the agent speaks with. This is a `voice_id` from `GET /v1/voice/models` (e.g. `aura-asteria-en`). Null/absent means the platform-default voice.
- `system_prompt` (string, optional)
- `webhook_url` (string, optional)
- `greeting_text` (string, optional) — Custom greeting played via TTS when a call connects. If null, a default greeting is used.
- `greeting_audio_url` (string, optional) — The source URL of a hosted WAV played as the greeting instead of greeting_text. Set via UpdateAgent; validated and stored at save time. The system-managed storage key is never returned.
- `tool_definitions` (string, optional, default: []) — JSON array of OpenAI-compatible function/tool definitions. The AI can invoke these tools during voice calls. Built-in tools: hang_up, transfer_call, hold_call, resume_call. Custom tools are dispatched to the agent's webhook_url. Defaults to "[]".
- `shareable` (boolean, optional) — When true, enables a public 'try my agent' link for browser-based test calls.
- `knowledge_base_id` (string, optional) — Attached knowledge base (RAG). When set, hosted-AI turns answer from this KB's documents. Empty/absent = none.
- `call_window_start` (string, optional, default: 08:00) — Earliest permitted outbound call time (HH:MM, 24hr). CBN compliance.
- `call_window_end` (string, optional, default: 20:00) — Latest permitted outbound call time (HH:MM, 24hr). CBN compliance.
- `call_window_timezone` (string, optional, default: Africa/Lagos) — IANA timezone for call window evaluation.
- `pre_call_announcement` (string, optional) — CBN requirement: spoken announcement at start of call identifying the sponsoring institution.
- `recording_enabled` (boolean, optional) — Whether call recording is enabled for this agent. Workspace-level recording must also be enabled via POST /v1/workspace/recording for calls to be recorded.
- `consent_required` (boolean, optional) — When true (default), the caller hears a consent prompt before recording starts. When false, recording begins immediately. Only disable if you have an independent legal basis under NDPR.
- `screening_enabled` (boolean, optional) — BYOM only. When true, inbound calls trigger a synchronous `call.screening` webhook (to the agent's `webhook_url`) BEFORE the greeting so you can allow/reject the caller and optionally override the greeting. See the [BYOM guide](/guides/byom).
- `screening_fail_closed` (boolean, optional) — Screening failure policy. false (default) = fail-open (allow the call if the screening webhook errors/times out); true = fail-closed (reject).
- `status` (enum, optional)
  - Allowed values: `active`, `suspended`
- `created_at` (datetime, optional)
- `updated_at` (datetime, optional)

## Errors

### 404 Update Agent Request Not Found Error

Not found

- `error_code` (enum, required)
  - Allowed values: `NOT_FOUND`, `ALREADY_EXISTS`, `INVALID_ARGUMENT`, `PERMISSION_DENIED`, `UNAUTHENTICATED`, `RATE_LIMITED`, `INTERNAL`, `UNAVAILABLE`, `QUOTA_EXCEEDED`, `NUMBER_UNAVAILABLE`, `CALL_FAILED`, `MESSAGE_FAILED`, `WEBHOOK_FAILED`, `AI_PROVIDER_ERROR`, `CALL_WINDOW_RESTRICTED`, `INVALID_REQUEST`, `INVALID_PLAN`, `NO_OP`, `NO_ACTIVE_SUBSCRIPTION`, `WORKSPACE_NOT_FOUND`, `TIER_SWITCH_UNSUPPORTED`, `INSUFFICIENT_BALANCE`, `WORKSPACE_BLOCKED`, `TIER_SWITCH_TOO_FREQUENT`, `CHANNEL_MISMATCH`, `OPT_OUT_ENFORCED`, `UPSTREAM_ERROR`, `REQUEST_BODY_TOO_LARGE`, `INVALID_BODY`, `AI_ERROR`, `ADMIN_DISABLED`, `STORE_UNAVAILABLE`, `ADMIN_DB_UNAVAILABLE`, `MISSING_ACTOR`, `ACTOR_TOO_LONG`, `MISSING_FIELD`, `INVALID_JSON`, `INVALID_AMOUNT`, `INVALID_INCLUDED_QTY`, `INVALID_CURRENCY`, `INVALID_PROFILE`, `INVALID_RESOURCE`, `INVALID_UNIT`, `INVALID_TIER`, `INVALID_EFFECTIVE_FROM`, `NOTES_TOO_LONG`, `INVALID_LIMIT`, `LIST_FAILED`, `UPSERT_FAILED`, `WORKSPACE_OVERRIDE_DISABLED`, `WORKSPACE_OVERRIDE_UNCONFIRMED`, `MISSING_WORKSPACE_HEADER`, `INVALID_PASSWORD`, `INVALID_EMAIL`, `INVALID_CREDENTIALS`, `EMAIL_EXISTS`, `EMAIL_NOT_VERIFIED`, `WEAK_PASSWORD`, `MISSING_COMPANY`, `MISSING_TOKEN`, `INVALID_TOKEN`, `TOO_MANY_ATTEMPTS`
- `message` (string, required)
- `request_id` (string, required)
- `documentation_url` (string, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "agent_id": "agent_id",
  "workspace_id": "workspace_id",
  "display_name": "display_name",
  "description": "description",
  "language": "language",
  "ai_provider": "ai_provider",
  "ai_model": "ai_model",
  "tts_voice": "tts_voice",
  "system_prompt": "system_prompt",
  "webhook_url": "webhook_url",
  "greeting_text": "greeting_text",
  "greeting_audio_url": "greeting_audio_url",
  "tool_definitions": "[{\"type\":\"function\",\"function\":{\"name\":\"hang_up\",\"description\":\"End the call gracefully\",\"parameters\":{\"type\":\"object\",\"properties\":{},\"required\":[]}}}]",
  "shareable": true,
  "knowledge_base_id": "knowledge_base_id",
  "call_window_start": "08:00",
  "call_window_end": "20:00",
  "call_window_timezone": "Africa/Lagos",
  "pre_call_announcement": "pre_call_announcement",
  "recording_enabled": true,
  "consent_required": true,
  "screening_enabled": true,
  "screening_fail_closed": true,
  "status": "active",
  "created_at": "2024-01-15T09:30:00Z",
  "updated_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.voicebip.com/v1/agents/agent_id"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.voicebip.com/v1/agents/agent_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.voicebip.com/v1/agents/agent_id"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.voicebip.com/v1/agents/agent_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.voicebip.com/v1/agents/agent_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.voicebip.com/v1/agents/agent_id', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.voicebip.com/v1/agents/agent_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.voicebip.com/v1/agents/agent_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```