Skip to main content
Now that you have your access token, you are ready to make your first API call to test your access to the Nitro PDF Services API. Your first call will be a POST request that optimizes a PDF file and returns a download URL for the resulting file.

Optimize a PDF

The Optimize method of the Transformations endpoint restructures a PDF and applies image downsampling according to a chosen profile, producing an output tailored to a specific use case (such as web viewing, printing, or archiving). Run the following curl command to optimize a PDF. Replace the <access_token> placeholder with a valid access token, either generated via code or extracted from your browser’s Application tab in the dev tools. Replace /path/to/your-file.pdf with the path to a local PDF file.

Request

curl --request POST \
  --url https://api.gonitro.dev/platform/transformations \
  --header 'Authorization: Bearer <access_token>' \
  --form 'method=optimize' \
  --form 'params={"profile":"web"}' \
  --form 'file=@/path/to/your-file.pdf'
The params.profile field selects a predefined optimization profile:
  • web — Linearizes the PDF for fast web delivery and downsamples images to screen resolution. Best for online viewing and email attachments.
  • print — Preserves print-resolution images and optimizes for fidelity over size. Best for high-quality printing.
  • archive — Converts to PDF/A, embedding all fonts and color profiles. Best for long-term storage and compliance.
  • minimal-file-size — Aggressively downsamples images and removes redundant data to produce the smallest possible file. Best when size reduction is the priority.
  • mixed-raster-content — Applies MRC compression, separating text and background layers. Best for scanned documents and pages mixing text and images.

Response

Below is an example response. The result.file.URL field contains a time-limited, pre-signed link to download the optimized PDF.
{
  "result": {
    "file": {
      "URL": "https://your-optimized-file.pdf",
      "contentType": "application/pdf",
      "metadata": {
        "fileSizeBytes": 8543,
        "pageCount": 1
      }
    }
  }
}

Response types

200 Success Successful request. The response contains a pre-signed URL to download the optimized PDF along with its content type and metadata (file size and page count). 401 Unauthorized If your access token is expired or invalid, you will receive a 401 Unauthorized response. If this happens, renew your access token and try again. If you continue getting the error after renewing the token, check the validity of the client_secret key that generated it. 413 Content Too Large The uploaded file exceeds the 25 MB or 200-page limit. Split the PDF into smaller parts and retry.

Next steps

Once you complete this section, you are ready to start working on your integration. We recommend exploring the PDF Services API reference for the full list of transformations, extractions, and conversions available.