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

# Create document (Legacy)

> **DEPRECATED**: Use `/signing-requests` instead. Legacy endpoint for creating a new signing request.



## OpenAPI

````yaml api-reference/v01.19.00/openapi-v01.19.00.json post /documents
openapi: 3.0.3
info:
  title: Firma Partner API
  description: >-
    RESTful API for document signing and template management.


    **Authentication**: All endpoints require API key authentication via the
    `Authorization` header. Use your API key directly without any prefix (e.g.,
    `your-api-key`). The Bearer prefix is optional but not required.


    **Security Features**:

    - Input validation using Zod schemas with detailed field-level error
    messages

    - RSA-256 signed JWT tokens for embedded template access


    **Rate Limiting**: Rate limits are tiered based on operation type:

    - Read operations (GET): 200 requests per minute

    - Write operations (POST/PUT/PATCH/DELETE): 120 requests per minute

    - Webhook CRUD operations: 60 requests per minute

    - Webhook test: 10 requests per minute

    - API key regeneration/expiration: 1 request per minute

    - Webhook secret rotation: 1 request per minute


    When rate limits are exceeded, the API returns a `429 Too Many Requests`
    response with headers:

    - `X-RateLimit-Limit`: Maximum requests per minute for this endpoint

    - `X-RateLimit-Remaining`: Requests remaining in current window

    - `X-RateLimit-Reset`: Unix timestamp when limit resets

    - `Retry-After`: Seconds until retry is allowed


    **Error Handling**: All errors return structured JSON responses with `error`
    (human-readable message), `code` (machine-readable identifier), and
    `details` (field-level validation errors when applicable).


    **Embedded Template Integration**: The Firma Template Editor can be embedded
    in your application using a standalone JavaScript library.


    ```html

    <!-- Load the Firma Template Editor library -->

    <script
    src="https://api.firma.dev/functions/v1/embed-proxy/template-editor.js"></script>


    <script>

    // Generate JWT token via API first

    fetch('https://api.firma.dev/functions/v1/signing-request-api/generate-template-token',
    {
      method: 'POST',
      headers: {
        'Authorization': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        companies_workspaces_templates_id: 'template-id'
      })
    })

    .then(res => res.json())

    .then(data => {
      // Initialize editor with JWT token
      window.FirmaTemplateEditor.init({
        container: '#firma-editor-container',
        jwt: data.token,
        templateId: 'template-id',
        theme: 'dark',
        readOnly: false,
        onSave: (savedData) => {
          console.log('Template saved:', savedData);
        },
        onError: (error) => {
          console.error('Editor error:', error);
        },
        onLoad: (template) => {
          console.log('Template loaded:', template);
        }
      });
    });

    ```
  version: 01.19.00
  contact:
    name: API Support
    url: https://firma.com/support
servers:
  - url: https://api.firma.dev/functions/v1/signing-request-api
    description: Production API - Recommended (Current)
  - url: https://api.firma.dev/api/v1
    description: Production API - Planned
security:
  - ApiKeyAuth: []
tags:
  - name: Company
    description: Company information and settings
  - name: Workspaces
    description: Workspace management operations
  - name: Templates
    description: Template management operations
  - name: Signing Requests
    description: Document signing request operations
  - name: Custom Fields
    description: >-
      Custom field definition management for workspaces, templates, and signing
      requests
  - name: Webhooks
    description: Webhook configuration and management
  - name: JWT Management
    description: JWT token generation and revocation for embedded templates
  - name: Workspace Settings
    description: Workspace configuration and settings
  - name: Email Domains
    description: >-
      Email domain setup and verification for sending signing request emails
      from custom domains
  - name: Email Templates
    description: >-
      Email template management for workspace and company-level customization of
      signing request notifications
  - name: Legacy
    description: Deprecated endpoints maintained for backward compatibility
