> 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: Regenerate a contact's AI lines

> **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).

## Regenerate a contact's AI lines

`POST /v1/contacts/{contactId}/ai-lines/regenerate` - operationId `ai-lines.regenerate`

| Permission | Credits | Rate limit |
| --- | --- | --- |
| Campaigns edit and the `ask` permission | 300 credits per 1,000 contact rows (`ai_personalization`) | 60 requests a minute per API key |

Clears the contact's personalized lines and the rewritten lines built on them, then queues a personalization run for
that contact alone. The call answers `202` with the run. Poll `GET /v1/ai-runs/{aiRunId}` until it ends.

Kenso charges the run as one contact at the personalization rate. When the run lands, a client approval page that
shows the contact gets the new lines. For a campaign that rewrites its lines, the campaign's scheduled AI work
rewrites the new lines later. Kenso checks credits and AI quota before it clears anything, so a refused call leaves the
contact's lines as they were.

Errors:

- `402 plan_limit_reached`: the workspace has no credits left. `error.refusal` has the balance.
- `404 not_found`: the contact is not in this workspace, is deleted, or is not in a campaign.
- `409 invalid_state`: the contact was already sent or exported, has a send queued, or is in an AI batch that has
not finished, or its campaign has no segment to personalize. Nothing changes. Edit a line instead.
- `429 rate_limited`: the workspace reached an AI run quota. Retry after the seconds in `Retry-After`.
- `503 service_unavailable`: the AI run queue was full after Kenso cleared the lines. The contact has no lines until
you retry or the campaign's next scheduled AI run writes them.

Requires Campaigns edit and the `ask` permission.

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/POST/v1/contacts/%7BcontactId%7D/ai-lines/regenerate)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `contactId` | path | integer (int64) | yes | The contact whose lines to write again. |
| `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`. |

### Response 202

`data` is a `AiRun`.

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The run id, a UUID. |
| `status` | string | The run's status: `queued`, `running`, `succeeded` (handed to the AI provider), `failed` or `canceled`. |
| `flow` | string | The flow the run processes: `qualification`, `personalization`, `rewriting` or `segmentation`. |
| `campaignId` | integer (int64) | The campaign the run processes. |
| `segmentId` | integer (int64) | The segment the run is limited to. Omitted when the run covers every segment. |
| `provider` | string | The AI provider that processed the batch, such as `openai`. Omitted until the run has submitted its contacts. |
| `model` | string | The model id the starting request named, on that call's response only. Omitted otherwise. |
| `createdAt` | string (date-time) | When Kenso queued the run, in UTC. |
| `startedAt` | string (date-time) | When the run started, in UTC. Omitted while it is queued. |
| `completedAt` | string (date-time) | When the run ended, in UTC. Omitted until it ends. |
| `contactsProcessed` | integer (int32) | Contacts the run handed to the AI provider. Omitted until the run has submitted them. |
| `batchId` | string | The AI provider's id for the first batch the run submitted. Omitted until the run has submitted one. |
| `error` | string | Why the run failed or was canceled, for a person to read. Omitted otherwise. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/contacts/812/ai-lines/regenerate" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID"
```

### Example response

```json
{
  "success": true,
  "data": {
    "id": "string",
    "status": "string",
    "flow": "qualification",
    "campaignId": 812,
    "segmentId": 812,
    "provider": "openai",
    "model": "string",
    "createdAt": "2026-09-23T15:02:11Z",
    "startedAt": "2026-09-23T15:02:11Z",
    "completedAt": "2026-09-23T15:02:11Z",
    "contactsProcessed": 1,
    "batchId": "string",
    "error": "string"
  }
}
```
