{"openapi":"3.0.4","info":{"title":"Kenso API: AI prompts","version":"1.1","description":"The AI prompts endpoints of the Kenso API, with every component they use. The full spec is https://api.ken.so/v1/docs/openapi.json. Every request sends `Authorization: Bearer <your API key>` and `Ken-Version: 2026-11-02`."},"servers":[{"url":"https://api.ken.so"}],"security":[{"Bearer":[]}],"tags":[{"name":"prompts","description":"Prompts are the instructions Kenso's AI follows for a campaign's contacts. Each prompt belongs to a campaign or a\nsegment, and to a flow: qualification, segmentation, scoring, personalization (which writes AI variables) or\nrewriting. A change that would clear AI results Kenso already made asks you to confirm it first.","x-displayName":"AI prompts"}],"paths":{"/v1/prompts":{"get":{"tags":["prompts"],"summary":"List prompts","description":"Returns the workspace's prompts in id order. Filter with `campaignId`, `segmentId`, `flow` and\n`q`, which matches the name.\n            \nErrors:\n            \n- `400 validation_failed`: a filter, `limit` or `cursor` is not valid.\n- `404 not_found`: the campaign or segment is not in this workspace.\n            \nRequires Campaigns view.\n\nRate limit: 12,000 calls a minute per API key, on top of the workspace limits.","operationId":"prompts.list","parameters":[{"name":"campaignId","in":"query","description":"Only this campaign's prompts.","schema":{"type":"integer","format":"int64"}},{"name":"segmentId","in":"query","description":"Only this segment's prompts. With `campaignId`, the segment must be in that campaign.","schema":{"type":"integer","format":"int64"}},{"name":"flow","in":"query","description":"Only prompts of this flow: `qualification`, `personalization`, `rewriting`, `segmentation`,\n`tone_of_voice` or `scoring`.","schema":{"type":"string"}},{"name":"q","in":"query","description":"Only prompts whose name matches this text, at most 200 characters.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"How many prompts to return, from 1 to 200. Defaults to 50.","schema":{"maximum":200,"minimum":1,"type":"integer","format":"int32","default":50}},{"name":"cursor","in":"query","description":"The `nextCursor` of the previous page. Omit it for the first page.","schema":{"type":"string"}},{"name":"Ken-Version","in":"header","description":"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.","schema":{"enum":["2026-11-02","1.1"],"type":"string"},"examples":{"default":{"value":"2026-11-02","x-disabled":false}}},{"name":"X-Ken-Workspace-Id","in":"header","description":"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`.","schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromptListResponse"}}}},"400":{"description":"Bad Request","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["unsupported_version","validation_failed","workspace_required"]},"401":{"description":"Unauthorized","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}},"x-ken-error-codes":["unauthenticated"]},"404":{"description":"Not Found","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["not_found"]},"429":{"description":"Too Many Requests","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TooManyRequestsError"}},"text/plain":{"schema":{"$ref":"#/components/schemas/RateLimitedText"}}},"x-ken-error-codes":["rate_limited"]}},"x-ken-permission":{"kind":"page","page":"campaigns","access":"view","summary":"Campaigns view"},"x-ken-rate-limit":{"limit":12000,"windowSeconds":60,"per":"api_key"}},"post":{"tags":["prompts"],"summary":"Create a prompt","description":"Adds a prompt to a campaign or segment. Send `prompt`, `flow`, `type`, and `campaignId` or\n`segmentId`. Returns `201` with a `Location` header.\n            \nErrors:\n            \n- `400 validation_failed`: a required field is missing or a value is not accepted.\n- `404 not_found`: the campaign, segment or prompt template is not in this workspace.\n- `409 conflict`: the write would clear AI results (see `error.impact`). Set the `confirm`\n  query parameter to true.\n            \nRequires Campaigns edit.\n\nRate limit: 4,800 calls a minute per API key, on top of the workspace limits.","operationId":"prompts.create","parameters":[{"name":"confirm","in":"query","description":"Set to true to go ahead when the change would clear AI results Kenso already made. Default false.","schema":{"type":"boolean"}},{"name":"Ken-Version","in":"header","description":"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.","schema":{"enum":["2026-11-02","1.1"],"type":"string"},"examples":{"default":{"value":"2026-11-02","x-disabled":false}}},{"name":"X-Ken-Workspace-Id","in":"header","description":"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`.","schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePromptRequest"}}}},"responses":{"201":{"description":"Created","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromptResponse"}}}},"400":{"description":"Bad Request","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["unsupported_version","validation_failed","workspace_required"]},"401":{"description":"Unauthorized","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}},"x-ken-error-codes":["unauthenticated"]},"404":{"description":"Not Found","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["not_found"]},"409":{"description":"Conflict","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["conflict"]},"429":{"description":"Too Many Requests","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TooManyRequestsError"}},"text/plain":{"schema":{"$ref":"#/components/schemas/RateLimitedText"}}},"x-ken-error-codes":["rate_limited"]}},"x-ken-permission":{"kind":"page","page":"campaigns","access":"edit","summary":"Campaigns edit"},"x-ken-rate-limit":{"limit":4800,"windowSeconds":60,"per":"api_key"}}},"/v1/prompts/{promptId}":{"get":{"tags":["prompts"],"summary":"Get a prompt","description":"Returns one prompt.\n            \nErrors:\n            \n- `404 not_found`: the prompt is not in this workspace.\n            \nRequires Campaigns view.\n\nRate limit: 12,000 calls a minute per API key, on top of the workspace limits.","operationId":"prompts.get","parameters":[{"name":"promptId","in":"path","description":"The prompt's id.","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"Ken-Version","in":"header","description":"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.","schema":{"enum":["2026-11-02","1.1"],"type":"string"},"examples":{"default":{"value":"2026-11-02","x-disabled":false}}},{"name":"X-Ken-Workspace-Id","in":"header","description":"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`.","schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromptResponse"}}}},"400":{"description":"Bad Request","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["unsupported_version","workspace_required"]},"401":{"description":"Unauthorized","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}},"x-ken-error-codes":["unauthenticated"]},"404":{"description":"Not Found","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["not_found"]},"429":{"description":"Too Many Requests","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TooManyRequestsError"}},"text/plain":{"schema":{"$ref":"#/components/schemas/RateLimitedText"}}},"x-ken-error-codes":["rate_limited"]}},"x-ken-permission":{"kind":"page","page":"campaigns","access":"view","summary":"Campaigns view"},"x-ken-rate-limit":{"limit":12000,"windowSeconds":60,"per":"api_key"}},"patch":{"tags":["prompts"],"summary":"Update a prompt","description":"Changes the fields you send, the same fields as a new prompt, and keeps the rest. `null` clears a text\nfield or `promptTemplateId`. `segmentId` cannot change, and a prompt without a segment keeps its\n`campaignId`.\n            \nErrors:\n            \n- `400 validation_failed`: the body is empty, names an unknown field, or breaks a rule above.\n- `404 not_found`: the prompt, campaign, segment or prompt template is not in this workspace.\n- `409 conflict`: the write would clear AI results (see `error.impact`). Set the `confirm`\n  query parameter to true to clear them, or `keepExistingOutput` to true to keep them.\n            \nRequires Campaigns edit.\n\nRate limit: 4,800 calls a minute per API key, on top of the workspace limits.","operationId":"prompts.update","parameters":[{"name":"promptId","in":"path","description":"The prompt's id.","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"confirm","in":"query","description":"Set to true to go ahead when the change would clear AI results Kenso already made. Default false.","schema":{"type":"boolean"}},{"name":"keepExistingOutput","in":"query","description":"Set to true to save the change and keep the AI results Kenso already made:\n             leads that have output keep it, and leads processed from now on use the new prompt. For a writing prompt, only\n             leads without copy are written. Nothing is cleared and the 409 is never returned. Default false.","schema":{"type":"boolean"}},{"name":"Ken-Version","in":"header","description":"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.","schema":{"enum":["2026-11-02","1.1"],"type":"string"},"examples":{"default":{"value":"2026-11-02","x-disabled":false}}},{"name":"X-Ken-Workspace-Id","in":"header","description":"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`.","schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{}}}},"responses":{"200":{"description":"OK","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromptResponse"}}}},"400":{"description":"Bad Request","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["unsupported_version","validation_failed","workspace_required"]},"401":{"description":"Unauthorized","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}},"x-ken-error-codes":["unauthenticated"]},"404":{"description":"Not Found","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["not_found"]},"409":{"description":"Conflict","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["conflict"]},"429":{"description":"Too Many Requests","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TooManyRequestsError"}},"text/plain":{"schema":{"$ref":"#/components/schemas/RateLimitedText"}}},"x-ken-error-codes":["rate_limited"]}},"x-ken-permission":{"kind":"page","page":"campaigns","access":"edit","summary":"Campaigns edit"},"x-ken-rate-limit":{"limit":4800,"windowSeconds":60,"per":"api_key"}},"delete":{"tags":["prompts"],"summary":"Delete a prompt","description":"Deletes a prompt. Returns `204`.\n            \nErrors:\n            \n- `404 not_found`: the prompt is not in this workspace.\n- `409 conflict`: the delete would clear AI results (see `error.impact`). Set the `confirm`\n  query parameter to true.\n            \nRequires Campaigns edit.\n\nRate limit: 4,800 calls a minute per API key, on top of the workspace limits.","operationId":"prompts.delete","parameters":[{"name":"promptId","in":"path","description":"The prompt's id.","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"confirm","in":"query","description":"Set to true to go ahead when the change would clear AI results Kenso already made. Default false.","schema":{"type":"boolean"}},{"name":"Ken-Version","in":"header","description":"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.","schema":{"enum":["2026-11-02","1.1"],"type":"string"},"examples":{"default":{"value":"2026-11-02","x-disabled":false}}},{"name":"X-Ken-Workspace-Id","in":"header","description":"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`.","schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"No Content","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}}},"400":{"description":"Bad Request","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["unsupported_version","workspace_required"]},"401":{"description":"Unauthorized","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}},"x-ken-error-codes":["unauthenticated"]},"404":{"description":"Not Found","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["not_found"]},"409":{"description":"Conflict","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["conflict"]},"429":{"description":"Too Many Requests","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TooManyRequestsError"}},"text/plain":{"schema":{"$ref":"#/components/schemas/RateLimitedText"}}},"x-ken-error-codes":["rate_limited"]}},"x-ken-permission":{"kind":"page","page":"campaigns","access":"edit","summary":"Campaigns edit"},"x-ken-rate-limit":{"limit":4800,"windowSeconds":60,"per":"api_key"}}},"/v1/prompts/test":{"post":{"tags":["prompts"],"summary":"Test prompts on sample contacts","description":"Runs the campaign's `qualification`, `segmentation` or `personalization` prompts on a random\nsample of its contacts and returns each result without saving it. Each sample calls the AI model and spends\nmodel usage, shown in `estimatedCostUsd`.\n            \nErrors:\n            \n- `400 validation_failed`: a field is not valid, or the campaign has fewer eligible contacts than\n  `sampleSize`.\n- `404 not_found`: the campaign or segment is not in this workspace.\n- `429 rate_limited`: the workspace reached its AI limit. Try again later.\n            \nRequires Campaigns edit and the `ask` permission.\n\nRate limit: 200 calls a minute per API key, on top of the workspace limits.","operationId":"prompts.test","parameters":[{"name":"Ken-Version","in":"header","description":"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.","schema":{"enum":["2026-11-02","1.1"],"type":"string"},"examples":{"default":{"value":"2026-11-02","x-disabled":false}}},{"name":"X-Ken-Workspace-Id","in":"header","description":"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`.","schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestPromptRequest"}}}},"responses":{"200":{"description":"OK","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromptTestResultResponse"}}}},"400":{"description":"Bad Request","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["unsupported_version","validation_failed","workspace_required"]},"401":{"description":"Unauthorized","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}},"x-ken-error-codes":["unauthenticated"]},"404":{"description":"Not Found","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Failure"}}},"x-ken-error-codes":["not_found"]},"429":{"description":"Too Many Requests","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TooManyRequestsError"}},"text/plain":{"schema":{"$ref":"#/components/schemas/RateLimitedText"}}},"x-ken-error-codes":["rate_limited"]}},"x-ken-permission":{"kind":"page","page":"campaigns","access":"edit","features":["ask"],"summary":"Campaigns edit and the `ask` permission"},"x-ken-rate-limit":{"limit":200,"windowSeconds":60,"per":"api_key","summary":"30 requests a minute and 200 a day per workspace (Free plan: 3 a minute and 20 a day)","quotas":[{"policy":"aiFlowExecute","per":"workspace","limits":[{"limit":30,"windowSeconds":60},{"limit":200,"windowSeconds":86400}],"plans":[{"plan":"Free","limits":[{"limit":3,"windowSeconds":60},{"limit":20,"windowSeconds":86400}]}]}]}}}},"components":{"securitySchemes":{"Bearer":{"type":"http","description":"Enter: Bearer {your Kenso API key}. Create one in the Kenso app under Settings > Integrations > API Keys.","scheme":"bearer","bearerFormat":"Opaque API key"}},"headers":{"RateLimit-Limit":{"description":"The request limit of the rate limit this request is closest to reaching: your plan's limit for this kind of call, your API key's own limit, or the operation's own limit, whichever has the fewest requests left.","schema":{"type":"integer"}},"RateLimit-Remaining":{"description":"The requests left under that limit. `0` on a `429`.","schema":{"type":"integer"}},"RateLimit-Reset":{"description":"The seconds until that limit resets.","schema":{"type":"integer"}}},"schemas":{"ApiKeyError":{"required":["error"],"type":"object","properties":{"error":{"type":"string","description":"A sentence for people that says what went wrong. It can change, so do not parse it."}},"additionalProperties":false,"description":"The body the API key check in front of the operations answered until November 2026, instead of the error body (`Failure`): `{ \"error\": \"Invalid or revoked API key\" }` on a `401`, `{ \"error\": \"Rate limit exceeded\" }` on a `429` and `{ \"error\": \"Authentication is temporarily unavailable\" }` on a `503`. It has no `code`, so branch on the HTTP status."},"CreatePromptRequest":{"required":["prompt","type","flow"],"type":"object","properties":{"name":{"type":"string","description":"The prompt's name. On a personalization prompt with `toOutput` true, it is also the AI variable's name.","nullable":true},"prompt":{"type":"string","description":"The instructions the AI follows. Required."},"audienceDescription":{"type":"string","description":"Who the campaign targets. Kenso adds it to the qualification, scoring and personalization prompts.","nullable":true},"qualificationCriteria":{"type":"string","description":"What makes a contact a fit. Qualification and scoring read it.","nullable":true},"disqualificationCriteria":{"type":"string","description":"What rules a contact out. Qualification and scoring read it.","nullable":true},"scoringCriteria":{"type":"string","description":"What makes a contact a good or a poor fit. A scoring prompt needs it to run.","nullable":true},"type":{"type":"string","description":"The message role the prompt is sent as: `system`, `user` or `assistant`. Required."},"flow":{"type":"string","description":"The step the prompt belongs to: `qualification`, `personalization`, `rewriting`,\n`segmentation` or `scoring`. Required."},"campaignId":{"type":"integer","description":"The campaign the prompt belongs to. Send it, `segmentId`, or both.","format":"int64","nullable":true},"segmentId":{"type":"integer","description":"The segment the prompt belongs to. With `campaignId`, the segment must be in that campaign.","format":"int64","nullable":true},"promptTemplateId":{"type":"integer","description":"A prompt template of this workspace to add the prompt to. Optional.","format":"int64","nullable":true},"toOutput":{"type":"boolean","description":"On a personalization prompt, true to have the AI write the result as an AI variable for the emails. Defaults to\nfalse.","nullable":true},"toRewrite":{"type":"integer","description":"Above 0 to have the rewriting step rewrite this AI variable. Optional.","format":"int32","nullable":true},"order":{"type":"integer","description":"Where the prompt sits among its campaign's prompts. Lower numbers come first. Defaults to 0.","format":"int32","nullable":true},"fallbackIfEmpty":{"type":"string","description":"The text to use when the AI variable comes out empty. Optional.","nullable":true},"isRequiredForSending":{"type":"boolean","description":"True to hold a contact from sending while this AI variable is empty and there is no fallback. Defaults to false.","nullable":true}},"additionalProperties":false,"description":"A new prompt."},"ErrorAccount":{"type":"object","properties":{"accountId":{"type":"integer","description":"The account's id.","format":"int64"},"name":{"type":"string","description":"The account's name."},"stakeholderId":{"type":"integer","description":"The person's stakeholder id on this account.","format":"int64"}},"additionalProperties":false,"description":"An account named in an error detail."},"ErrorBody":{"type":"object","properties":{"code":{"type":"string","description":"Stable error code, such as `validation_failed` or `not_found`. Branch on this value."},"message":{"type":"string","description":"A sentence for people that explains the error. It can change, so do not parse it."},"details":{"type":"array","items":{"$ref":"#/components/schemas/ErrorDetail"},"description":"One entry per problem, naming the field or limit it is about. Omitted when there are none.","nullable":true},"requestId":{"type":"string","description":"The id of this request: the same value as the `X-Correlation-Id` response header. Quote it when you write\nto contact@ken.so."},"docUrl":{"type":"string","description":"The page on this code in the developer docs, which says what it means and how to fix it. The errors guide for a\ncode that has no page of its own.","readOnly":true},"refusal":{"allOf":[{"$ref":"#/components/schemas/Refusal"}],"description":"On a `402`, the plan rule or usage limit that refused the request and how to lift it. Omitted otherwise."},"impact":{"allOf":[{"$ref":"#/components/schemas/InvalidationImpact"}],"description":"On a `409` that refuses a change because it would clear stored AI output (a prompt edit, a restore or a\nreset), how much the change would clear. Omitted otherwise."},"surface":{"type":"string","description":"Set only by the voice ticket's `409` (code `voice_conversation_active`): the chat the person's other\nvoice conversation runs in, `support`, `ken` or `onboarding`. Omitted on every other error.","nullable":true}},"additionalProperties":false,"description":"What went wrong in a request."},"ErrorDetail":{"type":"object","properties":{"field":{"type":"string","description":"The request field, header or limit the problem is about, such as `name` or `Ken-Version`."},"code":{"type":"string","description":"Stable code for this problem, such as `required` or `invalid`."},"message":{"type":"string","description":"A sentence for people that explains this problem."},"count":{"type":"integer","description":"On `export_limit_exceeded`, how many rows match the export. Omitted otherwise.","format":"int32","nullable":true},"index":{"type":"integer","description":"The position of the refused item in the request's list. Omitted otherwise.","format":"int32","nullable":true},"limit":{"type":"integer","description":"On `export_limit_exceeded`, the row limit the export ran with. On a `quota_exceeded` detail whose\n`field` names a quota, that quota's limit. On a `rate_limited` detail from your workspace's rate\nlimits, the limit that was hit. Omitted otherwise.","format":"int32","nullable":true},"resetAt":{"type":"string","description":"On some `quota_exceeded` details, when the quota frees up, in UTC. It is the same instant as the top-level\n`quotaResetAt`. On a `rate_limited` detail from your workspace's rate limits, when that limit resets.\nOmitted otherwise.","format":"date-time","nullable":true},"retryAfterSeconds":{"type":"integer","description":"On those `quota_exceeded` details and on most `rate_limited` details, the seconds to wait. It is the\nsame value as the `Retry-After` header. Omitted otherwise.","format":"int32","nullable":true},"inboxId":{"type":"integer","description":"The inbox the problem is about. Omitted otherwise.","format":"int64","nullable":true},"domainId":{"type":"integer","description":"The domain the problem is about. Omitted otherwise.","format":"int64","nullable":true},"domainName":{"type":"string","description":"The name of that domain, or the domain name the request gave. Omitted otherwise.","nullable":true},"accountId":{"type":"integer","description":"On `domain_taken`, `already_stakeholder` and `previously_removed`, the existing account to use\ninstead. Omitted otherwise.","format":"int64","nullable":true},"personId":{"type":"integer","description":"On `email_taken` and `linkedin_url_taken`, the existing person to use instead. Omitted otherwise.","format":"int64","nullable":true},"stakeholderId":{"type":"integer","description":"The account stakeholder the problem is about. Omitted otherwise.","format":"int64","nullable":true},"championId":{"type":"integer","description":"Not used. Always omitted.","format":"int64","nullable":true},"callTaskId":{"type":"integer","description":"On `call_task_exists`, the open call task that already holds the person's slot. Omitted otherwise.","format":"int64","nullable":true},"status":{"type":"string","description":"On `invalid_transition`, the current status. Omitted otherwise.","nullable":true},"allowed":{"type":"array","items":{"type":"string"},"description":"On `out_of_range`, the allowed values. On `invalid_transition`, the statuses the change is allowed\nfrom. Omitted otherwise.","nullable":true},"scope":{"type":"string","description":"On a `permission_denied` for an account owner change, the account scope the call needs (`all`). On\n`sending_paused`, what the pause covers: `inbox`, `domain` or `workspace`. Omitted otherwise.","nullable":true},"removedAt":{"type":"string","description":"On `previously_removed`, when a person removed the stakeholder, in UTC. Omitted otherwise.","format":"date-time","nullable":true},"page":{"type":"string","description":"On `permission_denied`, the page the call needs, such as `campaigns`. Omitted otherwise.","nullable":true},"required":{"type":"string","description":"On `permission_denied`, the access `page` needs: `view` or `edit`. Omitted otherwise.","nullable":true},"feature":{"type":"string","description":"On `permission_denied`, the permission the call needs, such as `launch`. Omitted otherwise.","nullable":true},"runId":{"type":"integer","description":"On `committee_run_active` and `run_not_finding`, the committee run the problem is about. Omitted\notherwise.","format":"int64","nullable":true},"mergedIntoId":{"type":"integer","description":"On `person_merged`, the person the merged person now lives on. On `account_merged`, the account the\nmerged account now lives on. Omitted otherwise.","format":"int64","nullable":true},"accounts":{"type":"array","items":{"$ref":"#/components/schemas/ErrorAccount"},"description":"On `person_on_accounts`, the accounts that block the change. Omitted otherwise.","nullable":true},"stage":{"type":"string","description":"On `stage_in_use` and `system_stage`, the opportunity stage key the problem is about. Omitted otherwise.","nullable":true},"opportunityCount":{"type":"integer","description":"On `stage_in_use`, how many opportunities are in that stage. Omitted otherwise.","format":"int32","nullable":true},"rule":{"type":"string","description":"On `guardrail_violation`, the contact limit rule the change breaks. Omitted otherwise.","nullable":true},"nextAllowedAt":{"type":"string","description":"On `guardrail_violation`, the first `dueAt` that passes every contact limit, in UTC. On a refused\nsend, when to retry. Omitted otherwise, and when waiting does not clear it.","format":"date-time","nullable":true},"fix":{"type":"string","description":"On a refused send, what to do next, in plain words. Omitted otherwise.","nullable":true},"opensAt":{"type":"string","description":"On `outside_calling_hours`, when the person's calling window opens, in UTC. Omitted otherwise.","format":"date-time","nullable":true},"currentVersion":{"type":"integer","description":"On a knowledge file's `version_conflict`, the file's current version. Omitted otherwise.","format":"int32","nullable":true},"provider":{"type":"string","description":"On a CRM connection error (`provider_error`, `exchange_failed`, `already_connected`,\n`account_mismatch` or `provider_unavailable`), the CRM it is about. Omitted otherwise.","nullable":true},"sharedWithMaster":{"type":"boolean","description":"True on a `quota_exceeded` detail when the shared limit of the white-label master workspace was hit, so\n`limit` is the limit of the whole white-label account. Omitted otherwise. The master's id is never sent.","nullable":true},"stepId":{"type":"integer","description":"On `link_reputation_blocked`, the saved sequence step that holds the blocked link. Omitted otherwise, and\nfor a step the save would have created.","format":"int64","nullable":true},"stepOrder":{"type":"integer","description":"On `link_reputation_blocked`, the `stepOrder` of that step. Omitted otherwise.","format":"int32","nullable":true},"url":{"type":"string","description":"On `link_reputation_blocked`, the blocked link as the step's copy writes it. Omitted otherwise.","nullable":true},"key":{"type":"string","description":"On `unfilled_template_key`, the template key the text still holds, such as `first_name` for\n`{first_name}`. Omitted otherwise.","nullable":true},"marker":{"type":"string","description":"On `unfilled_template_key`, that key as the text writes it, such as `{first_name}` or `[company]`.\nOmitted otherwise.","nullable":true},"retryAt":{"type":"string","description":"On a warm path Start's `guardrail_connector_monthly`, `guardrail_account_monthly`,\n`guardrail_connector_cooldown` and `guardrail_handoff_weekly`, when the limit frees up, in UTC. Omitted\notherwise.","format":"date-time","nullable":true},"workspaceId":{"type":"integer","description":"On `last_admin`, a workspace that needs a new admin before the account can be deleted. On\n`new_admin_not_found`, the workspace of the refused choice. Omitted otherwise.","format":"int64","nullable":true},"workspaceName":{"type":"string","description":"On `last_admin`, the name of that workspace. Omitted otherwise.","nullable":true},"class":{"type":"string","description":"On a `rate_limited` detail from your workspace's rate limits, the class of call that hit its limit:\n`read`, `write`, `bulk`, `heavy` or `sensitive`. Omitted otherwise.","nullable":true},"window":{"type":"string","description":"On that detail, the window whose limit was hit: `minute`, `day` or `bulkItemsDay`. Omitted\notherwise.","nullable":true}},"additionalProperties":false,"description":"One problem in an error: the field or limit it is about, a stable `code` and a `message`. The other fields\nappear only with the codes their descriptions name."},"Failure":{"type":"object","properties":{"success":{"type":"boolean","description":"Always false on an error."},"error":{"allOf":[{"$ref":"#/components/schemas/ErrorBody"}],"description":"What went wrong."},"quotaResetAt":{"type":"string","description":"When the quota that refused the request frees up, in UTC. Set on some quota refusals. Omitted otherwise.","format":"date-time","nullable":true},"currentVersion":{"type":"integer","description":"The current revision of a workflow draft, on a draft save's `409 version_conflict`. Read the workflow\nagain, then send this value as `baseVersion`. Omitted otherwise.","format":"int32","nullable":true},"current":{"allOf":[{"$ref":"#/components/schemas/MeetingRepNotesCurrent"}],"description":"Your meeting notes and their version as stored now, on a meeting notes save's `409 version_conflict`.\nMerge your change, then save again with `baseVersion` set to `current.repNotesVersion`. Omitted\notherwise."},"refusal":{"allOf":[{"$ref":"#/components/schemas/Refusal"}],"description":"A copy of `error.refusal`, set on some billing refusals. Omitted otherwise."},"message":{"type":"string","description":"A copy of `error.message`, set together with `refusal`. Omitted otherwise.","nullable":true},"lookalikeSeeds":{"description":"How Kenso read each seed of a lookalike search, on its `422 no_usable_seeds`:\n`{resolved: [{input, companyId, personId, name, domain}], unresolved: [{input, reason}]}`. Use it to show\nwhy no seed was usable. Omitted otherwise."}},"additionalProperties":false,"description":"The body of every error, with a 4xx or 5xx status. Branch on `error.code`."},"InvalidationImpact":{"type":"object","properties":{"qualificationResponses":{"type":"integer","description":"Stored qualification answers the change would clear.","format":"int32"},"qualifiedFlags":{"type":"integer","description":"Contacts whose qualified result the change would clear.","format":"int32"},"segmentationReasoning":{"type":"integer","description":"Stored segmentation explanations the change would clear.","format":"int32"},"segmentationAssignmentsKept":{"type":"integer","description":"Contacts that keep their segment.","format":"int32"},"segmentationAssignmentsReset":{"type":"integer","description":"Contacts that go back to the default segment.","format":"int32"},"personalizationLines":{"type":"integer","description":"Personalized lines the change would clear.","format":"int32"},"personalizationLeads":{"type":"integer","description":"Contacts that would lose their personalized lines.","format":"int32"},"rewritingLines":{"type":"integer","description":"Rewritten lines the change would clear.","format":"int32"},"rewritingLeads":{"type":"integer","description":"Contacts that would lose their rewritten lines.","format":"int32"}},"additionalProperties":false,"description":"How much stored AI output a change would clear in each AI step of a campaign, and how many segment assignments it\nkeeps or resets."},"MeetingRepNotesCurrent":{"type":"object","properties":{"repNotes":{"type":"string","description":"Your notes as stored now. Empty before your first save."},"repNotesVersion":{"type":"integer","description":"The stored notes' version. Send it as `baseVersion` when you save again.","format":"int32"}},"additionalProperties":false,"description":"Your meeting notes as Kenso stores them now, sent with a `409 version_conflict` on a notes save."},"Pagination":{"type":"object","properties":{"nextCursor":{"type":"string","description":"Send this value as `cursor` to get the next page. Omitted on the last page.","nullable":true},"hasMore":{"type":"boolean","description":"True when more items follow this page. Stop paging when it is false."},"total":{"type":"integer","description":"Deprecated: the same number as `totalCount`. Read `totalCount`.","format":"int32","nullable":true,"deprecated":true},"totalCount":{"type":"integer","description":"The number of items that match the list's filters, across all pages. Omitted when the list does not count them.","format":"int32","nullable":true},"isTotalCapped":{"type":"boolean","description":"True when `totalCount` stopped counting at its cap, so more items match than it says. Keep paging with\n`hasMore`. Omitted when `totalCount` is exact. Only `GET /v1/threads` with `q` caps its total.","nullable":true}},"additionalProperties":false,"description":"Where a list page ends and how to get the next page."},"Prompt":{"type":"object","properties":{"id":{"type":"integer","description":"The prompt's id.","format":"int64"},"name":{"type":"string","description":"The prompt's name. On a personalization prompt with `toOutput` true, it is also the AI variable's name, used\nin steps as `{{name}}`.","nullable":true},"prompt":{"type":"string","description":"The instructions the AI follows.","nullable":true},"audienceDescription":{"type":"string","description":"Who the campaign targets. Kenso adds it to the qualification, scoring and personalization prompts.","nullable":true},"qualificationCriteria":{"type":"string","description":"What makes a contact a fit. Qualification and scoring read it.","nullable":true},"disqualificationCriteria":{"type":"string","description":"What rules a contact out. Qualification and scoring read it.","nullable":true},"scoringCriteria":{"type":"string","description":"What makes a contact a good or a poor fit. A scoring prompt needs it to run.","nullable":true},"type":{"type":"string","description":"The message role the prompt is sent as: `system`, `user` or `assistant`.","nullable":true},"flow":{"type":"string","description":"The step the prompt belongs to: `qualification`, `personalization`, `rewriting`,\n`segmentation`, `scoring`, or `tone_of_voice` on older prompts.","nullable":true},"campaignId":{"type":"integer","description":"The campaign the prompt belongs to. Null on a prompt that belongs only to a segment.","format":"int64","nullable":true},"segmentId":{"type":"integer","description":"The segment the prompt belongs to, or null.","format":"int64","nullable":true},"segmentName":{"type":"string","description":"The segment's name, or null.","nullable":true},"promptTemplateId":{"type":"integer","description":"The prompt template the prompt is part of, or null.","format":"int64","nullable":true},"toOutput":{"type":"boolean","description":"On a personalization prompt, true when the AI writes the prompt's result as an AI variable for the emails.\nFalse when the prompt only adds context."},"toRewrite":{"type":"integer","description":"Above 0 when the rewriting step rewrites this AI variable. 0 leaves it as written.","format":"int32"},"order":{"type":"integer","description":"Where the prompt sits among its campaign's prompts. Lower numbers come first.","format":"int32"},"fallbackIfEmpty":{"type":"string","description":"The text to use when the AI variable comes out empty. A fallback written in the step itself wins over it. Null\nwhen there is none.","nullable":true},"isRequiredForSending":{"type":"boolean","description":"True when a contact cannot be sent to while this AI variable is empty and there is no fallback to use."},"createdAt":{"type":"string","description":"When the prompt was created, in UTC.","format":"date-time"},"updatedAt":{"type":"string","description":"When the prompt last changed, in UTC.","format":"date-time"}},"additionalProperties":false,"description":"A prompt the AI follows for a campaign or a segment."},"PromptListResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Always true on a success."},"data":{"type":"array","items":{"$ref":"#/components/schemas/Prompt"},"description":"The items on this page."},"pagination":{"allOf":[{"$ref":"#/components/schemas/Pagination"}],"description":"Where this page ends and how to get the next one."}},"additionalProperties":false,"description":"The body of a successful list operation: one page of results in `data`, and `pagination` to get the next\npage."},"PromptResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Always true on a success."},"data":{"allOf":[{"$ref":"#/components/schemas/Prompt"}],"description":"The result of the operation."}},"additionalProperties":false,"description":"The body of a successful operation that returns one result. The result is in `data`."},"PromptTestOutput":{"type":"object","properties":{"name":{"type":"string","description":"The AI variable's name."},"value":{"type":"string","description":"The value written for the contact."}},"additionalProperties":false,"description":"One AI variable's value in a prompt test."},"PromptTestOverrideRequest":{"required":["model"],"type":"object","properties":{"model":{"type":"string","description":"The model id. Required, and it must be a model the flow supports."},"maxTokens":{"type":"integer","description":"The most tokens the model may write, from 1 to 200,000. Omit it to keep the flow's setting.","format":"int32","nullable":true},"temperature":{"type":"number","description":"The sampling temperature, from 0 to 2. Omit it to keep the flow's setting.","format":"double","nullable":true},"reasoningLevel":{"type":"string","description":"How much the model reasons before it answers: `none`, `minimal`, `low`, `medium` or\n`high`. Omit it to keep the flow's setting.","nullable":true}},"additionalProperties":false,"description":"A model to try for one flow in a prompt test."},"PromptTestResult":{"type":"object","properties":{"campaignId":{"type":"integer","description":"The campaign that was tested.","format":"int64"},"flow":{"type":"string","description":"The flow that was tested: `qualification`, `segmentation` or `personalization`.","nullable":true},"requestedSampleSize":{"type":"integer","description":"How many contacts you asked for.","format":"int32"},"returnedSampleSize":{"type":"integer","description":"How many samples came back.","format":"int32"},"segmentId":{"type":"integer","description":"The segment whose prompts ran, on a personalization test. Null otherwise.","format":"int64","nullable":true},"provider":{"type":"string","description":"The AI provider the test ran on.","nullable":true},"model":{"type":"string","description":"The model the test ran on.","nullable":true},"cacheStrategy":{"type":"string","description":"How the prompt was cached for the model calls, such as `none`.","nullable":true},"successCount":{"type":"integer","description":"How many samples succeeded.","format":"int32"},"failureCount":{"type":"integer","description":"How many samples failed.","format":"int32"},"usageSummary":{"allOf":[{"$ref":"#/components/schemas/PromptTestUsage"}],"description":"Average token use and the estimated cost, or null."},"samples":{"type":"array","items":{"$ref":"#/components/schemas/PromptTestSample"},"description":"One result per sampled contact."}},"additionalProperties":false,"description":"The result of a prompt test."},"PromptTestResultResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Always true on a success."},"data":{"allOf":[{"$ref":"#/components/schemas/PromptTestResult"}],"description":"The result of the operation."}},"additionalProperties":false,"description":"The body of a successful operation that returns one result. The result is in `data`."},"PromptTestSample":{"type":"object","properties":{"contactId":{"type":"integer","description":"The sampled contact.","format":"int64"},"fullName":{"type":"string","description":"The contact's full name.","nullable":true},"linkedInUrl":{"type":"string","description":"The contact's LinkedIn profile link.","nullable":true},"title":{"type":"string","description":"The contact's job title.","nullable":true},"companyName":{"type":"string","description":"The contact's company name.","nullable":true},"segmentId":{"type":"integer","description":"The contact's segment, or null.","format":"int64","nullable":true},"segmentName":{"type":"string","description":"The contact's segment name, or null.","nullable":true},"success":{"type":"boolean","description":"True when the sample ran and the AI's answer could be read."},"provider":{"type":"string","description":"The AI provider this sample ran on.","nullable":true},"model":{"type":"string","description":"The model this sample ran on.","nullable":true},"cacheStrategy":{"type":"string","description":"How the prompt was cached for this sample's call.","nullable":true},"rewritingProvider":{"type":"string","description":"The rewriting call's AI provider, or null when there was none.","nullable":true},"rewritingModel":{"type":"string","description":"The rewriting call's model, or null when there was none.","nullable":true},"rewritingCacheStrategy":{"type":"string","description":"How the rewriting call's prompt was cached, or null.","nullable":true},"usage":{"allOf":[{"$ref":"#/components/schemas/PromptTestTokenUsage"}],"description":"This sample's token use, or null."},"estimatedCostUsd":{"type":"number","description":"This sample's estimated cost, in US dollars.","format":"double"},"errorMessage":{"type":"string","description":"Why the sample failed, or null when it succeeded.","nullable":true},"isQualified":{"type":"boolean","description":"On a qualification test, whether the contact qualified. Null otherwise.","nullable":true},"qualificationResponse":{"type":"string","description":"On a qualification test, the AI's full answer. Null otherwise.","nullable":true},"matchedSegmentName":{"type":"string","description":"On a segmentation test, the segment the AI picked. Null otherwise.","nullable":true},"segmentationReasoning":{"type":"string","description":"On a segmentation test, why the AI picked that segment. Null otherwise.","nullable":true},"personalizationOutputs":{"type":"array","items":{"$ref":"#/components/schemas/PromptTestOutput"},"description":"On a personalization test, each AI variable as the AI first wrote it."},"rewritingOutputs":{"type":"array","items":{"$ref":"#/components/schemas/PromptTestOutput"},"description":"On a personalization test, each AI variable the rewriting step rewrote."},"finalOutputs":{"type":"array","items":{"$ref":"#/components/schemas/PromptTestOutput"},"description":"On a personalization test, each AI variable as it would go out, after rewriting."}},"additionalProperties":false,"description":"One contact's result in a prompt test."},"PromptTestTokenUsage":{"type":"object","properties":{"inputTokens":{"type":"integer","description":"Tokens sent to the model.","format":"int32"},"outputTokens":{"type":"integer","description":"Tokens the model wrote.","format":"int32"},"totalTokens":{"type":"integer","description":"Input and output tokens together.","format":"int32"},"cacheCreationTokens":{"type":"integer","description":"Input tokens written to the provider's cache.","format":"int32"},"cacheReadTokens":{"type":"integer","description":"Input tokens read from the provider's cache.","format":"int32"},"reasoningTokens":{"type":"integer","description":"Tokens the model spent reasoning before it answered.","format":"int32"}},"additionalProperties":false,"description":"Token use of one sample."},"PromptTestUsage":{"type":"object","properties":{"averageInputTokens":{"type":"integer","description":"Average input tokens per sample.","format":"int32"},"averageCacheReadTokens":{"type":"integer","description":"Average input tokens per sample that were read from the provider's cache.","format":"int32"},"averageOutputTokens":{"type":"integer","description":"Average output tokens per sample.","format":"int32"},"totalEstimatedCostUsd":{"type":"number","description":"The estimated cost of the whole test, in US dollars.","format":"double"},"averageEstimatedCostUsd":{"type":"number","description":"The estimated cost per sample, in US dollars.","format":"double"}},"additionalProperties":false,"description":"Token use and cost across a prompt test."},"RateLimitedText":{"type":"string","description":"The gateway's plain-text body of a `429` over the operation's own limit, until November 2026: `Number of requests exceeded. Please try again later.`","example":"Number of requests exceeded. Please try again later."},"Refusal":{"type":"object","properties":{"code":{"type":"string","description":"Stable refusal code in upper case, such as `CAMPAIGN_LIMIT_REACHED` or `INSUFFICIENT_CREDITS`."},"metric":{"type":"string","description":"What the limit counts: `Campaigns`, `Leads`, `Emails`, `LinkedInSeats` or `AiCredits`,\n`jobs_export_rows` or `funding_export_rows` for an export allowance, `credit_pack_credits`,\n`credit_spend_usd_7d`, `domains` or `mailboxes` for a limit on a new paying workspace, or for a\nKenso Lifetime cap its key: `workspaces`, `inboxes`, `contacts`, `email_verifications_day`,\n`email_verifications_month`, `people_results_day`, `company_results_day`,\n`funding_results_day`, `job_post_results_day`, `website_visits_month` or\n`visitor_lookups_day`. Omitted when a plan rule, not a count, refused the request.","nullable":true},"used":{"type":"integer","description":"How much of the limit is used, in the unit of `metric`. Omitted when the refusal has no count.","format":"int32","nullable":true},"limit":{"type":"integer","description":"The limit, in the unit of `metric`. Omitted when the refusal has no count.","format":"int32","nullable":true},"remaining":{"type":"integer","description":"How much of the limit is left, in the unit of `metric`. Omitted when the refusal has no count.","format":"int32","nullable":true},"planType":{"type":"string","description":"The workspace's plan as its snake plan id, for example `free`, `legacy_core` or `growth`."},"remedy":{"type":"string","description":"What lifts the refusal: `Upgrade`, `BuyAddOn`, `UpdatePaymentMethod` or `ContactSupport`.\n`None` means no action of yours lifts it."},"unlocksAt":{"type":"string","description":"When the limit lifts by itself, in UTC: for a limit on a new paying workspace once it has paid an invoice, and for\na Kenso Lifetime daily or monthly cap its reset (00:00 UTC, or the 1st of the month). Omitted on every other\nrefusal.","format":"date-time","nullable":true},"requiredMillicredits":{"type":"integer","description":"On a credit refusal, the millicredits the action needed. 1,000 millicredits are one credit. Omitted on every\nother refusal.","format":"int64","nullable":true},"availableMillicredits":{"type":"integer","description":"On a credit refusal, the millicredits available. On `FREE_CREDITS_NOT_ELIGIBLE`, only the credits that may\npay for inboxes and domains. Omitted on every other refusal.","format":"int64","nullable":true},"restrictedMillicredits":{"type":"integer","description":"On `FREE_CREDITS_NOT_ELIGIBLE`, the free and bonus millicredits in the balance that cannot pay for inboxes\nand domains. Omitted on every other refusal.","format":"int64","nullable":true},"feature":{"type":"string","description":"On `PLAN_FEATURE_NOT_AVAILABLE`, the plan feature the plan does not include, in snake case (for example\n`website_visitor_id`). Omitted on every other refusal.","nullable":true},"requiredPlan":{"type":"string","description":"On `PLAN_FEATURE_NOT_AVAILABLE`, the cheapest plan that includes `feature`, in snake case (for example\n`growth`). For a feature the self-serve trial locks (`browser_runs`), the trial's own plan,\nwhich paying for unlocks it. Omitted on every other refusal.","nullable":true},"requiredTier":{"type":"integer","description":"On a Kenso Lifetime refusal, the lowest tier that lifts it: the next tier with a higher cap, or the lowest tier\nthat includes `feature`. Omitted at the top tier, when no tier includes the feature, and on every other\nrefusal.","format":"int32","nullable":true},"upgradeUrl":{"type":"string","description":"On a Kenso Lifetime refusal that a higher tier lifts, the AppSumo page where the buyer upgrades their license.\nOmitted until Kenso has read that page from AppSumo, when no tier lifts the refusal, and on every other refusal.","nullable":true}},"additionalProperties":false,"description":"Why a plan rule or usage limit refused the request, and how to lift it."},"TestPromptRequest":{"required":["campaignId","flow"],"type":"object","properties":{"campaignId":{"type":"integer","description":"The campaign whose prompts run. Required.","format":"int64"},"flow":{"type":"string","description":"The flow to test: `qualification`, `segmentation` or `personalization`. Required."},"sampleSize":{"type":"integer","description":"How many contacts to sample, from 1 to 100. Defaults to 10.","format":"int32","nullable":true},"segmentId":{"type":"integer","description":"On a personalization test, the segment whose prompts run. Omit it to run the campaign's default segment. Not\naccepted on other flows.","format":"int64","nullable":true},"modelOverrides":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/PromptTestOverrideRequest"},"description":"Models to use for this run only, keyed by flow. Set only the tested flow, plus `rewriting` on a\npersonalization test.","nullable":true},"excludeContactIds":{"type":"array","items":{"type":"integer","format":"int64"},"description":"Contact ids to leave out of the sample. Each id must be above 0.","nullable":true}},"additionalProperties":false,"description":"The campaign, flow and sample to test."},"TooManyRequestsError":{"oneOf":[{"$ref":"#/components/schemas/Failure"},{"$ref":"#/components/schemas/ApiKeyError"}],"description":"The JSON body of a `429`: the error body (`Failure`), with code `rate_limited` or `quota_exceeded`, over your workspace's rate limits, your API key's own limit, the operation's own limit or a usage quota. Until November 2026, over your API key's own limit the API key check answered `{ \"error\": \"Rate limit exceeded\" }` (`ApiKeyError`), and over the operation's own limit the gateway answered plain text (`RateLimitedText`): `Number of requests exceeded. Please try again later.` A client built against those answers keeps working: handle each shape. Wait the `Retry-After` seconds."},"UnauthorizedError":{"oneOf":[{"$ref":"#/components/schemas/Failure"},{"$ref":"#/components/schemas/ApiKeyError"}],"description":"The body of a `401`: the error body (`Failure`), whose `code` says what is wrong with the credential. Until November 2026, when the API key was not valid (unknown, expired or revoked, or its member no longer active), the API key check in front of the operations answered `{ \"error\": \"Invalid or revoked API key\" }` (`ApiKeyError`), and a request with no API key got a `401` that has no body. A client built against those answers keeps working: handle both shapes and a `401` with no body."}}}}