Files

POST/v1/files/upload/fromLocal

Upload from local file

Upload local files for further processing. To upload a local file:

  1. Send a POST request with the file name in the request body to the endpoint specified in the 1. Get Upload URL section. The response contains the input file ID and an upload URL.
  2. Send a PUT request to the URL with the file in the request body. See section 2. Upload local file for details.

1. Get Upload URL

POST /v1/files/upload/fromLocal

Request body

  • Name
    fileName
    Type
    string
    Type
    Required
    Description

    Name of the local file.

Request

POST
/v1/files/upload/fromLocal
curl -L -X POST 'https://api.pdf-tools.com/v1/files/upload/fromLocal' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
"fileName": "input.pdf"
}' 

Response

{
  "fileId": "a8b6b20b-298e-41c0-9da0-795410d1b891",
  "uploadUrl": "upload-url.com"
}

2. Upload local file

PUT <uploadUrl>

Replace <uploadUrl> with uploadUrl from previous step.

Headers

  • Name
    Content-Type
    Type
    string
    Type
    Required
    Description

    Specify content type as JSON. Accepted values: application/octet-stream

Request body

File binary data

PUT
<UPLOAD_URL>
curl --location --request PUT '<UPLOAD_URL>' \
--header 'Content-Type: application/octet-stream' \
--data '@<PATH_TO_LOCAL_FILE>'

Response

{
  // Empty 200 response
}


POST/v1/files/upload/fromUrl

Upload from URL

Upload files from the URL for further processing. To upload a file using a URL, send a POST request to this endpoint with the file URL in the request body. The response contains the input file ID.

Request body

  • Name
    fileUrl
    Type
    string
    Type
    Required
    Description

    URL of the file.

Request

POST
/v1/files/upload/fromUrl
curl -L -X POST 'https://api.pdf-tools.com/v1-beta/files/upload/fromUrl' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: <API_KEY_VALUE>' \
  --data-raw '{
    "fileUrl": "https://www.pdf-tools.com/public/downloads/whitepapers/Whitepaper-PDF-Primer-EN.pdf"
  }'

Response

{
  "fileId": "a8b6b20b-298e-41c0-9da0-795410d1b891"
}
GET/v1/files

List files

Returns a list of active files, this includes both user files and operation result files.

Query parameters

  • Name
    onlyResultFiles
    Type
    bool
    Type
    Optional
    Description

    Show only result files.

Request

GET
/v1/files
curl -L -X GET 'https://api.pdf-tools.com/v1/files' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>'

Response

{
  "files": [
    {
        "id": "39460f55-d529-4a0a-9a99-6cd8716a1cc1",
        "createdAt": "2024-03-07T15:00:59.1103018Z",
        "origin": "fromUrl",
        "name": "Whitepaper-PDF-Primer-EN.pdf",
        "extension": "pdf"
    }
  ]
}
GET/v1/files/{fileId}

Get file by ID

Returns information about a specific file.

Path parameters

  • Name
    fileId
    Type
    string
    Type
    Required
    Description

    The ID of the file to use for this request.

Request

GET
/v1/files/{fileId}
curl -L -X GET 'https://api.pdf-tools.com/v1/files/<FILE_ID>' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>'

Response

{
  "id": "39460f55-d529-4a0a-9a99-6cd8716a1cc1",
  "createdAt": "2024-03-07T15:00:59.1103018Z",
  "origin": "fromUrl",
  "name": "Whitepaper-PDF-Primer-EN.pdf",
  "extension": "pdf"
}
DELETE/v1/files/{fileId}

Delete file

Delete a file.

Path parameters

  • Name
    fileId
    Type
    string
    Type
    Required
    Description

    The ID of the file to use for this request.

Request

DELETE
/v1/files/{fileId}
curl -L -X DELETE 'https://api.pdf-tools.com/v1/files/<FILE_ID>' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>'

Response

{
  "files": [
    {
        "id": "39460f55-d529-4a0a-9a99-6cd8716a1cc1",
        "createdAt": "2024-03-07T15:00:59.1103018Z",
        "origin": "fromUrl",
        "name": "Whitepaper-PDF-Primer-EN.pdf",
        "extension": "pdf"
    }
  ]
}

Was this page helpful?