Skip to main content

GET /v1/file/download/{filetoken}

Endpoint URL Format:
https://api.pdf.co/v1/file/download/{filetoken}
Replace {filetoken} with the actual filetoken identifier. For example:
https://api.pdf.co/v1/file/download/a1d30e75adf5eaa.................
Key Features:
  • Exclusive Access: The endpoint strictly controls access, allowing only the account owner with the correct filetoken to retrieve the associated file.
  • Secure File Retrieval: Files are securely stored and can only be accessed through the authenticated API endpoint using the filetoken.
  • File Token Based: Uses a unique filetoken identifier to access files stored in PDF.co’s built-in file storage.
Files must be uploaded to PDF.co’s built-in file storage at https://app.pdf.co/files to obtain a filetoken. The filetoken is used to securely reference and retrieve files through the API.

Request Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key for authentication. Get your API key by registering at https://app.pdf.co

Response

The endpoint returns the file content directly with the appropriate Content-Type header based on the file type. The response is a binary file stream.

Response Headers

HeaderTypeDescription
Content-TypestringThe MIME type of the file (e.g., application/pdf, image/png)
Content-DispositionstringThe filename and disposition information
Content-LengthintegerThe size of the file in bytes

Error Responses

If an error occurs, the endpoint returns a JSON response with the following structure:
ParameterTypeDescription
errorbooleanIndicates whether an error occurred (true means error)
statusintegerStatus code of the request (200, 404, 403, 500, etc.). For more information, see Response Codes.
messagestringError message describing what went wrong
errorCodeintegerError code of the request (400, 401, 403, 404, 500, etc.)

Example Response (Success)

On successful request, the endpoint returns the file binary content directly. The following example shows the response headers for a PDF file:
Response Headers:
Content-Type: application/pdf
Content-Disposition: attachment; filename="document.pdf"
Content-Length: 245678

Example Error Response

To see the main response codes, please refer to the Response Codes page.
{
    "status": "error",
    "errorCode": 404,
    "error": true,
    "message": "record not found. IMPORTANT: If you need to set JSON data then convert it into string first (e.g. using JSON.stringify(obj) ). Check https://docs.pdf.co for more details."
}

Code Samples

  • CURL
  • JavaScript/Node.js
  • Python
  • PHP
  • C#
curl --location --request GET 'https://api.pdf.co/v1/file/download/YOUR_FILETOKEN_HERE' \
--header 'x-api-key: *******************' \
--output downloaded-file.pdf