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

# Upload a document

> Upload a document.<br /><br />Uploaded files must be linked to a service within 30 minutes or they will be automatically deleted.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/numbers-identity/documents.yml post /documents
openapi: 3.1.0
info:
  title: Telnyx Documents API
  version: 2.0.0
  description: API for Documents.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /documents:
    post:
      tags:
        - Documents
      summary: Upload a document
      description: >-
        Upload a document.<br /><br />Uploaded files must be linked to a service
        within 30 minutes or they will be automatically deleted.
      operationId: CreateDocument
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDocServiceDocumentRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateMultiPartDocServiceDocumentRequest'
        required: true
      responses:
        '200':
          $ref: '#/components/responses/DocServiceDocumentResponse'
        '422':
          $ref: '#/components/responses/documents_UnprocessableEntity'
        default:
          $ref: '#/components/responses/documents_GenericErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            const response = await client.documents.uploadJson({ document: {}
            });


            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.documents.upload_json(
                document={},
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Documents.UploadJson(context.TODO(), telnyx.DocumentUploadJsonParams{\n\t\tDocument: telnyx.DocumentUploadJsonParamsDocument{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.documents.DocumentUploadJsonParams;
            import com.telnyx.sdk.models.documents.DocumentUploadJsonResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    DocumentUploadJsonResponse response = client.documents().uploadJson();
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.documents.upload_json(document: {})

            puts(response)
        - lang: CLI
          source: |-
            telnyx documents upload-json \
              --api-key 'My API Key' \
              --document '{}'
components:
  schemas:
    CreateDocServiceDocumentRequest:
      type: object
      properties:
        url:
          description: >-
            If the file is already hosted publicly, you can provide a URL and
            have the documents service fetch it for you.
          type: string
          example: >-
            https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
        file:
          description: >-
            Alternatively, instead of the URL you can provide the Base64 encoded
            contents of the file you are uploading.
          type: string
          format: byte
          example: ZXhhbXBsZSBvZiBlbmNvZGVkIGNvbnRlbnQ=
        filename:
          description: The filename of the document.
          type: string
          example: test-document.pdf
        customer_reference:
          type: string
          description: A customer reference string for customer look ups.
          example: MY REF 001
    CreateMultiPartDocServiceDocumentRequest:
      type: object
      properties:
        file:
          description: The file you are uploading.
          type: string
          format: binary
        customer_reference:
          type: string
          description: Optional reference string for customer tracking.
          example: MY REF 001
    DocServiceDocument:
      allOf:
        - $ref: '#/components/schemas/DocServiceRecord'
        - type: object
          properties:
            record_type:
              description: Identifies the type of the resource.
              type: string
              readOnly: true
              example: document
            content_type:
              description: The document's content_type.
              type: string
              readOnly: true
              example: application/pdf
            size:
              description: Indicates the document's filesize
              type: object
              readOnly: true
              properties:
                unit:
                  description: Identifies the unit
                  type: string
                  readOnly: true
                  example: bytes
                amount:
                  description: The number of bytes
                  type: integer
                  readOnly: true
                  example: 123456
            status:
              type: string
              description: Indicates the current document reviewing status
              readOnly: true
              enum:
                - pending
                - verified
                - denied
              example: pending
            sha256:
              description: >-
                The document's SHA256 hash provided for optional verification
                purposes.
              type: string
              readOnly: true
              example: 08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c
            filename:
              description: The filename of the document.
              type: string
              example: test-document.pdf
            customer_reference:
              type: string
              description: Optional reference string for customer tracking.
              example: MY REF 001
            av_scan_status:
              type: string
              description: The antivirus scan status of the document.
              readOnly: true
              enum:
                - scanned
                - infected
                - pending_scan
                - not_scanned
              example: scanned
    documents_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/documents_Error'
      type: object
    DocServiceRecord:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Identifies the resource.
          readOnly: true
          example: 6a09cdc3-8948-47f0-aa62-74ac943d6c58
        record_type:
          type: string
          description: Identifies the type of the resource.
          readOnly: true
          example: sample_record_type
        created_at:
          type: string
          description: >-
            ISO 8601 formatted date-time indicating when the resource was
            created.
          readOnly: true
          example: '2018-02-02T22:25:27.521Z'
        updated_at:
          type: string
          description: >-
            ISO 8601 formatted date-time indicating when the resource was
            updated.
          readOnly: true
          example: '2018-02-02T22:25:27.521Z'
    documents_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
          additionalProperties: true
      type: object
  responses:
    DocServiceDocumentResponse:
      description: Successful response
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/DocServiceDocument'
    documents_UnprocessableEntity:
      description: Unprocessable entity. Check the 'detail' field in response for details.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/documents_Errors'
    documents_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/documents_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````