---
title: "Generate Sequence Spintax"
method: POST
path: "/sequences/generate-spintax"
tags: ["Sequences"]
---

# Generate Sequence Spintax

`POST /sequences/generate-spintax`

## Request

- Base URL: `https://be.graph8.com/api/v1`
- URL: `https://be.graph8.com/api/v1/sequences/generate-spintax`
- Auth: HTTP bearer

One-time AI generation: rewrite a manual email into spintax.

Returns the subject + body rewritten with (possibly nested)
``{{option a|option b}}`` blocks; the sequencer's per-contact resolver
then sends a different-looking variant to each lead. Content-level and
sequence-agnostic: paste the result into any sequence or campaign email
step as a MANUAL_TEMPLATE.

Requires an active subscription and consumes credits (token-metered;
402 on either failure). Synchronous, up to ~2 minutes; per-worker
concurrency is capped (429 + Retry-After when saturated). Output is
validated server-side (balanced braces, ``{{variables}}`` and links
preserved) - invalid model output surfaces as 422, never as silently
broken content.

## Headers

- `Authorization` string, nullable
- `X-Target-Org-Id` string, nullable

## Request body

- GenerateSpintaxRequest: One-time AI generation: rewrite a manual email into spintax. Field types intentionally mirror the internal ``sequencer.interfaces.voice.email_generation.GenerateSpintaxPayload`` (same Literals) so outer/inner validation cannot drift. The legacy ``target_combinations`` knob is deliberately NOT exposed on the public surface; ``strength`` supersedes it.
  - `subject` string, required: Email subject to rewrite into spintax
  - `body` string, required: Email body to rewrite into spintax
  - `email_type` 'plain' | 'html': Body format. 'html' preserves every <a href> link and all {{variables}} in the rewrite.
  - `tone_instructions` string, nullable: Optional tone/style guidance applied during the rewrite (e.g. 'casual, no exclamation marks').
  - `strength` 'light' | 'balanced' | 'maximum': Variation intensity: how heavily to vary the copy and how deeply to nest spintax blocks. Each level carries an ENFORCED ceiling on total distinct renderings (subject x body), applied after generation: 'light' up to 200 (flat blocks only), 'balanced' up to 5,000, 'maximum' up to 100,000. Output over the ceiling is trimmed down, never rejected.

## Response `200`

Successful Response

- ApiResponseGenerateSpintaxResponse
  - `data` GenerateSpintaxResponse, required: Spintax-encoded email plus its distinct-rendering counts.
    - `subject` string, required: Subject rewritten with {{option a|option b}} spintax blocks
    - `body` string, required: Body rewritten with (possibly nested) spintax blocks
    - `subject_combinations` integer, required: Distinct renderings the subject can produce
    - `body_combinations` integer, required: Distinct renderings the body can produce
    - `total_combinations` integer, required: Distinct full-email renderings (subject x body)
  - `pagination` PaginationMeta
    - `page` integer, required: Current page number (1-indexed)
    - `limit` integer, required: Items per page
    - `total` integer, required: Total number of items
    - `has_next` boolean, required: Whether there are more pages
    - `next_cursor` string, nullable: Opaque cursor for the next page; null when there are no more items. Pass it back as the `cursor` query param to fetch the following page without computing page numbers.
    - `total_available` integer, nullable: Search endpoints only: how many records really match, when known. Can be larger than `total`, which is capped at the 10,000 results that can be paged. For company search this is a distinct-company estimate. Null when unknown; absent outside search.
    - `total_is_lower_bound` boolean, nullable: Search endpoints only: true when more records match than `total` shows (the result set is larger than the 10,000 results that can be paged). Absent outside search.
    - `notes` string[], nullable: Search endpoints only: plain-language notes about the result, e.g. that more records match than can be paged, or that a reversed `between` range was put in order.

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/graph8/apis/graph8-developer-api.md) · [All operations](https://skmtc.dev/graph8/apis/graph8-developer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/graph8/apis/graph8-developer-api/revisions/89fc11143b70?raw)
