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

# Render a template

> Validate request `data` against the template's variable manifest and
enqueue an async render job. Returns `202` with a poll URL for a freshly
queued render, or `200` when an `Idempotency-Key` (or body `jobId`)
replays an existing render.




## OpenAPI

````yaml /openapi.yaml post /v1/templates/{slug}/render
openapi: 3.1.0
info:
  title: Craftkit API
  version: 1.0.0
  description: >
    The Craftkit public REST API. Design templates with typed variables, render

    PDFs asynchronously, share and track them, and send them out for digital

    signature.


    ## Authentication


    Most endpoints authenticate with a **project API key** as a bearer token:


    ```

    Authorization: Bearer ck_live_xxxxxxxxxxxxxxxx

    ```


    Keys come in `ck_live_` (production) and `ck_test_` (test) flavours. Embed

    iframe surfaces use a short-lived **embed session JWT** instead, and the

    admin provisioning endpoint uses the deployment-wide `CRAFTKIT_ADMIN_KEY`.

    Inbound webhooks (`/v1/hooks/*`) are not bearer-authed — they are verified
    by

    an HMAC signature header.


    ## Idempotency


    `POST /v1/templates/{slug}/render` and `POST /v1/signatures` accept an

    `Idempotency-Key` request header. Retrying with the same key returns the

    original resource instead of creating (and, for signatures, billing) a

    duplicate.


    ## Errors


    Application errors use a shared envelope:


    ```json

    { "error": { "code": "invalid_request", "message": "...", "issues": { } } }

    ```


    A small number of admin/embed endpoints return a flatter shape

    (`{ "error": "invalid_credentials" }`); those are documented inline.
servers:
  - url: https://api.craftkit.dev
    description: Production
security:
  - bearerApiKey: []
tags:
  - name: Templates
    description: Create, list, fetch, republish, delete templates and enqueue renders.
  - name: Renders
    description: Poll render status, download PDFs, manage shares, email, and engagement.
  - name: Signatures
    description: >-
      Send rendered PDFs out for digital signatures via the signature service
      and track status.
  - name: Webhooks
    description: Inbound webhook receivers (HMAC-authenticated, not bearer-authed).
  - name: Embed
    description: Embed session minting, catalogs, builder templates, form submission.
  - name: Admin
    description: Org provisioning (deployment admin key only).
  - name: System
    description: Health and status.
paths:
  /v1/templates/{slug}/render:
    parameters:
      - $ref: '#/components/parameters/TemplateSlug'
    post:
      tags:
        - Templates
      summary: Render a template
      description: |
        Validate request `data` against the template's variable manifest and
        enqueue an async render job. Returns `202` with a poll URL for a freshly
        queued render, or `200` when an `Idempotency-Key` (or body `jobId`)
        replays an existing render.
      operationId: renderTemplate
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RenderRequest'
            example:
              data:
                customer:
                  name: Acme Corp
              options:
                sync: false
      responses:
        '200':
          description: Idempotent replay of an existing render.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RenderEnvelope'
        '202':
          description: Render queued.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RenderEnvelope'
              example:
                id: 3f2a1b4c-5d6e-7f80-9a1b-2c3d4e5f6071
                status: queued
                pollUrl: >-
                  https://api.craftkit.dev/v1/renders/3f2a1b4c-5d6e-7f80-9a1b-2c3d4e5f6071
                downloadUrl: null
                errorMessage: null
                createdAt: '2026-06-21T10:00:00.000Z'
        '400':
          description: Invalid JSON, request shape, or variable data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalidRequest:
                  value:
                    error:
                      code: invalid_request
                      message: Request body did not match expected shape.
                invalidInputData:
                  value:
                    error:
                      code: invalid_input_data
                      message: Variable data did not match the template manifest.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Template not found, or a pinned `versionNumber` does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: version_not_found
                  message: Template 'invoice' has no version 99.
        '409':
          description: Template has no published version yet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: no_published_version
                  message: This template has no published version yet.
        '503':
          description: Render queue temporarily unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: queue_unavailable
                  message: >-
                    Render queue is temporarily unavailable. Please retry in a
                    moment.
      security:
        - bearerApiKey: []
components:
  parameters:
    TemplateSlug:
      name: slug
      in: path
      required: true
      description: The template slug (canonical identifier within the project).
      schema:
        type: string
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Make retries safe — a repeated request with the same key returns the
        original resource.
      schema:
        type: string
  schemas:
    RenderRequest:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          additionalProperties: true
          description: >-
            Variable values keyed by VariableDefinition.key. Loop arrays capped
            at 10,000 items.
        jobId:
          type: string
          minLength: 1
          maxLength: 200
          description: >-
            Optional idempotency key (the Idempotency-Key header takes
            precedence).
        options:
          type: object
          properties:
            sync:
              type: boolean
              default: false
            versionNumber:
              type: integer
              minimum: 1
              description: Pin to a specific template version (defaults to current).
            filename:
              type: string
              maxLength: 120
          default:
            sync: false
    RenderEnvelope:
      type: object
      description: Render shape returned by render/idempotent-replay and embed form-submit.
      required:
        - id
        - status
        - pollUrl
        - downloadUrl
        - errorMessage
        - createdAt
      properties:
        id:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/RenderStatusEnum'
        pollUrl:
          type: string
          format: uri
        downloadUrl:
          type:
            - string
            - 'null'
          format: uri
        errorMessage:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
    Error:
      type: object
      description: Shared application error envelope.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            issues:
              description: Optional Zod flatten() / issues detail.
      example:
        error:
          code: invalid_request
          message: Request body did not match expected shape.
    RenderStatusEnum:
      type: string
      enum:
        - queued
        - rendering
        - succeeded
        - failed
        - cancelled
  responses:
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Missing Bearer token.
  securitySchemes:
    bearerApiKey:
      type: http
      scheme: bearer
      description: >
        Project API key (`ck_live_…` or `ck_test_…`) presented as a bearer
        token.

        For embed partner endpoints this is the partner secret key, which is the

        same credential type.

````