> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usefini.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update prompts

> Save a new prompt version for one agent.

Saves a new prompt version for one agent and returns the stored version.

<Warning>
  Current controller behavior: the workspace-API-key write route uses `POST /v2/bots/{id}/hc-prompt` and does **not** add a `/public` suffix, even though the read routes do.
</Warning>

<Note>
  This route creates a new saved prompt version. It does not patch a prompt in place.
</Note>

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token containing your Fini workspace API key. Format: `Bearer fini_...` The key needs `write` scope.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Path parameters

<ParamField path="id" type="string" required>
  Agent ID whose prompts you want to update. Use [List agents](/en/api-reference/list-agents) to get the `botId`.
</ParamField>

## Body parameters

<ParamField body="hcPlanningPrompt" type="PromptSection[]" required>
  Full Planning Prompt section array. Send the complete array, not just the section you changed.
</ParamField>

<ParamField body="hcGuidelinePrompt" type="PromptSection[]" required>
  Full Main Guidelines section array.
</ParamField>

<ParamField body="hcChannelPrompt" type="PromptSection[]" required>
  Full Channel Prompt section array.
</ParamField>

<Note>
  For write payloads, subsection helper fields from merged reads such as `defaultPrompt` and `custom` are not required. A safe round-trip pattern is to start from [Get prompts](/en/api-reference/get-prompts), edit the arrays in place, and send them back.
</Note>

## Response

Returns the saved [`Prompt`](/en/api-reference/prompts#prompt-object) version.

<Note>
  Current controller behavior: this response is the stored version row, not the merged template view. If you need the merged read shape with `defaultPrompt` and `custom`, call [Get prompts](/en/api-reference/get-prompts) after writing.
</Note>

## Errors

<AccordionGroup>
  <Accordion title="400 Bad Request" icon="circle-exclamation">
    The body is malformed. All three top-level prompt arrays are required.
  </Accordion>

  <Accordion title="401 Unauthorized" icon="lock">
    The API key is missing, malformed, revoked, or invalid.
  </Accordion>

  <Accordion title="403 Forbidden" icon="shield-halved">
    The API key does not include the `write` scope required for this route.
  </Accordion>

  <Accordion title="404 Not Found" icon="ghost">
    The agent ID does not exist.
  </Accordion>

  <Accordion title="406 Not Acceptable" icon="circle-question">
    Current controller behavior: if the agent belongs to a different workspace, this route returns `406` with an invalid-agent message rather than `403`.
  </Accordion>

  <Accordion title="500 Internal Server Error" icon="triangle-exclamation">
    Fini failed while saving the prompt version in storage.
  </Accordion>
</AccordionGroup>
