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

# Mint a project API key

> Mint a new `ck_live_…` project API key for a project owned by the
authenticated account, for use against the project-scoped API
(`/v1/templates`, `/v1/renders`, `/v1/signatures`, embed). This never
mints an account key (`ck_acct_…`) — the account key itself is issued
only from the dashboard (**Account → API keys**). The plaintext key
is returned exactly once; only its SHA-256 hash is stored.




## OpenAPI

````yaml /openapi.yaml post /v1/projects/{id}/keys
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. The
    `/v1/projects*` endpoints are the one exception — they authenticate with a
    separate **account API key** (`ck_acct_…`) instead, scoped to every
    project the account owns rather than to a single project. The two
    credential types are strictly disjoint: a project key is rejected on
    `/v1/projects*` and an account key is rejected everywhere else. See
    [Authentication](/guides/authentication).

    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: Projects
    description: >-
      Account-scoped project management and per-project key minting. Every
      operation requires an account key (`ck_acct_…`) — a project key
      (`ck_live_…`) is rejected.
  - 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/projects/{id}/keys:
    post:
      tags:
        - Projects
      summary: Mint a project API key
      description: |
        Mint a new `ck_live_…` project API key for a project owned by the
        authenticated account, for use against the project-scoped API
        (`/v1/templates`, `/v1/renders`, `/v1/signatures`, embed). This never
        mints an account key (`ck_acct_…`) — the account key itself is issued
        only from the dashboard (**Account → API keys**). The plaintext key
        is returned exactly once; only its SHA-256 hash is stored.
      operationId: createProjectKey
      parameters:
        - $ref: '#/components/parameters/ProjectId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: Defaults to "API key" when omitted.
            example:
              name: Render service (prod)
      responses:
        '201':
          description: Project key minted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectKeyMintResult'
              example:
                id: 9c8b7a6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
                projectId: 3f9b6c2e-1a2b-4c3d-9e8f-7a6b5c4d3e2f
                name: Render service (prod)
                prefix: ck_live_aBcDe
                key: ck_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ012345
                createdAt: '2026-07-02T00:00:00.000Z'
        '400':
          description: Body was not valid JSON.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_json
                  message: Request body must be valid JSON.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/ProjectNotFound'
        '422':
          description: '`name`, if provided, must be non-empty and at most 200 characters.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_request
                  message: Invalid request body.
      security:
        - bearerAccountKey: []
components:
  parameters:
    ProjectId:
      name: id
      in: path
      required: true
      description: The project id.
      schema:
        type: string
        format: uuid
  schemas:
    ProjectKeyMintResult:
      type: object
      description: >-
        Response for POST /v1/projects/{id}/keys. `key` is the plaintext
        `ck_live_…` value — shown exactly once, never recoverable afterwards.
      required:
        - id
        - projectId
        - name
        - prefix
        - key
        - createdAt
      properties:
        id:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        name:
          type: string
          description: Defaults to "API key" when no name was supplied at mint time.
        prefix:
          type: string
          description: >-
            Public-facing prefix (e.g. `ck_live_aBcDe`), safe to display after
            creation.
        key:
          type: string
          description: Plaintext project API key. Store it now — it cannot be shown again.
        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.
  responses:
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Missing Bearer token.
    ProjectNotFound:
      description: >-
        No such project owned by this account (never disclosed to be owned by
        someone else).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
              message: Project not found.
  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.
    bearerAccountKey:
      type: http
      scheme: bearer
      description: |
        Account API key (`ck_acct_…`) presented as a bearer token. Distinct
        credential system from `bearerApiKey` — validated against a separate
        table, never against project keys or vice versa. Scoped to every
        project owned by the account; used **only** by the `/v1/projects*`
        endpoints below (each of which declares this scheme explicitly and
        does not inherit the document-level `bearerApiKey` default). Minted
        from the dashboard (**Account → API keys**) — there is no
        programmatic endpoint that issues an account key.

````