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

# Create Document

> Create a new document record with file and metadata



## OpenAPI

````yaml POST /v1/documents
openapi: 3.1.0
info:
  title: Well Document API
  version: 1.0.0
  description: API for uploading and managing financial documents in the Well platform
servers:
  - url: https://api.wellapp.ai
security: []
paths:
  /v1/documents:
    post:
      summary: Create a document
      description: Create a new document record with file and metadata
      parameters:
        - $ref: '#/components/parameters/AuthorizationHeader'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    The document file to upload (PDF, image, Word document,
                    etc.)
                data.type:
                  type: string
                  const: document
                  description: Resource type identifier
                data.attributes.file_name:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: Name of the document file
                data.attributes.workspace_id:
                  type: string
                  format: uuid
                  description: Workspace UUID
                data.attributes.external_workspace_id:
                  type: string
                  format: uuid
                  description: External Workspace UUID
                data.attributes.collect_id:
                  type: string
                  format: uuid
                  description: Collection UUID (optional)
                data.attributes.metadata.source_number:
                  type: string
                  description: Source phone number for the document
                data.attributes.metadata.target_number:
                  type: string
                  description: Target phone number for the document
                data.attributes.metadata.document_type:
                  type: string
                  enum:
                    - invoice
                    - receipt
                    - purchase_order
                    - ...
                  description: >-
                    Type of document classification. See [all document
                    types](/enums/universal-document-class-type) for complete
                    list.
                data.relationships.workspace.data.type:
                  type: string
                  const: workspace
                  description: Type for workspace relationship
                data.relationships.workspace.data.id:
                  type: string
                  format: uuid
                  description: UUID of the workspace to associate with this document
                data.relationships.company.data.type:
                  type: string
                  const: company
                  description: Type for company relationship
                data.relationships.company.data.id:
                  type: string
                  format: uuid
                  description: UUID of the company to associate with this document
                data.relationships.people.data.type:
                  type: string
                  const: people
                  description: Type for people relationship
                data.relationships.people.data.id:
                  type: string
                  format: uuid
                  description: UUID of the person to associate with this document
                data.relationships.people.data.meta.phone_number:
                  type: string
                  description: Phone number to identify the person (alternative to ID)
              required:
                - file
      responses:
        '201':
          description: Document created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
              example:
                data:
                  type: document
                  id: 550e8400-e29b-41d4-a716-446655440010
                  attributes:
                    file_name: invoice_2024.pdf
                    workspace_id: 550e8400-e29b-41d4-a716-446655440001
                    collect_id: 550e8400-e29b-41d4-a716-446655440002
                    metadata:
                      source_number: '+33123456789'
                      target_number: '+33987654321'
                      document_type: invoice
                    created_at: '2024-01-20T10:30:00Z'
                    updated_at: '2024-01-20T10:30:00Z'
                  relationships:
                    workspace:
                      data:
                        type: workspace
                        id: 550e8400-e29b-41d4-a716-446655440001
                    company:
                      data:
                        type: company
                        id: 550e8400-e29b-41d4-a716-446655440003
                    people:
                      data:
                        type: people
                        id: 550e8400-e29b-41d4-a716-446655440004
                        meta:
                          phone_number: '+33123456789'
                included:
                  - type: workspace
                    id: 550e8400-e29b-41d4-a716-446655440001
                    attributes:
                      name: Sales Team Workspace
                      description: Workspace for sales documents and invoices
                      avatar_color: '#4A90E2'
                      external_workspace_id: sales_ws_001
                      auto_extract_enabled: true
                      created_at: '2024-01-15T09:00:00Z'
                      updated_at: '2024-01-15T09:00:00Z'
                  - type: company
                    id: 550e8400-e29b-41d4-a716-446655440003
                    attributes:
                      name: ACME Corporation
                      description: Leading technology and consulting company
                      locale: fr
                      domain_name_primary_link_url: acme.com
                      tax_id:
                        value: FR12345678901
                        type: VAT
                      registration:
                        trade_name: ACME
                        registered_name: ACME Corporation SAS
                      registration_number:
                        business_type: SAS
                        value: RCS 123456789
                        registry_name: Registre du Commerce Paris
                        registry_country: FR
                      created_at: '2024-01-10T08:00:00Z'
                      updated_at: '2024-01-10T08:00:00Z'
                  - type: people
                    id: 550e8400-e29b-41d4-a716-446655440004
                    attributes:
                      first_name: Jean
                      last_name: Dupont
                      full_name: Jean Dupont
                      created_at: '2024-01-12T10:00:00Z'
                      updated_at: '2024-01-12T10:00:00Z'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          $ref: '#/components/responses/CompanyOrPersonNotFound'
        '413':
          description: Payload too large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
              example:
                code: PAYLOAD_TOO_LARGE
                status: 413
                title: Payload Too Large
                message: The uploaded file exceeds the maximum allowed size
                meta:
                  log_id: 550e8400-e29b-41d4-a716-446655440999
