> ## 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.

# Publish a variable catalog version

> Publish a named variable catalog version using the partner secret key.
Calling with the same name creates the next version and marks it current;
previous versions are archived, never deleted.




## OpenAPI

````yaml /openapi.yaml post /v1/embed/catalogs
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/embed/catalogs:
    post:
      tags:
        - Embed
      summary: Publish a variable catalog version
      description: >
        Publish a named variable catalog version using the partner secret key.

        Calling with the same name creates the next version and marks it
        current;

        previous versions are archived, never deleted.
      operationId: createEmbedCatalog
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - catalog
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                  pattern: ^[a-z0-9][a-z0-9-]*$
                catalog:
                  $ref: '#/components/schemas/VariableCatalog'
            example:
              name: crm-fields
              catalog:
                allowCustom: false
                namespaces:
                  - key: customer
                    label: Customer
                    fields:
                      - key: name
                        label: Name
                        dataType: text
                loops: []
      responses:
        '201':
          description: Catalog version published.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - name
                  - version
                properties:
                  id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  version:
                    type: integer
              example:
                id: c1a2b3c4-d5e6-f708-9a0b-1c2d3e4f5061
                name: crm-fields
                version: 2
        '400':
          description: Body was not valid JSON.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimpleError'
        '401':
          $ref: '#/components/responses/SimpleUnauthorized'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '500':
          description: Auth check or catalog storage failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerApiKey: []
components:
  schemas:
    VariableCatalog:
      type: object
      properties:
        allowCustom:
          type: boolean
          default: false
        namespaces:
          type: array
          items:
            $ref: '#/components/schemas/CatalogNamespace'
          default: []
        loops:
          type: array
          items:
            $ref: '#/components/schemas/CatalogLoop'
          default: []
    SimpleError:
      type: object
      description: |
        Flat error shape used by some admin/embed endpoints (the value is a
        machine-readable code string rather than the structured envelope).
      required:
        - error
      properties:
        error:
          oneOf:
            - type: string
            - type: object
              properties:
                code:
                  type: string
                message:
                  type: string
        message:
          type: string
        issues: {}
        detail:
          type: string
    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.
    CatalogNamespace:
      type: object
      required:
        - key
        - label
        - fields
      properties:
        key:
          type: string
          maxLength: 60
          pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
        label:
          type: string
          maxLength: 80
        icon:
          type: string
          maxLength: 40
        fields:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/CatalogField'
    CatalogLoop:
      type: object
      required:
        - key
        - label
        - itemFields
      properties:
        key:
          type: string
          maxLength: 160
          pattern: ^[a-zA-Z_][a-zA-Z0-9_.]*$
        label:
          type: string
          maxLength: 160
        itemFields:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/CatalogField'
        previewData:
          type: array
          maxItems: 10
          items:
            type: object
            additionalProperties: true
        description:
          type: string
          maxLength: 280
    CatalogField:
      type: object
      required:
        - key
        - label
        - dataType
      properties:
        key:
          type: string
          maxLength: 160
          pattern: ^[a-zA-Z_][a-zA-Z0-9_.]*$
        label:
          type: string
          maxLength: 160
        dataType:
          $ref: '#/components/schemas/VariableDataType'
        required:
          type: boolean
          default: false
        format:
          type: string
          maxLength: 60
        description:
          type: string
          maxLength: 280
        previewData:
          $ref: '#/components/schemas/ScalarPrimitive'
        sample:
          deprecated: true
          allOf:
            - $ref: '#/components/schemas/ScalarPrimitive'
    VariableDataType:
      type: string
      enum:
        - text
        - longtext
        - number
        - currency
        - date
        - datetime
        - boolean
        - image
        - url
        - email
    ScalarPrimitive:
      type:
        - string
        - number
        - boolean
        - 'null'
  responses:
    SimpleUnauthorized:
      description: Missing or invalid credentials (flat error shape).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SimpleError'
          example:
            error: invalid_credentials
    UnprocessableEntity:
      description: Request failed schema validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SimpleError'
          example:
            error: invalid_request
            issues: []
  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.

````