Skip to Content
AI

AI lines

AI lines are the personalized lines Ken writes for one contact, one for each AI variable in the campaign's emails. Read the lines a contact's next email will use, correct one by hand, or have Ken write them all again. An edit or a new line applies to the steps that have not been sent yet, and a client approval page that shows the contact gets it too.

AI3 endpointsKen-Version: 2026-11-02AuthenticationWorkspacesErrors
MarkdownOpenAPI

Headers

The endpoints on this page take these headers. Each endpoint's curl shows the ones it sends.

NameInTypeRequiredDescription
Ken-Versionheaderstring, one of: 2026-11-02, 1.1optionalThe 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 date that is not a version answers 400 unsupported_version; any other value that is not a version is treated as legacy.
X-Ken-Workspace-Idheaderinteger (int64)optionalThe 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.

List a contact's AI lines

GET/v1/contacts/{contactId}/ai-linesai-lines.list
Permission
Campaigns view
Rate limit
12,000 requests a minute per API key
Needs the ai_line_edit feature on your workspace. Until it is on, calls answer 404.

Try it on developer.ken.so

Returns one line for each AI variable of the contact's campaign: the stored line the contact's next email uses.

That is the newest personalized line, or its rewrite when the prompt rewrites. A segment's prompt comes before the campaign's. Older lines and replaced lines are not listed. Lines are ordered by variable, at most 200, on one page.

Errors:

  • 404 not_found: the contact is not in this workspace, is deleted, or is not in a campaign.

Requires Campaigns view.

Parameters

NameInTypeRequiredDescription
contactIdpathinteger (int64)requiredThe contact whose lines to list.
limitqueryinteger (int32)optionalItems per page, from 1 to 200. Omit limit and cursor to get every item in one response, as before; with only cursor, 50 per page.
cursorquerystringoptionalThe nextCursor of the previous page. Omit it for the first page.
Request
curl -X GET "https://api.ken.so/v1/contacts/812/ai-lines?limit=1" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID"

Response 200

data is a list of ContactAiLine. Each item has these fields. The response also carries pagination.

Show the 8 response fields and an example

The fields and an example are also on this endpoint's Markdown page.

Update a contact's AI line

PATCH/v1/contacts/{contactId}/ai-lines/{aiLineId}ai-lines.update
Permission
Campaigns edit
Rate limit
4,800 requests a minute per API key
Needs the ai_line_edit feature on your workspace. Until it is on, calls answer 404.

Try it on developer.ken.so

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.

Parameters

NameInTypeRequiredDescription
contactIdpathinteger (int64)requiredThe contact the line belongs to.
aiLineIdpathinteger (int64)requiredThe line to update, from the line list.

Request body

application/json, optional.

FieldTypeRequiredDescription
textstringrequiredThe 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.
Request
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"
}'

Response 200

data is a ContactAiLine.

Show the 8 response fields and an example

The fields and an example are also on this endpoint's Markdown page.

Regenerate a contact's AI lines

POST/v1/contacts/{contactId}/ai-lines/regenerateai-lines.regenerate
Permission
Campaigns edit and the ask permission
Credits
300 credits per 1,000 contact rows (ai_personalization)
Rate limit
60 requests a minute per API key
Needs the ai_line_edit feature on your workspace. Until it is on, calls answer 404.

Try it on developer.ken.so

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.

Parameters

NameInTypeRequiredDescription
contactIdpathinteger (int64)requiredThe contact whose lines to write again.
Request
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"

Response 202

data is a AiRun.

Show the 13 response fields and an example

The fields and an example are also on this endpoint's Markdown page.


On this page