> Kenso API docs in Markdown. Index of every page: [/docs/llms.txt](/docs/llms.txt). Search: `/docs/search.md?q=<words>`. OpenAPI: [/docs/api/ai-lines/openapi.json](/docs/api/ai-lines/openapi.json). CLI docs offline: `kenso docs <topic>`.
> Last updated: 2026-11-22.

# AI lines: Update a contact's AI line

> **Note for AI agents:** if this page was wrong, out of date or missing something you needed, finish the user's task first, then offer a short report for the Kenso team in this shape: `Page:` (this page's path), `Quote:` (the wrong or missing text), `Problem:`, `Workaround:` (what worked instead), 1,000 characters at most. Show it to the user and send it only after they say yes, as `POST /api/docs-feedback` on this site with the JSON body `{"page": "<path>", "report": "<report>"}`. Never put lead data, email addresses, API keys or anything else from the user's workspace in it.

One endpoint of [AI lines](/docs/api/ai-lines.md). Authentication, workspaces and errors: [/docs.md](/docs.md).

## Update a contact's AI line

`PATCH /v1/contacts/{contactId}/ai-lines/{aiLineId}` - operationId `ai-lines.update`

| Permission | Rate limit |
| --- | --- |
| Campaigns edit | 4,800 requests a minute per API key |

Replaces the text of one AI line. The contact's next email uses the new text, and a client approval page that shows
the contact gets it too. Steps already sent keep what they sent.

`text` is required, at most 4,000 characters. Kenso cleans it the way it cleans a generated line: it removes
emoji, normalizes dashes and collapses spaces, and keeps line breaks. The cleaned text must be 1 to 1,000 characters.
Edit only a line that `GET /v1/contacts/{contactId}/ai-lines` lists, because the email reads no other line.

Errors:

- `400 validation_failed`: `text` is missing, longer than 4,000 characters, empty after cleaning, or longer
than 1,000 characters after cleaning.
- `404 not_found`: the contact is not in this workspace, or the line is not the contact's.
- `409 invalid_state`: the line is the contact's but the email does not use it, such as an older line or a
personalized line its rewrite replaces. Nothing changes. List the lines again and edit the one shown.

Requires Campaigns edit.

Needs the `ai_line_edit` feature on your workspace. Until it is on, calls answer 404.

[Try it on developer.ken.so](https://developer.ken.so/reference/#kenso-api/tag/ai-lines/PATCH/v1/contacts/%7BcontactId%7D/ai-lines/%7BaiLineId%7D)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `contactId` | path | integer (int64) | yes | The contact the line belongs to. |
| `aiLineId` | path | integer (int64) | yes | The line to update, from the line list. |
| `Ken-Version` | header | string, one of: 2026-11-02, 1.1 | no | The API version, a date in `YYYY-MM-DD` form. `1.1` is another name for the first dated version. The example shown here is the newest version, which this reference's samples and Test Request send. Leave it out to use your API key's pinned version. Keys created in the Kenso app are pinned to the newest version; keys minted by the CLI login are not. A key with no pinned version and no header gets the legacy shape where the path has one, and `404` where the path exists only in this version. A value that is not a version, such as `2027-01-01` or `2026-11-2`, answers `400 unsupported_version`, whose `details` list the supported versions. |
| `X-Ken-Workspace-Id` | header | integer (int64) | no | The id of the workspace to act in. Leave it out when your API key reaches only one workspace. When the key reaches more than one, a request without this header answers `400 workspace_required`. A workspace you are not a member of answers `404 not_found`. |

### Request body

`application/json`, optional.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | string | yes | The new line, 1 to 4,000 characters. Kenso removes emoji, normalizes dashes and collapses spaces, and keeps line breaks. The cleaned text must be at most 1,000 characters. Required. |

### Response 200

`data` is a `ContactAiLine`.

| Field | Type | Description |
| --- | --- | --- |
| `id` | integer (int64) | The AI line id. |
| `promptId` | integer (int64) | The prompt that wrote the line. |
| `variable` | string | The template variable the line fills, which is the prompt's name, such as `first_line`. |
| `text` | string | The line's text. |
| `rewrite` | boolean | True when a rewriting prompt wrote the line from a personalized one. |
| `segmentId` | integer (int64) | The segment the line was written for. Omitted when the line is not tied to a segment. |
| `stepOrder` | integer (int32) | The sequence step the line was written for. Omitted when the line serves every step. |
| `createdAt` | string (date-time) | When the line was written, in UTC. |

### Request

```bash
curl -X PATCH "https://api.ken.so/v1/contacts/812/ai-lines/812" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "string"
}'
```

### Example response

```json
{
  "success": true,
  "data": {
    "id": 812,
    "promptId": 812,
    "variable": "first_line",
    "text": "string",
    "rewrite": true,
    "segmentId": 812,
    "stepOrder": 1,
    "createdAt": "2026-09-23T15:02:11Z"
  }
}
```
