# Edit an agent (any field or section)

> PATCH /agents/{id}. HeyRik API parameters and documented request and response examples.

Source: https://www.heyrik.com/docs/api-reference/agents/patch-agents-id-edit-an-agent-any-field-or-section

PATCH https://server.heyrik.com/api/v1/agents/{id}

## Path parameters

- id (required): Replace {id} in the request URL with the value for this resource.

## Headers

Authorization: Bearer $HEYRIK_API_KEY (required). Keep your key on your server.

## Parameters

- name / greeting / language (—): Top-level fields — send just the ones you want to change.
- config.prompt_sections (object[]): Replace the Conversation Flow (the instruction sections). Send the FULL array you want the agent to have — it replaces the whole flow, so include the sections you're keeping.
- voice_settings (object): Swap the voice: { "voice_id": "<id from GET /voices>" } — a library voice or one of your clones.
- config (object): Patch any other builder section — call_behavior, no_response, transfer, fillers, personality, extracted_variables. Deep-merged, so the KB and untouched sections are preserved.

## Notes

Config sections deep-merge, so patching call_behavior won't wipe your KB. EXCEPTION: config.prompt_sections REPLACES the whole Conversation Flow — send the complete array you want. Applies to the NEXT call.

## Request example

```sh
curl -X PATCH https://server.heyrik.com/api/v1/agents/agc_9f2a1c30 \
  -H "Authorization: Bearer $HEYRIK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "voice_settings": { "voice_id": "vx_7b1e44a2" },
    "config": {
      "personality": "Friendly",
      "prompt_sections": [
        { "order": 0, "enabled": true, "title": "Identity & Purpose",
          "content": "- You are a warm real-estate qualification agent. Qualify the caller for a site visit." },
        { "order": 1, "enabled": true, "title": "Conversational Flow",
          "content": "- Ask, one at a time: property type, budget, location, timeline." },
        { "order": 2, "enabled": true, "title": "Closing",
          "content": "- Secure agreement to speak with a senior expert, thank them, and end the call." }
      ],
      "call_behavior": { "max_call_duration_sec": 600, "end_call_phrases": ["bye", "done"] }
    }
  }'
```

## Response example

```json
{
  "data": {
    "id": "agc_9f2a1c30",
    "greeting": "Thanks for calling Acme!",
    "updated_at": "2026-07-24T06:20:11.004Z"
  }
}
```
