Skip to content

Download PDF result file

This guide demonstrates how to use the record.finished webhook to know when a record has been completed by the user with a result available, and then download the resulting PDF file via our API. The PDF returned by the download endpoint is the same file shown in the back-office.

Prerequisites

  • Amiqus API credentials: Ensure you have valid credentials to authenticate your requests.
  • Webhook subscription: You must be subscribed to the record.finished event in your webhook settings.
  • Stored record ID: When you created the record (via the Create a Record endpoint), you should have stored the returned record_id.
    • If you have not created a Client and Record yet, you can follow this Registration Flow guide to create a client and record.

Overview of the flow

Step-by-step guide

1. Subscribe to the record.finished webhook

In your Amiqus dashboard, add your endpoint URL under Webhooks and select the record.finished event.

A sample webhook payload will look like:

json
{
  "webhook": {
    "uuid": "db6a2d91-b67e-4f88-b71a-b73da98c5168",
    "created_at": "2023-02-11T13:01:34Z",
    "events": ["*"]
  },
  "trigger": {
    "triggered_at": "2023-06-28T16:15:27Z",
    "alias": "record.finished"
  },
  "data": {
    "record": {
      "id": 1,
      "show": "https://id.amiqus.co/api/v2/records/1",
      "download": "https://id.amiqus.co/api/v2/records/1/download"
    }
  }
}

2. Receive the webhook

When a user completes all checks, Amiqus will send a POST request to your endpoint. The webhook will contain a payload with the record ID and a download URL as shown above.

3. Download the PDF result file

Use the download URL from the webhook to call the Download a Record endpoint. This returns the PDF binary, which you can save.

What happens next?

  • Store the PDF: Save it to your storage.
  • Log the download: Record audit details (timestamp, recordId, user) for compliance.
  • Notify stakeholders: Optionally send an email or internal notification confirming the result is available.
  • Error handling: If the endpoint returns a non-200 response, log the error and retry or alert your team.