Skip to main content
POST
/
documents
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: 'My API Key',
});

const response = await client.documents.uploadJson({
  url: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
});

console.log(response.data);
{
  "data": {
    "id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
    "record_type": "document",
    "created_at": "2018-02-02T22:25:27.521Z",
    "updated_at": "2018-02-02T22:25:27.521Z",
    "content_type": "application/pdf",
    "size": {
      "unit": "bytes",
      "amount": 123456
    },
    "status": "pending",
    "sha256": "08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
    "filename": "test-document.pdf",
    "customer_reference": "MY REF 001",
    "av_scan_status": "scanned"
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
  • Option 1
  • Option 2
url
string
required

If the file is already hosted publicly, you can provide a URL and have the documents service fetch it for you.

Example:

"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"

filename
string

The filename of the document.

Example:

"test-document.pdf"

customer_reference
string

Optional reference string for customer tracking.

Example:

"MY REF 001"

Response

Successful response

data
object