components:
  parameters:
    AuthorizationHeader:
      name: Authorization
      in: header
      required: true
      schema:
        type: string
      description: Bearer token for authentication
  schemas:
    Document:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - document
        attributes:
          $ref: '#/components/schemas/DocumentAttributes'
        relationships:
          type: object
          properties:
            company:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - company
                    id:
                      type: string
            people:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - people
                    id:
                      type: string
                    meta:
                      type: object
                      properties:
                        phone_number:
                          type: string
    BadRequestError:
      type: object
      properties:
        code:
          type: string
          example: SCHEMA_VALIDATION_ERROR
          description: Error code identifier
        status:
          type: integer
          example: 400
          description: HTTP status code
        title:
          type: string
          example: Validation Error
          description: Error title
        message:
          type: string
          example: The request is invalid
          description: Detailed error message
        details:
          type: array
          items:
            type: object
            properties:
              instancePath:
                type: string
                description: Path to the invalid field in the request
              schemaPath:
                type: string
                description: Path to the validation rule in the schema
              keyword:
                type: string
                description: Validation keyword that failed
              params:
                type: object
                description: Parameters related to the validation failure
              message:
                type: string
                description: Human-readable validation error message
          description: Array of detailed validation errors
        meta:
          type: object
          properties:
            log_id:
              type: string
              format: uuid
              example: 65c669d4-679c-4a8b-b8c0-fbe37699bb5b
              description: Unique identifier for tracking this error in logs
          required:
            - log_id
      required:
        - code
        - status
        - title
        - message
        - meta
    UnauthorizedError:
      type: object
      properties:
        code:
          type: string
          example: UNAUTHORIZED
          description: Error code identifier
        status:
          type: integer
          example: 401
          description: HTTP status code
        title:
          type: string
          example: Unauthorized
          description: Error title
        message:
          type: string
          example: You are not authorized to access this resource
          description: Detailed error message
        meta:
          type: object
          properties:
            log_id:
              type: string
              format: uuid
              example: 65c669d4-679c-4a8b-b8c0-fbe37699bb5b
              description: Unique identifier for tracking this error in logs
          required:
            - log_id
      required:
        - code
        - status
        - title
        - message
        - meta
    DocumentAttributes:
      type: object
      properties:
        file_name:
          type: string
        status:
          type: string
        uploaded_at:
          type: string
          format: date-time
        processed_at:
          type: string
          format: date-time
        file_type:
          type: string
        size_bytes:
          type: integer
  responses:
    CompanyOrPersonNotFound:
      description: Company or person not found
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: COMPANY_OR_PERSON_NOT_FOUND
                description: Error code identifier
              status:
                type: integer
                example: 404
                description: HTTP status code
              title:
                type: string
                example: Company or Person Not Found
                description: Error title
              message:
                type: string
                example: >-
                  The requested company or one of the specified people could not
                  be found
                description: Detailed error message
              meta:
                type: object
                properties:
                  log_id:
                    type: string
                    format: uuid
                    example: 65c669d4-679c-4a8b-b8c0-fbe37699bb5b
                    description: Unique identifier for tracking this error in logs
                required:
                  - log_id
            required:
              - code
              - status
              - title
              - message
              - meta

````