REST API to export and download a page in PDF format

Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Rest API to export and download a page in PDF format in Confluence

Environment

Confluence Data Center 7.x and later (including 8.x, 9.x, and 10.x)

Solution

Since there isn't an official API for exporting pages as PDFs as per Confluence REST API, you can use the export action from FlyingPDF as a workaround to export and download the page in PDF format.

This can be done in the below steps :

Using basic auth:

  • First, call the export URL, in verbose mode using the below curl command:

curl -v -u user:password -H "X-Atlassian-Token: no-check" <BASE_URL>/spaces/flyingpdf/pdfpageexport.action\?pageId=<PAGE-ID>
  • In the response headers from the above curl command, you'll find the URL to download the PDF under the location :

< HTTP/2 302 < cache-control: no-store < content-security-policy: frame-ancestors 'self' < content-type: text/html;charset=UTF-8 < date: Thu, 22 Aug 2024 04:11:03 GMT < expires: Thu, 01 Jan 1970 00:00:00 GMT < location: /confluence/download/export/pdfexport-20240822-220824-0410-1/test_8797801676934c48931f83261b52adf6-220824-0410-2.pdf?contentType=application/pdf < set-cookie: _b0691=720538dfc61b5d60; Path=/ < set-cookie: JSESSIONID=3A0BC7AD0A643250FD0E962B884F0ED7; Path=/confluence; Secure; HttpOnly < x-ausername: admin
  • Copy the path from the above location and make another call to download the file. Specify the destination where you want to save the file under --output :

curl -v -u user:password <BASE_URL>/download/export/pdfexport-20240822-220824-0410-1/test_8797801676934c48931f83261b52adf6-220824-0410-2.pdf --output /location/to/file.pdf

The above command will save the PDF export of the specified page to the location specified in the --output option.

Using a PAT:

Personal Access Tokens are the recommended authentication method for scripted REST API calls in Confluence Data Center 7.9 and later. PATs are user-scoped, revocable, and avoid storing passwords in scripts or environment variables.

To create a PAT, navigate to your profile picture → Personal Access Tokens → Create token. Copy the token — it is displayed only once.

  • Replace the basic auth flag (-u user:password) in the commands above with a Bearer Authorization header:

curl -v -H "Authorization: Bearer <YOUR_PAT>" -H "X-Atlassian-Token: no-check" <BASE_URL>/spaces/flyingpdf/pdfpageexport.action?pageId=<PAGE-ID>
  • Then download the file using the path from the Location header:

curl -v -H "Authorization: Bearer <YOUR_PAT>" <BASE_URL>/download/export/pdfexport-<timestamp>/<filename>.pdf --output /location/to/file.pdf

If you prefer a single curl command instead of the two-step process, use the -L flag to follow the 302 redirect automatically and -o to write the output directly to a file:

Using basic auth:

curl -L -u user:password -H "X-Atlassian-Token: no-check" -o page.pdf "<BASE_URL>/spaces/flyingpdf/pdfpageexport.action?pageId=<PAGE-ID>"

Using a PAT:

curl -L -H "Authorization: Bearer <YOUR_PAT>" -H "X-Atlassian-Token: no-check" -o page.pdf "<BASE_URL>/spaces/flyingpdf/pdfpageexport.action?pageId=<PAGE-ID>"

Note: If your Confluence instance is behind a reverse proxy that rewrites the redirect URL to a different host, the -L flag may not forward the Authorization header to the new host. In that case, use the two-step approach above instead.

Troubleshooting common errors:

HTTP 500 / timeout on large pages

Pages with many macros, large embedded content, or many attachments can exceed the default conversion sandbox stack size or timeout. The error typically appears in atlassian-confluence.log as a StackOverflowError or SandboxCrashedException.

Workaround: Increase the Java stack size for both Confluence and the conversion sandbox process by adding the following JVM system properties. Restart Confluence after applying the change. For very large pages, consider exporting the parent space PDF or breaking the page into smaller pages.

-Xss8m -Dconversion.sandbox.stack.limit.megabytes=8

HTTP 401 when using a PAT

Verify that the PAT was created by a user with View permission on the target page (Export permission is also recommended) The token has not expired (check expiration in your profile → Personal Access Tokens) The "Last authenticated" timestamp updates after your request (if it shows "Never", the token is not being recognized) The Bearer token is sent without quotes or angle brackets in the actual request

Related articles:

Updated on May 20, 2026

Still need help?

The Atlassian Community is here for you.