> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.scripe.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate a carousel into the media library asynchronously

> Kick off an AI carousel generation: the model picks a design,
storyboards the deck, writes every slide, generates any imagery
the design calls for, stamps the project's brand identity onto
it, and the result is rendered to a PDF by the same pipeline the
dashboard's carousel download uses. Returns a `Job` envelope.

The deck is written in the project's own voice (its brand
context and tone-of-voice language) and published under its own
identity — author name, handle, headshot and the workspace's
logo — exactly as a deck generated in the dashboard is. Nothing
about the deck differs by which surface asked for it.

On completion the job's `result` carries:

- `mediaId` — an `img_…` asset in the project's media library
  (visible in `GET /v1/media`, `source: GENERATED`), whose
  stored document lets the deck be reopened in the editor;
- `documentKey` — the S3 key of the rendered PDF, which you pass
  straight to `PATCH /v1/posts/{postId}/media` as
  `{ "kind": "document", "document": { "key": "…" } }`. That is
  how a carousel actually reaches LinkedIn;
- `slideCount` — how many slides the planner produced;
- `imageSlots` — `{ pending, filled, budgetDeclined, failed }`,
  how the deck's generated-image slots resolved. `pending` is
  how many the composed deck asked for; anything not `filled`
  shipped with the design's own stand-in art. Check it when you
  need to know whether the deck you received is complete — a
  stand-in is visually indistinguishable from a design that
  wanted no imagery.

Cost: reserved in two phases against the daily AI-spend cap and
reconciled with provider actuals after the job runs, so a deck
settles at what it really cost. 45¢ is reserved up front for the
three chained model calls (design pick, storyboard, slide copy)
and the deck's first 20¢ of imagery. The deck's real image-slot
count is only known once it has been composed, so each further
slot reserves its own cost (5¢ a raster, 11¢ an author cutout)
immediately before it is generated. Every reservation is a
single atomic conditional update: concurrent calls cannot
jointly exceed the cap, and losers receive a 402.

If the cap runs out mid-job the carousel is still delivered —
the slots that could not be paid for keep their stand-in art and
are counted in `imageSlots.budgetDeclined`. The cap is never
overshot.

Decks typically take two to three minutes, comfortably past the
25 000 ms `wait_for_completion_ms` ceiling — poll
`GET /v1/jobs/{jobId}` rather than sync-waiting.

Requires the `media:write` scope.




## OpenAPI

````yaml /openapi/v1.yaml post /media/carousels
openapi: 3.1.0
info:
  title: Scripe Public API
  version: '2026-08-10'
  summary: >-
    Read and write Scripe workspace data — posts, notes, ideas, sources,
    knowledge, media, analytics, usage, async jobs, and webhooks.
  description: |
    The Scripe public API gives integrators stable, versioned access to a
    workspace's content surface: reads across every resource, synchronous
    writes (notes, posts, ideas, text sources, media assets), async jobs
    (post generation, file/URL/YouTube ingest, image and carousel
    generation), usage meters, and outbound webhooks.

    All endpoints (except `/v1/health`) require a Bearer token — either a
    workspace API key (`scripe_sk_*`) or an OAuth 2.1 access token
    (`scripe_oat_*`). Pin the API version with the `Scripe-Api-Version`
    request header to opt out of breaking changes.
  contact:
    name: Scripe Support
    url: https://scripe.io/support
    email: support@scripe.io
  license:
    name: Proprietary
servers:
  - url: https://api.scripe.io/v1
    description: Production
security:
  - BearerApiKey: []
tags:
  - name: Health
    description: Liveness and authenticated key smoke tests.
  - name: Workspace
    description: The workspace + principal resolved from your API key.
  - name: Projects
    description: Personal-brand, company-page, and amplifier projects.
  - name: Notes
    description: Project notes with paired calendar slot.
  - name: Posts
    description: Drafts, scheduled, and published LinkedIn posts.
  - name: Analytics
    description: Your own LinkedIn analytics and viral-post inspiration search.
  - name: Sources
    description: Transcriptions (audio/video sources) with truncated body.
  - name: Uploads
    description: >-
      Pre-signed S3 PUT URLs the customer uploads bytes to before referencing
      via Sources or Knowledge.
  - name: Knowledge
    description: >-
      Knowledge-base documents indexed for RAG. Async ingest via text, file,
      URL, or YouTube.
  - name: Jobs
    description: >-
      Async-job lifecycle — submitted via post-generation, knowledge ingest,
      file source.
  - name: Calendar
    description: >-
      The content calendar — scheduled/planned posts, note slots, idea
      placements, and the posting-time template.
  - name: Ideas
    description: >-
      The idea board — creative briefs with derived workflow statuses and
      date-level calendar placement.
  - name: Media
    description: >-
      Media-library search, own-image imports, AI image generation, and
      full-state media writes onto posts.
  - name: Settings
    description: >-
      Curated project settings, engagement policy, and company pages (read-only
      over REST).
  - name: Webhooks
    description: |
      Outbound HTTP callbacks. Subscribe an endpoint to one or more
      event names; we POST a signed JSON payload every time a matching
      event fires in the workspace. The signing secret is shown once
      on create and once on rotate — verify the
      `Webhook-Signature: t=<ts>,v1=<hmac>` header on every delivery.