paths:
  /documents:
    post:
      tags:
        - Legacy
      summary: Create document (Legacy)
      description: >-
        **DEPRECATED**: Use `/signing-requests` instead. Legacy endpoint for
        creating a new signing request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: Document name
                  maxLength: 255
                recipients:
                  type: array
                  items:
                    type: object
                    required:
                      - email
                    properties:
                      name:
                        type: string
                      email:
                        type: string
                        format: email
            example:
              name: Sales Agreement 2024
              recipients:
                - name: John Doe
                  email: john@example.com
      responses:
        '201':
          description: Document created successfully
          headers:
            X-Legacy-Endpoint:
              schema:
                type: string
              description: Indicates this is a legacy endpoint
            X-Deprecated:
              schema:
                type: string
              description: Deprecation notice
            X-RateLimit-Limit:
              schema:
                type: integer
              description: 'Rate limit: 120 requests per minute'
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Remaining requests in current window
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix timestamp when rate limit resets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SigningRequestCreateResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '429':
          $ref: '#/components/responses/RateLimitError'
      deprecated: true
      security:
        - ApiKeyAuth: []
components:
  schemas:
    SigningRequestCreateResponse:
      type: object
      description: >-
        Signing request as returned by CREATE endpoints (POST /signing-requests,
        POST /documents)
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the signing request
        name:
          type: string
          description: Signing request name
          maxLength: 255
        description:
          type: string
          nullable: true
          description: Signing request description
        status:
          type: string
          enum:
            - draft
          description: Status is always 'draft' for newly created signing requests
        document_url:
          type: string
          format: uri
          description: Pre-signed URL to the PDF document
        page_count:
          type: integer
          minimum: 1
          description: Number of pages in the document
        expiration_hours:
          type: integer
          minimum: 1
          default: 168
          description: 'Hours until signing request expires (default: 168 = 7 days)'
        template_id:
          type: string
          format: uuid
          nullable: true
          description: Template ID if created from a template
        settings:
          $ref: '#/components/schemas/SigningRequestSettings'
        created_date:
          type: string
          format: date-time
          description: Creation timestamp
        updated_date:
          type: string
          format: date-time
          description: Last update timestamp
        sent_date:
          type: string
          format: date-time
          nullable: true
          description: When the signing request was sent
        finished_date:
          type: string
          format: date-time
          nullable: true
          description: When all signatures were completed
        cancelled_date:
          type: string
          format: date-time
          nullable: true
          description: When the signing request was cancelled
        recipients:
          type: array
          description: Signing request recipients
          items:
            $ref: '#/components/schemas/SigningRequestCreateRecipient'
        fields:
          type: array
          description: Signing request fields with flat position values
          items:
            $ref: '#/components/schemas/SigningRequestCreateField'
        warnings:
          type: array
          items:
            type: string
          description: >-
            Optional email format validation warnings. Only present when
            recipient emails have unusual formats.
    SigningRequestSettings:
      type: object
      description: >-
        Signing request and template settings. All 9 fields are returned by
        every endpoint that includes settings.
      properties:
        allow_download:
          type: boolean
          description: Whether recipients can download the document
          default: true
        attach_pdf_on_finish:
          type: boolean
          description: Whether to attach PDF when signing is complete
          default: true
        allow_editing_before_sending:
          type: boolean
          description: Whether the signing request can be edited before sending
          default: false
        use_signing_order:
          type: boolean
          description: >-
            Whether signing order is enforced among recipients. When true,
            signers receive the document in sequence based on their order. When
            false, all signers receive the document simultaneously.
          default: true
        hand_drawn_only:
          type: boolean
          description: >-
            When enabled, signers can only hand-draw their signatures and cannot
            use typed/font-based signatures
          default: false
        send_signing_email:
          type: boolean
          description: Whether to send signing request notification emails to signers
          default: true
        send_finish_email:
          type: boolean
          description: Whether to send completion email when all signers finish
          default: true
        send_expiration_email:
          type: boolean
          description: Whether to send expiration notification email when request expires
          default: true
        send_cancellation_email:
          type: boolean
          description: >-
            Whether to send cancellation notification email when request is
            cancelled
          default: true
        require_otp_verification:
          type: boolean
          nullable: true
          description: >-
            Whether signers must verify their email with a one-time code before
            accessing the document. null = inherit from workspace/company
            setting.
          default: null
    SigningRequestCreateRecipient:
      type: object
      description: Recipient as returned in CREATE signing request responses
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the recipient
        first_name:
          type: string
          nullable: true
          description: Recipient first name
        last_name:
          type: string
          nullable: true
          description: Recipient last name
        name:
          type: string
          nullable: true
          description: Combined full name (auto-constructed from first_name + last_name)
        email:
          type: string
          format: email
          description: Recipient email address
        designation:
          type: string
          enum:
            - Signer
            - Approver
            - CC
          description: >-
            Role of the recipient. Signer signs the document, Approver approves
            with approval fields, CC receives a copy when complete.
        order:
          type: integer
          minimum: 1
          description: Signing order
        phone_number:
          type: string
          nullable: true
          description: Recipient phone number
        street_address:
          type: string
          nullable: true
          description: Street address
        city:
          type: string
          nullable: true
          description: City
        state_province:
          type: string
          nullable: true
          description: State or province
        postal_code:
          type: string
          nullable: true
          description: Postal code
        country:
          type: string
          nullable: true
          description: Country
        title:
          type: string
          nullable: true
          description: Job title
        company:
          type: string
          nullable: true
          description: Company name
        custom_fields:
          type: object
          nullable: true
          description: Custom key-value pairs
        finished_date:
          type: string
          format: date-time
          nullable: true
          description: When this recipient completed signing
    SigningRequestCreateField:
      type: object
      description: >-
        Field as returned in CREATE signing request responses (flat position,
        database-style)
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the field
        type:
          type: string
          enum:
            - text
            - signature
            - date
            - checkbox
            - dropdown
            - radio_buttons
            - number
            - text_area
            - file
            - initial
            - stamp
            - approval_signature
            - approval_checkmark
            - approval_date
          description: Type of the field
        recipient_id:
          type: string
          format: uuid
          nullable: true
          description: ID of assigned recipient
        page_number:
          type: integer
          minimum: 1
          description: Page number (1-indexed)
        x_position:
          type: number
          description: X coordinate as percentage (0-100)
        y_position:
          type: number
          description: Y coordinate as percentage (0-100)
        width:
          type: number
          description: Width as percentage (0-100)
        height:
          type: number
          description: Height as percentage (0-100)
        required:
          type: boolean
          description: Whether the field is required
        read_only:
          type: boolean
          description: Whether this field is read-only
        read_only_value:
          type: string
          nullable: true
          description: Static value for read-only fields
        variable_name:
          type: string
          nullable: true
          description: Variable name for prefilled data mapping
        variable_defined_name:
          type: string
          nullable: true
          description: >-
            Human-readable field name from the custom field definition (e.g.
            'artist_name'). Only present for fields linked to a custom field
            definition, null otherwise.
        dropdown_options:
          type: array
          items:
            type: string
          nullable: true
          description: Options for dropdown fields
        format_rules:
          type: object
          nullable: true
          description: Formatting rules (e.g., date format)
        validation_rules:
          type: object
          nullable: true
          description: Validation rules for the field
        date_signing_default:
          type: boolean
          description: Whether to use signing date as default
        final_value:
          type: string
          nullable: true
          description: Pre-filled or final value of the field
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
        message:
          type: string
          description: Detailed error description
        details:
          type: object
          description: Additional error details
          additionalProperties: true
  responses:
    ValidationError:
      description: Bad Request - Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Validation Error
            message: Invalid input data
            details:
              name: Name is required
              email: Invalid email format
    UnauthorizedError:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unauthorized
            message: Invalid API key
    RateLimitError:
      description: Too Many Requests - Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
          description: Maximum requests per minute
        X-RateLimit-Remaining:
          schema:
            type: integer
          description: Requests remaining
        X-RateLimit-Reset:
          schema:
            type: integer
          description: Unix timestamp of reset
        Retry-After:
          schema:
            type: integer
          description: Seconds until retry allowed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Rate Limit Exceeded
            message: Too many requests. Please wait before retrying.
            details:
              retry_after: 45
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key for authentication. Use your API key directly without any prefix
        (e.g., 'your-api-key'). Bearer prefix is optional but not required.

````