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

# AI prompts: Create a prompt

> **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 prompts](/docs/api/prompts.md). Authentication, workspaces and errors: [/docs.md](/docs.md).

## Create a prompt

`POST /v1/prompts` - operationId `prompts.create`

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

Adds a prompt to a campaign or segment. Send `prompt`, `flow`, `type`, and `campaignId` or
`segmentId`. Returns `201` with a `Location` header.

Errors:

- `400 validation_failed`: a required field is missing or a value is not accepted.
- `404 not_found`: the campaign, segment or prompt template is not in this workspace.
- `409 conflict`: the write would clear AI results (see `error.impact`). Set the `confirm`
query parameter to true.

Requires Campaigns edit.

[Try it on developer.ken.so](https://developer.ken.so/reference/#kenso-api/tag/prompts/POST/v1/prompts)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `confirm` | query | boolean | no | Set to true to go ahead when the change would clear AI results Kenso already made. Default false. |
| `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 |
| --- | --- | --- | --- |
| `name` | string | no | The prompt's name. On a personalization prompt with `toOutput` true, it is also the AI variable's name. |
| `prompt` | string | yes | The instructions the AI follows. Required. |
| `audienceDescription` | string | no | Who the campaign targets. Kenso adds it to the qualification, scoring and personalization prompts. |
| `qualificationCriteria` | string | no | What makes a contact a fit. Qualification and scoring read it. |
| `disqualificationCriteria` | string | no | What rules a contact out. Qualification and scoring read it. |
| `scoringCriteria` | string | no | What makes a contact a good or a poor fit. A scoring prompt needs it to run. |
| `type` | string | yes | The message role the prompt is sent as: `system`, `user` or `assistant`. Required. |
| `flow` | string | yes | The step the prompt belongs to: `qualification`, `personalization`, `rewriting`, `segmentation` or `scoring`. Required. |
| `campaignId` | integer (int64) | no | The campaign the prompt belongs to. Send it, `segmentId`, or both. |
| `segmentId` | integer (int64) | no | The segment the prompt belongs to. With `campaignId`, the segment must be in that campaign. |
| `promptTemplateId` | integer (int64) | no | A prompt template of this workspace to add the prompt to. Optional. |
| `toOutput` | boolean | no | On a personalization prompt, true to have the AI write the result as an AI variable for the emails. Defaults to false. |
| `toRewrite` | integer (int32) | no | Above 0 to have the rewriting step rewrite this AI variable. Optional. |
| `order` | integer (int32) | no | Where the prompt sits among its campaign's prompts. Lower numbers come first. Defaults to 0. |
| `fallbackIfEmpty` | string | no | The text to use when the AI variable comes out empty. Optional. |
| `isRequiredForSending` | boolean | no | True to hold a contact from sending while this AI variable is empty and there is no fallback. Defaults to false. |

### Response 201

`data` is a `Prompt`.

| Field | Type | Description |
| --- | --- | --- |
| `id` | integer (int64) | The prompt's id. |
| `name` | string | The prompt's name. On a personalization prompt with `toOutput` true, it is also the AI variable's name, used in steps as `{{name}}`. |
| `prompt` | string | The instructions the AI follows. |
| `audienceDescription` | string | Who the campaign targets. Kenso adds it to the qualification, scoring and personalization prompts. |
| `qualificationCriteria` | string | What makes a contact a fit. Qualification and scoring read it. |
| `disqualificationCriteria` | string | What rules a contact out. Qualification and scoring read it. |
| `scoringCriteria` | string | What makes a contact a good or a poor fit. A scoring prompt needs it to run. |
| `type` | string | The message role the prompt is sent as: `system`, `user` or `assistant`. |
| `flow` | string | The step the prompt belongs to: `qualification`, `personalization`, `rewriting`, `segmentation`, `scoring`, or `tone_of_voice` on older prompts. |
| `campaignId` | integer (int64) | The campaign the prompt belongs to. Null on a prompt that belongs only to a segment. |
| `segmentId` | integer (int64) | The segment the prompt belongs to, or null. |
| `segmentName` | string | The segment's name, or null. |
| `promptTemplateId` | integer (int64) | The prompt template the prompt is part of, or null. |
| `toOutput` | boolean | On a personalization prompt, true when the AI writes the prompt's result as an AI variable for the emails. False when the prompt only adds context. |
| `toRewrite` | integer (int32) | Above 0 when the rewriting step rewrites this AI variable. 0 leaves it as written. |
| `order` | integer (int32) | Where the prompt sits among its campaign's prompts. Lower numbers come first. |
| `fallbackIfEmpty` | string | The text to use when the AI variable comes out empty. A fallback written in the step itself wins over it. Null when there is none. |
| `isRequiredForSending` | boolean | True when a contact cannot be sent to while this AI variable is empty and there is no fallback to use. |
| `createdAt` | string (date-time) | When the prompt was created, in UTC. |
| `updatedAt` | string (date-time) | When the prompt last changed, in UTC. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/prompts" \
  -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 '{
  "name": "string",
  "prompt": "string",
  "audienceDescription": "string",
  "qualificationCriteria": "string",
  "disqualificationCriteria": "string",
  "scoringCriteria": "string",
  "type": "system",
  "flow": "qualification",
  "campaignId": 812,
  "segmentId": 812,
  "promptTemplateId": 812,
  "toOutput": true,
  "toRewrite": 1,
  "order": 1,
  "fallbackIfEmpty": "string",
  "isRequiredForSending": true
}'
```

### Example response

```json
{
  "success": true,
  "data": {
    "id": 812,
    "name": "string",
    "prompt": "string",
    "audienceDescription": "string",
    "qualificationCriteria": "string",
    "disqualificationCriteria": "string",
    "scoringCriteria": "string",
    "type": "system",
    "flow": "qualification",
    "campaignId": 812,
    "segmentId": 812,
    "segmentName": "string",
    "promptTemplateId": 812,
    "toOutput": true,
    "toRewrite": 1,
    "order": 1,
    "fallbackIfEmpty": "string",
    "isRequiredForSending": true,
    "createdAt": "2026-09-23T15:02:11Z",
    "updatedAt": "2026-09-23T15:02:11Z"
  }
}
```
