> 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: Test prompts on sample contacts

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

## Test prompts on sample contacts

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

| Permission | Rate limit |
| --- | --- |
| Campaigns edit and the `ask` permission | 30 requests a minute and 200 a day per workspace (Free plan: 3 a minute and 20 a day) |

Runs the campaign's `qualification`, `segmentation` or `personalization` prompts on a random
sample of its contacts and returns each result without saving it. Each sample calls the AI model and spends
model usage, shown in `estimatedCostUsd`.

Errors:

- `400 validation_failed`: a field is not valid, or the campaign has fewer eligible contacts than
`sampleSize`.
- `404 not_found`: the campaign or segment is not in this workspace.
- `429 rate_limited`: the workspace reached its AI limit. Try again later.

Requires Campaigns edit and the `ask` permission.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `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 |
| --- | --- | --- | --- |
| `campaignId` | integer (int64) | yes | The campaign whose prompts run. Required. |
| `flow` | string | yes | The flow to test: `qualification`, `segmentation` or `personalization`. Required. |
| `sampleSize` | integer (int32) | no | How many contacts to sample, from 1 to 100. Defaults to 10. |
| `segmentId` | integer (int64) | no | On a personalization test, the segment whose prompts run. Omit it to run the campaign's default segment. Not accepted on other flows. |
| `modelOverrides` | map of PromptTestOverrideRequest | no | Models to use for this run only, keyed by flow. Set only the tested flow, plus `rewriting` on a personalization test. |
| `excludeContactIds` | array of integer (int64) | no | Contact ids to leave out of the sample. Each id must be above 0. |

### Response 200

`data` is a `PromptTestResult`.

| Field | Type | Description |
| --- | --- | --- |
| `campaignId` | integer (int64) | The campaign that was tested. |
| `flow` | string | The flow that was tested: `qualification`, `segmentation` or `personalization`. |
| `requestedSampleSize` | integer (int32) | How many contacts you asked for. |
| `returnedSampleSize` | integer (int32) | How many samples came back. |
| `segmentId` | integer (int64) | The segment whose prompts ran, on a personalization test. Null otherwise. |
| `provider` | string | The AI provider the test ran on. |
| `model` | string | The model the test ran on. |
| `cacheStrategy` | string | How the prompt was cached for the model calls, such as `none`. |
| `successCount` | integer (int32) | How many samples succeeded. |
| `failureCount` | integer (int32) | How many samples failed. |
| `usageSummary` | PromptTestUsage | Average token use and the estimated cost, or null. |
| `samples` | array of PromptTestSample | One result per sampled contact. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/prompts/test" \
  -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 '{
  "campaignId": 812,
  "flow": "qualification",
  "sampleSize": 1,
  "segmentId": 812,
  "modelOverrides": {
    "key": {
      "model": "string",
      "maxTokens": 1,
      "temperature": 0.5,
      "reasoningLevel": "none"
    }
  },
  "excludeContactIds": [
    812
  ]
}'
```

### Example response

```json
{
  "success": true,
  "data": {
    "campaignId": 812,
    "flow": "qualification",
    "requestedSampleSize": 1,
    "returnedSampleSize": 1,
    "segmentId": 812,
    "provider": "string",
    "model": "string",
    "cacheStrategy": "none",
    "successCount": 1,
    "failureCount": 1,
    "usageSummary": {
      "averageInputTokens": 1,
      "averageCacheReadTokens": 1,
      "averageOutputTokens": 1,
      "totalEstimatedCostUsd": 0.5,
      "averageEstimatedCostUsd": 0.5
    },
    "samples": [
      {
        "contactId": 812,
        "fullName": "Jane Doe",
        "linkedInUrl": "https://example.com",
        "title": "string",
        "companyName": "Acme",
        "segmentId": 812,
        "segmentName": "string",
        "success": true,
        "provider": "string",
        "model": "string",
        "cacheStrategy": "string",
        "rewritingProvider": "string",
        "rewritingModel": "string",
        "rewritingCacheStrategy": "string",
        "usage": {
          "inputTokens": 1,
          "outputTokens": 1,
          "totalTokens": 1,
          "cacheCreationTokens": 1,
          "cacheReadTokens": 1,
          "reasoningTokens": 1
        },
        "estimatedCostUsd": 0.5,
        "errorMessage": "string",
        "isQualified": true,
        "qualificationResponse": "string",
        "matchedSegmentName": "string",
        "segmentationReasoning": "string",
        "personalizationOutputs": [
          {
            "name": "string",
            "value": "string"
          }
        ],
        "rewritingOutputs": [
          {
            "name": "string",
            "value": "string"
          }
        ],
        "finalOutputs": [
          {
            "name": "string",
            "value": "string"
          }
        ]
      }
    ]
  }
}
```

