---
title: "Generate variations"
method: POST
path: "/campaigns/{campaignId}/variations/generate"
tags: ["Campaigns"]
---

# Generate variations

`POST /campaigns/{campaignId}/variations/generate`

## Request

- Base URL: `https://api.sequenzy.com/api/v1`
- URL: `https://api.sequenzy.com/api/v1/campaigns/{campaignId}/variations/generate`
- Auth: HTTP bearer

Starts generating 1 to 4 variations with AI and returns them at once with status generating. Each one takes its own direction planned from your prompt, so they differ from each other; style sets how far they move. Generation runs in the background; poll List variations or Get variation until each is ready or failed (a variation still generating after 10 minutes is reported as failed). An email can have up to 8 variations generating at once. The source is the email's saved content, or the variation in parentVariationId, which must be ready. The campaign email itself does not change.

## Path parameters

- `campaignId` string, required

## Request body

- object
  - `prompt` string, required: The direction for the new versions, in any language.
  - `count` integer
  - `parentVariationId` string, nullable: Derive from this variation instead of the email. New variations are its branches.
  - `style` 'close' | 'fresh' | 'bold': How far the new versions move from the source. close edits it, keeping its style and structure; fresh writes each version anew with its own structure in the brand's colors and fonts; bold also gives each its own look (a theme of its own). Defaults to close for branches of a variation and fresh otherwise.

## Response `202`

Generation started

- object
  - `success` boolean
  - `variations` EmailVariation[]
    - `id` string
    - `emailId` string
    - `parentId` string, nullable: The nearest variation this one descends from that has not been discarded. Null when derived from the email.
    - `label` string: Canvas label. V1, V2, ... for versions of the email; V2.1, V2.2, ... for branches of V2.
    - `name` string
    - `summary` string, nullable: What changed, in a sentence.
    - `prompt` string, nullable: The request that generated this variation.
    - `style` 'close' | 'fresh' | 'bold' | 'null', nullable: How far it was asked to move from its source, when AI generated it.
    - `status` 'generating' | 'ready' | 'failed'
    - `error` string, nullable: Why generation failed.
    - `subject` string, nullable: Subject this variation uses. Null keeps the email's subject.
    - `previewText` string, nullable
    - `blocks` EmailBlock[], nullable: Null while generating or after a failure.
      - `id` string
      - `type` 'text' | 'html' | 'heading' | 'list' | 'button' | 'spacer' | 'divider' | 'image' | 'columns' | 'group' | 'conditional-group' | 'repeat' | 'card' | 'cta' | 'social' | 'logo' | 'header' | 'footer' | 'video' | 'product' | 'discount-code' | 'code' | 'countdown' | 'hero' | 'testimonial' | 'gallery' | 'badge' | 'table' | 'features' | 'image-card' | 'pricing' | 'author' | 'article' | 'rating' | 'stats' | 'steps' | 'product-grid' | 'poll', required
      - `content` string: Content for text, html, and heading-like blocks.
      - `label` string: Editor label for a structural group block.
      - `layout` 'stack' | 'row' | 'grid' | 'overlay': Direct-child layout for a structural group block.
      - `columns` integer: Number of columns used by a group with grid layout.
      - `gap` integer: Gap in pixels between direct group children.
      - `stackOnMobile` boolean: Columns block only. Multi-column rows stack into a single column on screens 480px wide or narrower. Set to false to keep the columns side by side on mobile. Omit or set to true for the default stacking.
      - `padding` integer: Uniform group padding in pixels; per-side styles.padding* fields override it.
      - `overlayColor` string: Opaque fallback and shade color for an overlay group.
      - `overlayShade` integer: Overlay shade intensity as a percentage.
      - `overlayPosition` 'top' | 'center' | 'bottom': Vertical position of overlay foreground content.
      - `children` EmailBlock[]: Recursive child blocks for group and repeat containers.
      - `styles` object: Per-block visual styles. For compatibility, style fields such as backgroundColor, backgroundOpacity, borderColor, borderWidth, and borderRadius can also be supplied at the block top level and are normalized into this object.
        - `paddingTop` number
        - `paddingBottom` number
        - `paddingLeft` number
        - `paddingRight` number
        - `backgroundColor` string
        - `backgroundOpacity` number: Background opacity percentage from 0 to 100.
        - `textColor` string
        - `textAlign` 'left' | 'center' | 'right'
        - `keepAlign` boolean: Keep a centered button, logo or footer centered when the email is left-aligned (layout.contentAlign left). Without it a left email moves these blocks left; right always stays.
        - `borderRadius` number
        - `borderColor` string
        - `borderWidth` number
        - `bleed` boolean: Stretch the block edge-to-edge across the email container. Top-level blocks only.
      - `conditions` object[]: Optional per-block display rules. The block renders only when every rule matches. The same shape is used for a conditional-group block's top-level `conditions`.
        - `id` string, required
        - `field` 'variable' | 'attribute' | 'email' | 'firstName' | 'lastName', required: `variable` resolves a merge-tag path from the transactional send `variables` or an automation `event` payload (nested paths like `order.total` or `event.plan` work). `attribute` reads a stored subscriber attribute. `email`, `firstName`, and `lastName` read core subscriber fields.
        - `operator` 'is' | 'is_not' | 'contains' | 'not_contains' | 'gt' | 'gte' | 'lt' | 'lte' | 'is_empty' | 'is_not_empty', required
        - `value` string, required: For `variable` and `attribute`, use `name:value` - the part before the colon is the variable path or attribute name, and the part after it is the comparison value. For `email`, `firstName`, and `lastName`, provide the plain comparison string.
    - `emailTheme` object, nullable: The variation's own email theme. Null means it uses the email's theme.
    - `fontFamily` string, nullable: The variation's own body font stack. Null means it uses the email's font.
    - `position` object, nullable: Where the user placed it on the editor canvas, in canvas pixels. Null means the canvas places it automatically.
      - `x` integer
      - `y` integer
    - `inUse` boolean: Whether using this variation would leave the campaign email unchanged (same blocks, and its own subject, preview text, theme and font when it has them). When several match, only the one used most recently is in use.
    - `usedAt` string, date-time, nullable: When this variation was last put in the campaign email.
    - `createdAt` string, date-time
    - `updatedAt` string, date-time

## Other responses

- `400`: Not an email campaign, or the email is a single raw HTML block (variations need Sequenzy blocks)
- `401`: Unauthorized
- `404`: Campaign or parent variation not found
- `409`: The parent variation is still generating or failed, or this email already has 8 variations generating (the limit; wait for some to finish)
- `503`: Generation could not be started (for example the queue is unavailable). Any variations it created are marked failed; retry the request.

## Changes

- **2026-10-26** `e2e7d27d7804`: 1 info
  - added the optional property `variations/items/blocks/items/styles/keepAlign` to the response with the `202` status
- **2026-10-16** `db3873ca3d4d`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/sequenzy/apis/sequenzy-api/changes/campaigns/:campaignId/variations/generate/post.md)

---

[API](https://skmtc.dev/sequenzy/apis/sequenzy-api.md) - [All operations](https://skmtc.dev/sequenzy/apis/sequenzy-api/llms.txt) - [OpenAPI document](https://skmtc.dev/sequenzy/apis/sequenzy-api/revisions/8156dc12d8b4?raw)