paths:
  /media/carousels:
    post:
      tags:
        - Media
        - Jobs
      summary: Generate a carousel into the media library asynchronously
      description: |
        Kick off an AI carousel generation: the model picks a design,
        storyboards the deck, writes every slide, generates any imagery
        the design calls for, stamps the project's brand identity onto
        it, and the result is rendered to a PDF by the same pipeline the
        dashboard's carousel download uses. Returns a `Job` envelope.

        The deck is written in the project's own voice (its brand
        context and tone-of-voice language) and published under its own
        identity — author name, handle, headshot and the workspace's
        logo — exactly as a deck generated in the dashboard is. Nothing
        about the deck differs by which surface asked for it.

        On completion the job's `result` carries:

        - `mediaId` — an `img_…` asset in the project's media library
          (visible in `GET /v1/media`, `source: GENERATED`), whose
          stored document lets the deck be reopened in the editor;
        - `documentKey` — the S3 key of the rendered PDF, which you pass
          straight to `PATCH /v1/posts/{postId}/media` as
          `{ "kind": "document", "document": { "key": "…" } }`. That is
          how a carousel actually reaches LinkedIn;
        - `slideCount` — how many slides the planner produced;
        - `imageSlots` — `{ pending, filled, budgetDeclined, failed }`,
          how the deck's generated-image slots resolved. `pending` is
          how many the composed deck asked for; anything not `filled`
          shipped with the design's own stand-in art. Check it when you
          need to know whether the deck you received is complete — a
          stand-in is visually indistinguishable from a design that
          wanted no imagery.

        Cost: reserved in two phases against the daily AI-spend cap and
        reconciled with provider actuals after the job runs, so a deck
        settles at what it really cost. 45¢ is reserved up front for the
        three chained model calls (design pick, storyboard, slide copy)
        and the deck's first 20¢ of imagery. The deck's real image-slot
        count is only known once it has been composed, so each further
        slot reserves its own cost (5¢ a raster, 11¢ an author cutout)
        immediately before it is generated. Every reservation is a
        single atomic conditional update: concurrent calls cannot
        jointly exceed the cap, and losers receive a 402.

        If the cap runs out mid-job the carousel is still delivered —
        the slots that could not be paid for keep their stand-in art and
        are counted in `imageSlots.budgetDeclined`. The cap is never
        overshot.

        Decks typically take two to three minutes, comfortably past the
        25 000 ms `wait_for_completion_ms` ceiling — poll
        `GET /v1/jobs/{jobId}` rather than sync-waiting.

        Requires the `media:write` scope.
      operationId: createCarouselGeneration
      parameters:
        - $ref: '#/components/parameters/ScripeApiVersion'
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CarouselGenerationCreate'
      responses:
        '200':
          description: Job enqueued (or finished, on a sync-wait hit).
          headers:
            Idempotent-Replayed:
              schema:
                type: string
                enum:
                  - 'true'
                  - 'false'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobSingle'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/SpendCapExceeded'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    ScripeApiVersion:
      name: Scripe-Api-Version
      in: header
      required: false
      description: |
        Pin the API version. Format `YYYY-MM-DD`. Omit to receive the
        currently rolling default. Unknown versions return `400
        version_unsupported`.
      schema:
        type: string
        example: '2026-08-10'
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: |
        Opaque string (1–64 chars, `[A-Za-z0-9_-]`) used to dedup
        retried writes. Within 24h of the first request, the same key
        + same body returns the original response (`Idempotent-Replayed:
        true`). Same key + different body returns `409
        idempotency_key_conflict`.

        Strongly recommended for every write — see
        `/docs/api/v1/idempotency`.
      schema:
        type: string
        pattern: ^[A-Za-z0-9_-]{1,64}$
  schemas:
    CarouselGenerationCreate:
      type: object
      required:
        - projectId
        - topic
      properties:
        projectId:
          type: string
          example: proj_a1b2c3d4e5f6g7h8
        topic:
          type: string
          maxLength: 8000
          description: |
            The core idea the deck communicates. A whole post body is
            fine — the planner reads it as the brief.
        steer:
          type: string
          maxLength: 4000
          description: |
            Explicit instruction that takes priority — audience, angle,
            tone, things to avoid.
        outline:
          type: string
          maxLength: 4000
          description: |
            A slide-by-slide outline to honour verbatim. Goes to the
            PLANNER, the only step that can actually respect slide count
            and order; omit it to let the planner storyboard the deck.
        templateId:
          type: string
          maxLength: 100
          description: |
            Force one of the shipped carousel designs. Omitted — or
            unknown — and the model picks the best fit for the topic.
            The workspace's default company design, when one is saved,
            wins over the model's pick.
        wait_for_completion_ms:
          type: integer
          minimum: 0
          maximum: 25000
          description: |
            Soft hint — server polls for up to this many ms before
            returning. Capped at 25 000 ms. A carousel usually takes
            longer, so polling is the intended path.
    JobSingle:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/Job'
    Job:
      type: object
      required:
        - id
        - type
        - status
        - projectId
        - startedAt
        - completedAt
        - progress
        - result
        - errorCode
        - errorMessage
        - attemptCount
        - estimatedCompletionMs
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          example: job_a1b2c3d4e5f6g7h8
        type:
          type: string
          example: POST_GENERATION
          description: |
            One of `POST_GENERATION`, `KB_INGEST_TEXT`, `KB_INGEST_FILE`,
            `KB_INGEST_URL`, `KB_INGEST_YOUTUBE`, `SOURCE_INGEST_FILE`,
            `IMAGE_GENERATION`, `CAROUSEL_GENERATION`.
        status:
          type: string
          example: QUEUED
          description: One of `QUEUED`, `RUNNING`, `DONE`, `FAILED`, `CANCELLED`.
        projectId:
          type: string
          nullable: true
        startedAt:
          type: string
          format: date-time
          nullable: true
        completedAt:
          type: string
          format: date-time
          nullable: true
        progress:
          type: object
          nullable: true
          required:
            - progress
            - updatedAt
          properties:
            progress:
              type: number
              minimum: 0
              maximum: 1
            message:
              type: string
            updatedAt:
              type: string
              format: date-time
        result:
          type: object
          nullable: true
          additionalProperties: true
          description: >
            Worker-populated only when status is `DONE`. Shape varies

            per `type`, and every id in it is a **public** id you can

            pass straight back to the API:


            | `type` | `result` |

            |---|---|

            | `POST_GENERATION` | `{ "postId": "post_..." }` |

            | `KB_INGEST_TEXT` / `_FILE` / `_URL` / `_YOUTUBE` | `{
            "documentId": "kb_..." }` |

            | `SOURCE_INGEST_FILE` | `{ "sourceId": "src_..." }` |

            | `IMAGE_GENERATION` | `{ "mediaId": "img_..." }` |
        errorCode:
          type: string
          nullable: true
        errorMessage:
          type: string
          nullable: true
        attemptCount:
          type: integer
          minimum: 0
        estimatedCompletionMs:
          type: integer
          nullable: true
          description: Rolling p50 hint for clients deciding whether to wait.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - request_id
            - docs_url
          properties:
            code:
              type: string
              description: Stable, machine-readable error identifier.
              example: not_found
            message:
              type: string
            request_id:
              type: string
              example: req_a1b2c3d4e5f6
            docs_url:
              type: string
              format: uri
            details:
              description: Optional structured payload — shape varies per code.
  responses:
    BadRequest:
      description: Malformed request (bad cursor, bad limit, etc.).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, malformed, expired, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    SpendCapExceeded:
      description: |
        Daily AI-spend cap reached for this workspace. Resets at
        00:00 UTC.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Plan not eligible, scope missing, or workspace mismatch.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found in this workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    IdempotencyConflict:
      description: |
        `Idempotency-Key` reused with a different body within the
        24h dedup window. Pick a fresh key or replay the original
        body verbatim.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unprocessable:
      description: Body shape was JSON but failed validation (`unprocessable`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Sliding-window rate limit exceeded.
      headers:
        Retry-After:
          schema:
            type: integer
        X-RateLimit-Limit:
          schema:
            type: integer
        X-RateLimit-Remaining:
          schema:
            type: integer
        X-RateLimit-Reset:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerApiKey:
      type: http
      scheme: bearer
      bearerFormat: scripe_sk_live_*
      description: |
        Pass `Authorization: Bearer scripe_sk_live_<...>` (or
        `scripe_sk_test_<...>` for test keys) on every request. Keys
        are scoped to a single workspace and can be revoked from the
        Scripe dashboard.

        The same header also accepts an OAuth 2.1 access token
        (`scripe_oat_*`); both credentials share one scope vocabulary
        and every operation below documents the scope it requires.
        An API key can hold every scope named on this surface except
        `webhooks:manage`, which is grantable to OAuth tokens only
        today — the webhook-endpoint operations answer
        `403 scope_missing` to every API key. Operations that name no
        scope accept any valid token of the workspace.

````