## Types

Each named type the tables above use, nested ones included.

### PromptTestOverrideRequest

A model to try for one flow in a prompt test.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `model` | string | yes | The model id. Required, and it must be a model the flow supports. |
| `maxTokens` | integer (int32) | no | The most tokens the model may write, from 1 to 200,000. Omit it to keep the flow's setting. |
| `temperature` | number (double) | no | The sampling temperature, from 0 to 2. Omit it to keep the flow's setting. |
| `reasoningLevel` | string | no | How much the model reasons before it answers: `none`, `minimal`, `low`, `medium` or `high`. Omit it to keep the flow's setting. |

### PromptTestUsage

Token use and cost across a prompt test.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `averageInputTokens` | integer (int32) | no | Average input tokens per sample. |
| `averageCacheReadTokens` | integer (int32) | no | Average input tokens per sample that were read from the provider's cache. |
| `averageOutputTokens` | integer (int32) | no | Average output tokens per sample. |
| `totalEstimatedCostUsd` | number (double) | no | The estimated cost of the whole test, in US dollars. |
| `averageEstimatedCostUsd` | number (double) | no | The estimated cost per sample, in US dollars. |

### PromptTestSample

One contact's result in a prompt test.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `contactId` | integer (int64) | no | The sampled contact. |
| `fullName` | string | no | The contact's full name. |
| `linkedInUrl` | string | no | The contact's LinkedIn profile link. |
| `title` | string | no | The contact's job title. |
| `companyName` | string | no | The contact's company name. |
| `segmentId` | integer (int64) | no | The contact's segment, or null. |
| `segmentName` | string | no | The contact's segment name, or null. |
| `success` | boolean | no | True when the sample ran and the AI's answer could be read. |
| `provider` | string | no | The AI provider this sample ran on. |
| `model` | string | no | The model this sample ran on. |
| `cacheStrategy` | string | no | How the prompt was cached for this sample's call. |
| `rewritingProvider` | string | no | The rewriting call's AI provider, or null when there was none. |
| `rewritingModel` | string | no | The rewriting call's model, or null when there was none. |
| `rewritingCacheStrategy` | string | no | How the rewriting call's prompt was cached, or null. |
| `usage` | PromptTestTokenUsage | no | This sample's token use, or null. |
| `estimatedCostUsd` | number (double) | no | This sample's estimated cost, in US dollars. |
| `errorMessage` | string | no | Why the sample failed, or null when it succeeded. |
| `isQualified` | boolean | no | On a qualification test, whether the contact qualified. Null otherwise. |
| `qualificationResponse` | string | no | On a qualification test, the AI's full answer. Null otherwise. |
| `matchedSegmentName` | string | no | On a segmentation test, the segment the AI picked. Null otherwise. |
| `segmentationReasoning` | string | no | On a segmentation test, why the AI picked that segment. Null otherwise. |
| `personalizationOutputs` | array of PromptTestOutput | no | On a personalization test, each AI variable as the AI first wrote it. |
| `rewritingOutputs` | array of PromptTestOutput | no | On a personalization test, each AI variable the rewriting step rewrote. |
| `finalOutputs` | array of PromptTestOutput | no | On a personalization test, each AI variable as it would go out, after rewriting. |

### PromptTestTokenUsage

Token use of one sample.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `inputTokens` | integer (int32) | no | Tokens sent to the model. |
| `outputTokens` | integer (int32) | no | Tokens the model wrote. |
| `totalTokens` | integer (int32) | no | Input and output tokens together. |
| `cacheCreationTokens` | integer (int32) | no | Input tokens written to the provider's cache. |
| `cacheReadTokens` | integer (int32) | no | Input tokens read from the provider's cache. |
| `reasoningTokens` | integer (int32) | no | Tokens the model spent reasoning before it answered. |

### PromptTestOutput

One AI variable's value in a prompt test.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | The AI variable's name. |
| `value` | string | no | The value written for the contact. |
