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

# Get a template

> Fetch a single template's metadata, its published variable manifest, and
the auto-generated JSON Schema for client-side validation. Returns
`manifest: null` / `published: false` when the template exists but has no
published version (distinct from a 404).




## OpenAPI

````yaml /openapi.yaml get /v1/templates/{slug}
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}:
    parameters:
      - $ref: '#/components/parameters/TemplateSlug'
    get:
      tags:
        - Templates
      summary: Get a template
      description: >
        Fetch a single template's metadata, its published variable manifest, and

        the auto-generated JSON Schema for client-side validation. Returns

        `manifest: null` / `published: false` when the template exists but has
        no

        published version (distinct from a 404).
      operationId: getTemplate
      responses:
        '200':
          description: The template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateDetail'
              example:
                id: 7c9f0b2e-2b1a-4f3d-9c8e-1a2b3c4d5e6f
                name: Invoice
                slug: invoice
                description: Standard customer invoice
                templateType: document
                currentVersionNumber: 3
                published: true
                manifest:
                  variables:
                    - key: customer.name
                      label: Customer name
                      dataType: text
                      required: true
                  loops: []
                jsonSchema:
                  type: object
                createdAt: '2026-06-01T09:00:00.000Z'
                updatedAt: '2026-06-20T14:30:00.000Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/TemplateNotFound'
      security:
        - bearerApiKey: []
components:
  parameters:
    TemplateSlug:
      name: slug
      in: path
      required: true
      description: The template slug (canonical identifier within the project).
      schema:
        type: string
  schemas:
    TemplateDetail:
      type: object
      required:
        - id
        - name
        - slug
        - published
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        slug:
          type: string
        description:
          type:
            - string
            - 'null'
        templateType:
          type: string
        currentVersionNumber:
          type:
            - integer
            - 'null'
        published:
          type: boolean
        manifest:
          oneOf:
            - $ref: '#/components/schemas/VariableManifest'
            - type: 'null'
        jsonSchema:
          type:
            - object
            - 'null'
          additionalProperties: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    VariableManifest:
      type: object
      required:
        - variables
        - loops
      properties:
        variables:
          type: array
          items:
            $ref: '#/components/schemas/VariableDefinition'
        loops:
          type: array
          items:
            $ref: '#/components/schemas/LoopDefinition'
    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.
    VariableDefinition:
      type: object
      required:
        - key
        - label
        - dataType
      properties:
        key:
          type: string
          maxLength: 120
          pattern: ^[a-zA-Z_][a-zA-Z0-9_.]*$
        label:
          type: string
          maxLength: 120
        dataType:
          $ref: '#/components/schemas/VariableDataType'
        required:
          type: boolean
          default: false
        defaultValue:
          $ref: '#/components/schemas/ScalarPrimitive'
        previewData:
          $ref: '#/components/schemas/ScalarPrimitive'
        format:
          type: string
          maxLength: 60
        description:
          type: string
          maxLength: 280
    LoopDefinition:
      type: object
      required:
        - key
        - label
        - itemFields
      properties:
        key:
          type: string
          maxLength: 120
          pattern: ^[a-zA-Z_][a-zA-Z0-9_.]*$
        label:
          type: string
          maxLength: 120
        itemFields:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/VariableDefinition'
        previewData:
          type: array
          maxItems: 10
          items:
            type: object
            additionalProperties: true
        description:
          type: string
          maxLength: 280
    VariableDataType:
      type: string
      enum:
        - text
        - longtext
        - number
        - currency
        - date
        - datetime
        - boolean
        - image
        - url
        - email
    ScalarPrimitive:
      type:
        - string
        - number
        - boolean
        - 'null'
  responses:
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Missing Bearer token.
    TemplateNotFound:
      description: No such template in this project.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: template_not_found
              message: No template 'invoice' in this project.
  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.

````