> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowsign.app/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Flowsign is one word with a lowercase s.
> The REST API base URL is https://my.flowsign.app and every endpoint lives under /api/v1.
> When answering API questions, cite the HTTP method and endpoint path.
> API access needs the Enterprise plan and an API key with the API access permission.

# Add documents to a template

> Adds documents to a template and returns an upload URL for each file. Requires CREATE template access.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/templates/{templateId}/documents
openapi: 3.0.3
info:
  title: Flowsign API
  version: 1.0.0
  description: >-
    Public v1 API for Flowsign. Every endpoint is authenticated with a Bearer
    API key (prefix `fsk_`). Errors use `{ error, details? }`; success responses
    wrap payload data as `{ data }`.


    An organisation is divided into workspaces. A key is issued for one
    workspace and acts there on every request (see `GET /api/v1/workspaces`);
    `X-Workspace-Id` is optional and may only name that workspace. Packages,
    templates, contacts and members are scoped to the key's workspace.
servers:
  - url: https://my.flowsign.app
    description: Production
security:
  - ApiKey: []
paths:
  /api/v1/templates/{templateId}/documents:
    post:
      tags:
        - Templates
      summary: Add documents to a template
      description: >-
        Adds documents to a template and returns an upload URL for each file.
        Requires CREATE template access.
      operationId: postTemplatesByTemplateIdDocuments
      parameters:
        - schema:
            type: string
          required: true
          name: templateId
          in: path
        - schema:
            type: string
            description: >-
              The workspace the key was issued for, as returned by `GET
              /api/v1/workspaces`. Optional: omitting it acts in the key's
              workspace, and any other id is rejected with 401.
          required: false
          name: x-workspace-id
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                documents:
                  type: array
                  items:
                    type: object
                    properties:
                      nonce:
                        type: string
                        minLength: 1
                        description: >-
                          A caller-chosen string echoed back on the matching
                          document in the response, so each upload URL can be
                          matched to its file.
                        example: employment-agreement-2026-09
                      documentKind:
                        allOf:
                          - $ref: '#/components/schemas/DocumentKind'
                          - description: >-
                              STANDARD (the default) for a PDF. DYNAMIC for a
                              .docx, which is converted with `POST
                              /api/v1/templates/:templateId/documents/:documentId/convert`
                              once uploaded.
                      fileName:
                        type: string
                        minLength: 1
                        description: >-
                          The file's name including its extension. The
                          document's title is the name without the extension.
                        example: Employment agreement.pdf
                      fileSize:
                        type: integer
                        minimum: 0
                        description: >-
                          The file's size in bytes. A size over the document
                          limit is refused with 413 before anything is created.
                        example: 184320
                      pageCount:
                        type: integer
                        minimum: 1
                        description: How many pages the file has. Defaults to 1.
                        example: 4
                      order:
                        type: integer
                        minimum: 0
                        description: >-
                          Zero-based position of the document among the
                          template's documents.
                        example: 0
                    required:
                      - nonce
                      - fileName
                  minItems: 1
                  description: The documents to add. At least one.
              required:
                - documents
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      templateId:
                        type: string
                        description: The template the documents were added to.
                        example: kX9dQ2mB7pLw
                      documents:
                        type: array
                        items:
                          $ref: '#/components/schemas/UploadedDocument'
                        description: >-
                          One entry per document sent, in the same order, each
                          carrying the `nonce` it was sent with and the
                          `uploadUrl` to PUT its bytes to. Place fields
                          afterwards with `PUT
                          /api/v1/templates/:templateId/fields`.
                    required:
                      - templateId
                      - documents
                required:
                  - data
        '400':
          description: The body is not valid JSON
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Caller's plan does not include this feature (publicApi / webhooks)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: API key present but caller lacks the required permission
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No template with that id in the workspace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The template is open for editing in the app by another user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: A document's fileSize is over the per-document limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Request failed schema validation; details keyed by field
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded; see `Retry-After`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    DocumentKind:
      type: string
      enum:
        - STANDARD
        - DYNAMIC
      description: >-
        `STANDARD` is an uploaded PDF whose pages are fixed. `DYNAMIC` is a
        document converted from an editable source into content Flowsign edits
        and lays out itself, so its pages are not fixed.
      example: STANDARD
    UploadedDocument:
      type: object
      properties:
        id:
          type: string
          description: The new document's id.
          example: cmg4v8q2k0003s7xhq1w8n5r7
        nonce:
          type: string
          description: The `nonce` given for this document in the request.
          example: doc-1
        filePath:
          type: string
          description: >-
            Where the file is stored once uploaded, under the workspace's
            prefix. Informational: upload through `uploadUrl`.
          example: >-
            cmf9x1a2b0000abcd1e2f3g4h/cmf9x1a2b0001abcd5i6j7k8l/packages/cmg4v8q2k0001s7xh3b9d2f6a/cmg4v8q2k0003s7xhq1w8n5r7-Employment
            agreement.pdf
        uploadUrl:
          type: string
          format: uri
          description: >-
            A single-use signed URL. PUT the file's bytes to it within two hours
            to attach the file.
          example: >-
            https://xyzcompany.supabase.co/storage/v1/object/upload/sign/pdf/cmf9x1a2b0000abcd1e2f3g4h/cmf9x1a2b0001abcd5i6j7k8l/packages/cmg4v8q2k0001s7xh3b9d2f6a/cmg4v8q2k0003s7xhq1w8n5r7-Employment%20agreement.pdf?token=eyJhbGciOiJIUzI1NiJ9.example
      required:
        - id
        - nonce
        - filePath
        - uploadUrl
      description: A document created by an upload request, with the URL its bytes go to.
    Error:
      type: object
      properties:
        error:
          type: string
          description: What went wrong, in plain words.
          example: 'Missing permission: canSendPackages'
        details:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: >-
            Validation problems keyed by field path. Present only on 422
            responses.
          example:
            recipients.0.email:
              - Invalid email
      required:
        - error
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: fsk_*

````