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

# Image variables: Test an image variable on 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 [Image variables](/docs/api/image-variables.md). Authentication, workspaces and errors: [/docs.md](/docs.md).

## Test an image variable on contacts

`POST /v1/campaigns/{campaignId}/image-variables/{variableKey}/test` - operationId `image-variables.test`

| Permission | Credits | Rate limit |
| --- | --- | --- |
| Campaigns edit | Varies with the request (`campaign_image`) | 240 requests a minute per API key |

Generates images for up to 5 contacts of a `per_prospect` variable, so you can check the result before you
turn the variable on. The call waits for the images and returns them. Each image becomes that contact's image.
The test does not turn the variable on.

Kenso picks contacts with no image first, then contacts whose image failed. It never picks a contact whose image
Kenso blocked. A contact whose generation failed outright is left out of the response. Kenso charges credits for
each ready image. Each contact it picks counts toward the workspace's daily limit of image generations (100 a day,
lower on the Free plan). When no contact is eligible, the call generates nothing and counts nothing.

Errors:

- `404 not_found`: the campaign or the variable does not exist in this workspace.
- `409 wrong_kind`: the variable is `shared`. Set its image with the shared image call instead.
- `429 quota_exceeded`: the workspace reached its daily limit of image generations. `Retry-After` says
when to try again.

Requires Campaigns edit.

Needs the `campaign_images` feature on your workspace. Until it is on, calls answer 404.

[Try it on developer.ken.so](https://developer.ken.so/reference/#kenso-api/tag/image-variables/POST/v1/campaigns/%7BcampaignId%7D/image-variables/%7BvariableKey%7D/test)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `campaignId` | path | integer (int64) | yes | Id of the campaign. |
| `variableKey` | path | string | yes | Key of the image variable, such as `hero_image`. |
| `Ken-Version` | header | string, one of: 2026-11-02, 1.1 | no | The API version, a date in `YYYY-MM-DD` form. `1.1` is another name for the first dated version. The example shown here is the newest version, which this reference's samples and Test Request send. Leave it out to use your API key's pinned version. Keys created in the Kenso app are pinned to the newest version; keys minted by the CLI login are not. A key with no pinned version and no header gets the legacy shape where the path has one, and `404` where the path exists only in this version. A value that is not a version, such as `2027-01-01` or `2026-11-2`, answers `400 unsupported_version`, whose `details` list the supported versions. |
| `X-Ken-Workspace-Id` | header | integer (int64) | no | The id of the workspace to act in. Leave it out when your API key reaches only one workspace. When the key reaches more than one, a request without this header answers `400 workspace_required`. A workspace you are not a member of answers `404 not_found`. |

### Response 200

`data` is a `ImageVariableTest`.

| Field | Type | Description |
| --- | --- | --- |
| `images` | array of CampaignImage | One image per tested contact, ready or failed. A contact whose generation failed outright is left out. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/campaigns/812/image-variables/hero_image/test" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID"
```

### Example response

```json
{
  "success": true,
  "data": {
    "images": [
      {
        "imageKey": "string",
        "contactId": 812,
        "variableKey": "string",
        "status": "string",
        "errorCode": "timeout",
        "errorDetail": "string",
        "width": 1,
        "height": 1,
        "previewUrl": "https://example.com",
        "previewExpiresAt": "2026-09-23T15:02:11Z",
        "updatedAt": "2026-09-23T15:02:11Z"
      }
    ]
  }
}
```

## Types

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

### CampaignImage

An image Kenso made or stored for a campaign's emails.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `imageKey` | string | no | The image's unique 26-character key. Read the image again with `GET /v1/campaign-images/{imageKey}`. |
| `contactId` | integer (int64) | no | Id of the contact the image belongs to. Omitted for an image that every contact shares. |
| `variableKey` | string | no | Key of the image variable the image fills, or `custom_image` for the contact's own image. Omitted when the image belongs to no current image variable. |
| `status` | string | no | State of the image: `pending` while Kenso makes or fetches it, `ready` once it is stored, or `failed`. |
| `errorCode` | string | no | Why the image failed, such as `timeout`, `not_an_image`, `too_large` or `provider_error`. Set when `status` is `failed`. |
| `errorDetail` | string | no | A readable explanation of the failure. Set when `status` is `failed`. |
| `width` | integer (int32) | no | Width of the image in pixels. Omitted while unknown. |
| `height` | integer (int32) | no | Height of the image in pixels. Omitted while unknown. |
| `previewUrl` | string | no | A link to view the ready image, valid until `previewExpiresAt`. Use it for viewing only, not inside an email. Omitted unless `status` is `ready`. |
| `previewExpiresAt` | string (date-time) | no | When `previewUrl` stops working, in UTC: 1 hour after the call. Omitted with `previewUrl`. |
| `updatedAt` | string (date-time) | no | When the image last changed, in UTC. |
