LogoDOCS
OverviewAuthenticationRate LimitsErrors
Logo
Sign in →

The Document object

Most PDFGate endpoints that generate, transform, or store a file return a Document object describing the result. This is the shape returned by jsonResponse: true requests, and by the Get Document endpoint.

Attributes
idstring

Unique identifier for the document.

statusenum

The current status of the document.

Possible values:
completedprocessingexpiredfaileddeleted
typeenum

Indicates which operation produced this document.

Possible values:
from_htmlflattenedwatermarkedencryptedcompresseddocument_fields_addeduploadedsignedsignature_audit_logsigning_template
fileUrlstring

A temporary, pre-signed URL from which the file can be downloaded. Only present when a preSignedUrlExpiresIn value was provided on the request that returned this object; otherwise omitted. The URL expires after the requested duration.

sizenumber

The file size in bytes.

metadataobject

Custom key-value data you set on the document at creation time.

derivedFromstring

The ID of the source document this file was generated from, if any. Present when the document was produced by an operation that transforms an existing file, such as Flatten, Compress, Protect, or Watermark.

createdAttimestamp

The date and time the document was created.

expiresAttimestamp

The date and time the underlying file is scheduled to be removed from storage, based on your account's storage retention setting. Absent if no retention duration applies.

1{2  "id": "6642381c5c61",3  "status": "completed",4  "type": "flattened",5  "fileUrl": "https://api.pdfgate.com/file/open/:preSignedUrlToken",6  "size": 1620006,7  "metadata": {8    "author": "John Doe",9    "documentType": "Contract"10  },11  "derivedFrom": "68f920bacfe16de217f019as",12  "createdAt": "2024-02-13T15:56:12.607Z",13  "expiresAt": "2024-08-13T15:56:12.607Z"14}

Get Document

Retrieves a Document object containing metadata and file details for a previously generated or uploaded document.

Path parameters
documentIdstringrequired

The ID of the document to retrieve.

Query parameters
preSignedUrlExpiresInnumber

Minimum: 60 seconds

Maximum: 86400 seconds (24 hours)

Requests a temporary authorized URL for the file. After this duration, the URL automatically expires and can no longer be used to download the PDF. The value must be provided in seconds.

GET/document/{documentId}
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl --header "Authorization: Bearer YOUR_API_KEY" \2  --request GET \3  https://api.pdfgate.com/document/{documentId}
JSON response - Document object
1{2  "id": "6642381c5c61",3  "status": "completed",4  "type": "flattened",5  "fileUrl": "https://api.pdfgate.com/file/open/:preSignedUrlToken",6  "size": 1620006,7  "createdAt": "2024-02-13T15:56:12.607Z",8  "expiresAt": "2024-08-13T15:56:12.607Z"9}

Delete Document

Deletes a document. This performs a soft delete to preserve internal records and maintain audit integrity.

When a document is deleted:

  • The generated document file is permanently removed from storage.
  • Any user-provided data, such as metadata, is anonymized.
  • The document record remains in the system for internal reference and auditing, but the document is no longer accessible or usable.

Note: Documents used as a source in an envelope with in_progress or draft status cannot be deleted. A document can only be deleted once all associated envelopes are in created, completed, or expired status.

Path parameters
documentIdstringrequired

The ID of the document to delete.

DELETE/document/{documentId}
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl --header "Authorization: Bearer YOUR_API_KEY" \2  --request DELETE \3  https://api.pdfgate.com/document/{documentId}
No Content response
1204 No Content

Get File

Retrieves a raw PDF file previously generated or uploaded.

Note: To access a generated file, you must enable file storage in your PDFGate dashboard under Settings → Storage. Files are retained only for the configured storage duration. By default, file storage is disabled.

Path parameters
documentIdstringrequired

The ID of the document whose file should be downloaded.

GET/file/{documentId}
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl -L -H "Authorization: Bearer YOUR_API_KEY" \2  "https://api.pdfgate.com/file/{documentId}" > output.pdf
File stream response
1File stream

Upload File

Uploads a PDF document. The document can be provided either as a file upload or by specifying a publicly accessible URL where the PDF is hosted.

Request Body
filefilerequired if url is not provided

File type: .pdf

Maximum size: 500 mb

The PDF file to be uploaded.

urlstringrequired if file is not provided

Use this parameter if you want to upload a PDF file accessible at a public URL.

preSignedUrlExpiresInnumber

Minimum: 60 seconds

Maximum: 86400 seconds (24 hours)

Use this to control temporary authorized access to files. After this duration, the URL automatically expires and can no longer be used to download the PDF. The value must be provided in seconds.

If you need to generate a new pre-signed URL for an existing document, use the Get Document endpoint.

metadataobject

Sets custom data to your document record.

POST/upload
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl -X POST "https://api.pdfgate.com/upload" \2  -H "Authorization: Bearer YOUR_API_KEY" \3  -F "file=@YOUR_FILE.pdf" \4  -F "metadata={\"author\":\"John Doe\",\"documentType\":\"Contract\"}" \5  -F "preSignedUrlExpiresIn=3600"
File stream response
1File stream
JSON response - Document object
1{2  "id": "6642381c5c61",3  "status": "completed",4  "fileUrl": "https://api.pdfgate.com/file/open/:preSignedUrlToken",5  "size": 1620006,6  "type": "uploaded",7  "createdAt": "2024-02-13T15:56:12.607Z"8}