---
title: "Apply Instruction Gap"
method: POST
path: "/voice/agents/{agentId}/generation/gaps/apply"
tags: ["Voice Agent Intelligence"]
---

# Apply Instruction Gap

`POST /voice/agents/{agentId}/generation/gaps/apply`

## Request

- Base URL: `https://api.speakai.co/v1`
- URL: `https://api.speakai.co/v1/voice/agents/{agentId}/generation/gaps/apply`
- Auth: API key in header `x-speakai-key` and API key in header `x-access-token`

### Apply Instruction Gap

Requires the OWNER or ADMIN role. Inserts suggestedPatch into the agent's instructions (after insertAfterSection if given, otherwise appended) and persists the result.

## Path parameters

- `agentId` string, required

## Request body

- object
  - `suggestedPatch` string, required: Required. Typically taken directly from Analyze Instruction Gaps.
  - `insertAfterSection` string, nullable: Insert after this named section heading; omit or null to append at the end.

## Response `200`

OK

- object
  - `status` 'success'
  - `data` object
    - `instructions` string: The agent's full instructions after the patch was applied.

## Other responses

- `400`: suggestedPatch is required
- `403`: Caller's role is not OWNER or ADMIN
- `404`: Agent not found

---

[API](https://skmtc.dev/speakai/apis/speak-ai-api.md) · [All operations](https://skmtc.dev/speakai/apis/speak-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/speakai/apis/speak-ai-api/revisions/52d777e6d46e?raw)
