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

# Create Document by Envelope ID

> In Nitro, a *Document* is a file that participants in an eSignature Envelope will read and sign. This could be an employment contract, NDA, legal agreement, banking form, or any other file required in your signature workflow.

The **Create Document by Envelope ID** endpoint supports uploading a **single** file per request.
Every document must be part of an Envelope container. To upload a document, first [Create an Envelope](https://developers.gonitro.com/docs/api-reference/envelope/create-envelope) and retain the Envelope `ID`.

### Supported file formats
When a `contentType` is provided in the metadata, the following formats are accepted and will be converted to PDF automatically:

#### Document formats

| Extension | Content Type |
|-----------|-------------|
| .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| .doc | application/msword |
| .dot | application/msword |
| .docm | application/vnd.ms-word.document.macroenabled.12 |
| .dotx | application/vnd.openxmlformats-officedocument.wordprocessingml.template |
| .dotm | application/vnd.ms-word.template.macroenabled.12 |

#### Spreadsheet formats

| Extension | Content Type |
|-----------|-------------|
| .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| .xls | application/vnd.ms-excel |
| .xlt | application/vnd.ms-excel |
| .xlsm | application/vnd.ms-excel.sheet.macroenabled.12 |
| .xltx | application/vnd.openxmlformats-officedocument.spreadsheetml.template |
| .xltm | application/vnd.ms-excel.template.macroenabled.12 |

#### Presentation formats

| Extension | Content Type |
|-----------|-------------|
| .pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
| .ppt | application/vnd.ms-powerpoint |

#### Web formats

| Extension | Content Type |
|-----------|-------------|
| .html | text/html |
| .htm | text/html |
| .rtf | application/rtf |
| .xml | application/xml |

#### Image formats

| Extension | Content Type |
|-----------|-------------|
| .png | image/png |
| .jpg | image/jpeg |
| .jpeg | image/jpeg |
| .tif | image/tiff |
| .tiff | image/tiff |
| .gif | image/gif |
| .psd | image/vnd.adobe.photoshop |
| .eps | application/postscript |
| .svg | image/svg+xml |

#### Other formats

| Extension | Content Type |
|-----------|-------------|
| .csv | text/csv |

#### PDF formats

| Extension | Content Type |
|-----------|-------------|
| .pdf | application/pdf |

When `contentType` is omitted from the metadata, only PDF files are accepted.

When uploading a document, the following limits apply:
  - Maximum pages per document: 250
  - Maximum size per document: 20Mb
  - Maximum documents per envelope: 15
  - Maximum size per envelope: 300 Mb




## OpenAPI

````yaml https://api.gonitro.dev/openapi.json post /sign/envelopes/{envelopeID}/documents
openapi: 3.1.0
info:
  title: Nitro Sign Public API
  description: REST API for Nitro Sign
  version: '0.1'
servers:
  - url: https://api.gonitro.dev
security:
  - bearerAuth: []
paths:
  /sign/envelopes/{envelopeID}/documents:
    post:
      tags:
        - Sign
      summary: Create Document by Envelope ID
      description: >
        In Nitro, a *Document* is a file that participants in an eSignature
        Envelope will read and sign. This could be an employment contract, NDA,
        legal agreement, banking form, or any other file required in your
        signature workflow.


        The **Create Document by Envelope ID** endpoint supports uploading a
        **single** file per request.

        Every document must be part of an Envelope container. To upload a
        document, first [Create an
        Envelope](https://developers.gonitro.com/docs/api-reference/envelope/create-envelope)
        and retain the Envelope `ID`.


        ### Supported file formats

        When a `contentType` is provided in the metadata, the following formats
        are accepted and will be converted to PDF automatically:


        #### Document formats


        | Extension | Content Type |

        |-----------|-------------|

        | .docx |
        application/vnd.openxmlformats-officedocument.wordprocessingml.document
        |

        | .doc | application/msword |

        | .dot | application/msword |

        | .docm | application/vnd.ms-word.document.macroenabled.12 |

        | .dotx |
        application/vnd.openxmlformats-officedocument.wordprocessingml.template
        |

        | .dotm | application/vnd.ms-word.template.macroenabled.12 |


        #### Spreadsheet formats


        | Extension | Content Type |

        |-----------|-------------|

        | .xlsx |
        application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |

        | .xls | application/vnd.ms-excel |

        | .xlt | application/vnd.ms-excel |

        | .xlsm | application/vnd.ms-excel.sheet.macroenabled.12 |

        | .xltx |
        application/vnd.openxmlformats-officedocument.spreadsheetml.template |

        | .xltm | application/vnd.ms-excel.template.macroenabled.12 |


        #### Presentation formats


        | Extension | Content Type |

        |-----------|-------------|

        | .pptx |
        application/vnd.openxmlformats-officedocument.presentationml.presentation
        |

        | .ppt | application/vnd.ms-powerpoint |


        #### Web formats


        | Extension | Content Type |

        |-----------|-------------|

        | .html | text/html |

        | .htm | text/html |

        | .rtf | application/rtf |

        | .xml | application/xml |


        #### Image formats


        | Extension | Content Type |

        |-----------|-------------|

        | .png | image/png |

        | .jpg | image/jpeg |

        | .jpeg | image/jpeg |

        | .tif | image/tiff |

        | .tiff | image/tiff |

        | .gif | image/gif |

        | .psd | image/vnd.adobe.photoshop |

        | .eps | application/postscript |

        | .svg | image/svg+xml |


        #### Other formats


        | Extension | Content Type |

        |-----------|-------------|

        | .csv | text/csv |


        #### PDF formats


        | Extension | Content Type |

        |-----------|-------------|

        | .pdf | application/pdf |


        When `contentType` is omitted from the metadata, only PDF files are
        accepted.


        When uploading a document, the following limits apply:
          - Maximum pages per document: 250
          - Maximum size per document: 20Mb
          - Maximum documents per envelope: 15
          - Maximum size per envelope: 300 Mb
      operationId: createDocument
      parameters:
        - name: envelopeID
          in: path
          description: >-
            A unique UUIDv4 string that identifies the envelope in the Nitro
            system.
          required: true
          schema:
            type: string
            format: uuid
        - name: nitroDocumentID
          in: query
          description: |2
              An ID reference to a user-associated Nitro Document. Instead of uploading a new file, you can attach an existing Nitro Document to an envelope by referencing its `nitroDocumentID`. This lets you reuse documents that have already been uploaded.

              To do this, provide the `nitroDocumentID` **instead** of a file in the `payload`.

              Important: `nitroDocumentID` and `payload` parameters are mutually exclusive. You must choose one of the following combinations:

              `payload` + `metadata`

              `nitroDocumentID` + `metadata`

              Providing both in the same request will throw an error.
          required: false
          schema:
            type: string
            description: |2
                An ID reference to a user-associated Nitro Document. Instead of uploading a new file, you can attach an existing Nitro Document to an envelope by referencing its `nitroDocumentID`. This lets you reuse documents that have already been uploaded.

                To do this, provide the `nitroDocumentID` **instead** of a file in the `payload`.

                Important: `nitroDocumentID` and `payload` parameters are mutually exclusive. You must choose one of the following combinations:

                `payload` + `metadata`

                `nitroDocumentID` + `metadata`

                Providing both in the same request will throw an error.
            minimum: 0
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                metadata:
                  $ref: '#/components/schemas/EnvelopeWebDocumentRequestMetadata'
                  description: The Metadata for the uploaded document
                payload:
                  type: string
                  format: binary
                  description: >
                    The document to upload, provided as binary data. Each file
                    can be up to 20 MB and 250 pages.


                    An Envelope can include up to 15 files total, with a
                    combined size limit of 300 MB.


                    Example:

                    ```bash
                       curl -X POST "https://api.gonitro.dev/sign/envelopes/{envelopeID}/documents"   -H "Authorization: Bearer <token>"   -F 'metadata={"name":"<your_document_name>","contentType":"application/pdf"};type=application/json'   -F "payload=@/path/to/document.pdf"  # @ symbol reads file content
                      ```
              required:
                - metadata
            encoding:
              metadata:
                contentType: application/json
              payload:
                contentType: application/octet-stream
              nitroDocumentID:
                contentType: text/plain
      responses:
        '201':
          description: >
            When a document is created you will get a unique ID for it. You can
            add fields to the document later by referencing its unique ID using
            other endpoints in this API. When the document is first created, it
            will be in a pending state until it is processed by our system.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PendingDocumentResponse'
        '400':
          description: Invalid envelope or document name
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/BadRequestProblemDetail'
        '401':
          description: Unauthorized - Invalid or missing JWT token
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/UnauthorizedProblemDetail'
        '413':
          description: Content too large
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ContentTooLargeProblemDetail'
        '415':
          description: File format not supported
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/UnsupportedMediaTypeDetail'
        '422':
          description: >
            Unprocessable entity - too many documents.


            An envelope can contain up to 15 documents, with each document not
            exceeding 20 MB in size.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/UnprocessableEntityProblemDetail'
components:
  schemas:
    EnvelopeWebDocumentRequestMetadata:
      type: object
      properties:
        name:
          type: string
          description: The user-given name for the uploaded document
          minLength: 1
        contentType:
          type: string
          description: >-
            The MIME type of the uploaded document. When provided, the file is
            accepted as-is without content detection and will be converted to
            PDF if needed. When omitted, defaults to application/pdf.
          example: >-
            application/vnd.openxmlformats-officedocument.wordprocessingml.document
      required:
        - name
    PendingDocumentResponse:
      type: object
      description: Response for a pending document
      properties:
        name:
          type: string
          description: Name of the file provided by the user.
          minLength: 1
        createdAt:
          type: string
          format: date-time
          description: UTC timestamp indicating when the document was created.
        status:
          type: string
          description: Current status of the document.
          enum:
            - pending
            - uploaded
            - failed
            - signed
            - sealed
        ID:
          type: string
          format: uuid
          description: Unique uuid identifier for the document.
          minLength: 1
      required:
        - ID
        - name
      title: Pending
    BadRequestProblemDetail:
      type: object
      description: Bad Request error details
      example:
        type: https://developers.gonitro.com/docs/build-nitro/errors#400-bad-request
        title: Bad Request
        status: 400
        detail: Request validation failed
        instance: /sign/envelopes
        validation_errors:
          name: must not be blank
      properties:
        type:
          type: string
          description: A URI reference that identifies the problem type
        title:
          type: string
          description: A short, human-readable summary of the problem type
        status:
          type: integer
          format: int32
          description: The HTTP status code
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence
        instance:
          type: string
          description: A URI reference that identifies the specific occurrence
        extensions:
          type: object
          additionalProperties: {}
          description: Additional problem-specific properties
    UnauthorizedProblemDetail:
      type: object
      description: Unauthorized error details
      example:
        type: >-
          https://developers.gonitro.com/docs/build-nitro/errors#401-unauthorized
        title: Unauthorized
        status: 401
        detail: Missing or invalid Authorization header
        instance: /sign/envelopes
      properties:
        type:
          type: string
          description: A URI reference that identifies the problem type
        title:
          type: string
          description: A short, human-readable summary of the problem type
        status:
          type: integer
          format: int32
          description: The HTTP status code
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence
        instance:
          type: string
          description: A URI reference that identifies the specific occurrence
        extensions:
          type: object
          additionalProperties: {}
          description: Additional problem-specific properties
    ContentTooLargeProblemDetail:
      type: object
      description: Content too large error details
      example:
        type: >-
          https://developers.gonitro.com/docs/build-nitro/errors#413-content-too-large
        title: Content too large
        status: 413
        detail: Uploaded document exceeds the file size limit of 20Mb
        instance: /sign/envelopes/envelop-123/documents
      properties:
        type:
          type: string
          description: A URI reference that identifies the problem type
        title:
          type: string
          description: A short, human-readable summary of the problem type
        status:
          type: integer
          format: int32
          description: The HTTP status code
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence
        instance:
          type: string
          description: A URI reference that identifies the specific occurrence
        extensions:
          type: object
          additionalProperties: {}
          description: Additional problem-specific properties
    UnsupportedMediaTypeDetail:
      type: object
      description: Unsupported Media Type error details
      example:
        type: >-
          https://developers.gonitro.com/docs/build-nitro/errors#415-unsupported-media-type
        title: Unsupported Media Type
        status: 415
        detail: 'The provided media type is not supported: application/pdf'
        instance: /sign/conversions
      properties:
        type:
          type: string
          description: A URI reference that identifies the problem type
        title:
          type: string
          description: A short, human-readable summary of the problem type
        status:
          type: integer
          format: int32
          description: The HTTP status code
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence
        instance:
          type: string
          description: A URI reference that identifies the specific occurrence
        extensions:
          type: object
          additionalProperties: {}
          description: Additional problem-specific properties
    UnprocessableEntityProblemDetail:
      type: object
      description: Unprocessable Entity error details
      example:
        type: >-
          https://developers.gonitro.com/docs/build-nitro/errors#422-unprocessable-entity
        title: Unprocessable Entity
        status: 422
        detail: Too many documents in envelope
        instance: /sign/envelopes
      properties:
        type:
          type: string
          description: A URI reference that identifies the problem type
        title:
          type: string
          description: A short, human-readable summary of the problem type
        status:
          type: integer
          format: int32
          description: The HTTP status code
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence
        instance:
          type: string
          description: A URI reference that identifies the specific occurrence
        extensions:
          type: object
          additionalProperties: {}
          description: Additional problem-specific properties
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````