GET /v1/file/download/{filetoken}
Endpoint URL Format:
{filetoken} with the actual filetoken identifier. For example:
- 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
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key | string | Yes | Your 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
| Header | Type | Description |
|---|---|---|
Content-Type | string | The MIME type of the file (e.g., application/pdf, image/png) |
Content-Disposition | string | The filename and disposition information |
Content-Length | integer | The size of the file in bytes |
Error Responses
If an error occurs, the endpoint returns a JSON response with the following structure:| Parameter | Type | Description |
|---|---|---|
error | boolean | Indicates whether an error occurred (true means error) |
status | integer | Status code of the request (200, 404, 403, 500, etc.). For more information, see Response Codes. |
message | string | Error message describing what went wrong |
errorCode | integer | Error 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:
Example Error Response
To see the main response codes, please refer to the Response Codes page.
Inconsistent URL Encoding in cURL Output: When using cURL to make API requests, the output JSON may show URL characters encoded as Unicode escape sequences. For example, the ampersand character (
&) may appear as \u0026 in the cURL output. This is normal JSON encoding behavior and does not affect the validity of the URL. The URL will function correctly when used, as JSON parsers automatically decode these escape sequences. If you’re parsing the response programmatically, your JSON parser will handle this conversion automatically.Code Samples
- CURL
- JavaScript/Node.js
- Python
- PHP
- C#