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

# Refresh an embed session

> Rotate a session token using a single-use renew token. Authenticated by the partner secret.



## OpenAPI

````yaml /openapi.yaml post /v1/embed/sessions/refresh
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/sessions/refresh:
    post:
      tags:
        - Embed
      summary: Refresh an embed session
      description: >-
        Rotate a session token using a single-use renew token. Authenticated by
        the partner secret.
      operationId: refreshEmbedSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - renewToken
              properties:
                renewToken:
                  type: string
                  minLength: 8
            example:
              renewToken: rt_abc123
      responses:
        '200':
          description: Session rotated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedSessionResponse'
        '400':
          description: Body was not valid JSON.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimpleError'
        '401':
          description: Missing/invalid credentials, or refresh failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimpleError'
              example:
                error: refresh_failed
                message: renew token expired
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
      security:
        - bearerApiKey: []
components:
  schemas:
    EmbedSessionResponse:
      type: object
      description: snake_case response from session mint/refresh.
      required:
        - session_id
        - session_token
        - iframe_url
        - expires_at
        - renew_token
      properties:
        session_id:
          type: string
          format: uuid
        session_token:
          type: string
        iframe_url:
          type: string
          format: uri
        expires_at:
          type: string
          format: date-time
        renew_token:
          type: string
    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
  responses:
    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.

````