Upload #
Uploads a file to the PDF tools website for processing.
Endpoint #
POST
https://trupdf.com/api/v1/uploads
Parameters #
processId
(required): The unique identifier generated in the previous step (start-task
).file
(required): The PDF file to be uploaded. Only one file can be uploaded at a time.task
(required): Specifies the type of task to be performed. Example:merge-pdf
Example using cURL: #
curl -X POST \
https://trupdf.com/api/v1/uploads \
-F "processId=xYNNUCkqVVWEDsxXOLGZxCbz9ggreeNAOMErSl8wRw1WDsiZbnvECaGV6AwdtUtaYLA2PrI9WuPCGOqdiJcfp2d6d0b9p0gnbePz" \
-F "file=@/path/to/your/file.pdf" \
-F "task=merge-pdf" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H 'Content-Type: application/json'
Example using PHP: #
use GuzzleHttp\Client;
$client = new Client();
$token = 'YOUR_API_TOKEN';
$response = $client->post('https://trupdf.com/api/v1/uploads', [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json',
],
'multipart' => [
[
'name' => 'processId',
'contents' => 'xYNNUCkqVVWEDsxXOLGZxCbz9ggreeNAOMErSl8wRw1WDsiZbnvECaGV6AwdtUtaYLA2PrI9WuPCGOqdiJcfp2d6d0b9p0gnbePz'
],
[
'name' => 'task',
'contents' => 'merge-pdf'
],
[
'name' => 'file',
'contents' => fopen('/path/to/your/file.pdf', 'r'),
],
]
]);
$data = json_decode($response->getBody(), true);
Response #
Upon successful upload of the file, the server returns a JSON response with details of the uploaded file.
Example Response: #
{
"message": "File uploaded successfully",
"fileName": "example.pdf",
}
Error Responses
- If any of the required parameters (processId, file, task) are missing or invalid, the server responds with an appropriate error message.
- If there is an issue with the file upload process or any other error occurs, the server responds with an error message indicating the failure.
Notes
- Ensure that the processId used for uploading matches the one generated in the start-task step.
- Only one file can be uploaded at a time.
- The uploaded file should be in PDF format.
- Save the fileName, fileSize, and fileType for reference or verification purposes.
This step uploads a PDF file to the PDF processing workflow, ready for execution.