# Add a document to a loading

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /loadings/{loading_id}/documents:
    post:
      summary: Add a document to a loading
      deprecated: false
      description: Uploads a document (as base64) and attaches it to a loading.
      operationId: createDocument
      tags:
        - LoadingCalendar API/Documents
        - Documents
      parameters:
        - name: loading_id
          in: path
          description: ''
          required: true
          example: 0
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentCreateRequest'
      responses:
        '201':
          description: Document created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
          headers: {}
          x-apidog-name: ''
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                errors:
                  - Invalid API key
          headers: {}
          x-apidog-name: Unauthorized
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: string
                      examples:
                        - Not found
                    examples:
                      - - Not found
                x-apidog-refs: {}
                x-apidog-orders:
                  - errors
                x-apidog-ignore-properties: []
              example:
                errors:
                  - Not found
          headers: {}
          x-apidog-name: NotFound
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: string
                      examples:
                        - Validation failed
                    examples:
                      - - Validation failed
                x-apidog-refs: {}
                x-apidog-orders:
                  - errors
                x-apidog-ignore-properties: []
              example:
                errors:
                  - Validation failed
          headers: {}
          x-apidog-name: UnprocessableEntity
      security: []
      x-apidog-folder: LoadingCalendar API/Documents
      x-apidog-status: released
      x-run-in-apidog: https://app.eu.apidog.com/web/project/361044/apis/api-4047029-run
components:
  schemas:
    DocumentCreateRequest:
      type: object
      required:
        - filename
        - base64
      properties:
        category:
          type: string
          enum:
            - loading_plan
            - proof_of_loading
            - other
            - bill_of_lading
            - packing_slip
          x-apidog-enum:
            - value: loading_plan
              name: ''
              description: ''
            - value: proof_of_loading
              name: ''
              description: ''
            - value: other
              name: ''
              description: ''
            - value: bill_of_lading
              name: ''
              description: ''
            - value: packing_slip
              name: ''
              description: ''
        filename:
          type: string
          examples:
            - delivery-note.pdf
        content_type:
          type: string
          examples:
            - application/pdf
          default: application/octet-stream
          enum:
            - application/pdf
            - image/jpeg
            - image/png
            - image/gif
            - text/plain
            - text/csv
            - application/msword
            - >-
              application/vnd.openxmlformats-officedocument.wordprocessingml.document
            - application/vnd.ms-excel
            - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            - application/octet-stream
          x-apidog-enum:
            - value: application/pdf
              name: ''
              description: ''
            - value: image/jpeg
              name: ''
              description: ''
            - value: image/png
              name: ''
              description: ''
            - value: image/gif
              name: ''
              description: ''
            - value: text/plain
              name: ''
              description: ''
            - value: text/csv
              name: ''
              description: ''
            - value: application/msword
              name: ''
              description: ''
            - value: >-
                application/vnd.openxmlformats-officedocument.wordprocessingml.document
              name: ''
              description: ''
            - value: application/vnd.ms-excel
              name: ''
              description: ''
            - value: >-
                application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
              name: ''
              description: ''
            - value: application/octet-stream
              name: ''
              description: ''
        base64:
          type: string
          description: Base64-encoded file content
      x-apidog-orders:
        - category
        - filename
        - content_type
        - base64
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    Document:
      type: object
      properties:
        id:
          type: integer
        category:
          type: string
          enum:
            - loading_plan
            - bill_of_lading
            - packing_slip
            - proof_of_loading
            - other
          x-apidog-enum:
            - value: loading_plan
              name: ''
              description: ''
            - value: bill_of_lading
              name: ''
              description: ''
            - value: packing_slip
              name: ''
              description: ''
            - value: proof_of_loading
              name: ''
              description: ''
            - value: other
              name: ''
              description: ''
          examples:
            - bill_of_lading
        filename:
          type: string
          examples:
            - delivery-note.pdf
        content_type:
          type: string
          examples:
            - application/pdf
          enum:
            - application/pdf
            - image/jpeg
            - image/png
            - image/gif
            - text/plain
            - text/csv
            - application/msword
            - >-
              application/vnd.openxmlformats-officedocument.wordprocessingml.document
            - application/vnd.ms-excel
            - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            - application/octet-stream
          x-apidog-enum:
            - value: application/pdf
              name: ''
              description: ''
            - value: image/jpeg
              name: ''
              description: ''
            - value: image/png
              name: ''
              description: ''
            - value: image/gif
              name: ''
              description: ''
            - value: text/plain
              name: ''
              description: ''
            - value: text/csv
              name: ''
              description: ''
            - value: application/msword
              name: ''
              description: ''
            - value: >-
                application/vnd.openxmlformats-officedocument.wordprocessingml.document
              name: ''
              description: ''
            - value: application/vnd.ms-excel
              name: ''
              description: ''
            - value: >-
                application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
              name: ''
              description: ''
            - value: application/octet-stream
              name: ''
              description: ''
        base64:
          type: string
          description: Base64-encoded file content
      x-apidog-orders:
        - id
        - category
        - filename
        - content_type
        - base64
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          examples:
            - - Access forbidden
      x-apidog-orders:
        - errors
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    BearerAuth:
      type: bearer
      scheme: bearer
      description: API key obtained from the Developers section
servers:
  - url: https://loadingcalendar-staging.herokuapp.com/api/v1
    description: Testing Env
  - url: https://www.loadingcalendar.com/api/v1
    description: Prod Env
security: []

```