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

# Upload a form image

> Upload a single image (multipart `file` field) for a `fill`-mode embed
session, returning its public URL so the form payload can carry a URL
instead of a raw file. Authenticated by the embed session JWT. Max 10 MB,
`image/*` only.




## OpenAPI

````yaml /openapi.yaml post /v1/embed/form-submit/{sessionId}/upload-image
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/form-submit/{sessionId}/upload-image:
    parameters:
      - $ref: '#/components/parameters/SessionId'
    post:
      tags:
        - Embed
      summary: Upload a form image
      description: >
        Upload a single image (multipart `file` field) for a `fill`-mode embed

        session, returning its public URL so the form payload can carry a URL

        instead of a raw file. Authenticated by the embed session JWT. Max 10
        MB,

        `image/*` only.
      operationId: uploadEmbedImage
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The image file (image/* only, max 10 MB).
      responses:
        '200':
          description: Uploaded.
          content:
            application/json:
              schema:
                type: object
                required:
                  - url
                properties:
                  url:
                    type: string
                    format: uri
              example:
                url: https://cdn.craftkit.dev/embed-uploads/proj/sess/abc.png
        '400':
          description: Bad origin, missing file, or invalid multipart body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: missing_file
                  message: A "file" field is required.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Session is not in fill mode.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: wrong_mode
                  message: upload-image requires scope.mode="fill"
        '404':
          description: Session id in path does not match the token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: File exceeds the 10 MB size limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: file_too_large
                  message: File exceeds the 10 MB size limit.
        '415':
          description: Only image files are accepted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_type
                  message: Only image files are accepted.
      security:
        - embedSessionJwt: []
components:
  parameters:
    SessionId:
      name: sessionId
      in: path
      required: true
      description: The embed session id (must match the JWT subject).
      schema:
        type: string
        format: uuid
  schemas:
    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.
  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.
    embedSessionJwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Short-lived embed session JWT minted by `POST /v1/embed/sessions`. Used
        by

        the iframe form-submit / upload-image endpoints and accepted (alongside
        a

        partner key) by builder template creation.

````