Invoice

Generate an invoice's Certificate of Analysis (COA) PDF

Generate a single combined Certificate of Analysis (COA) PDF for an invoice — assembled by merging the primary lab-result file of each line item's batch or package into one document — and download it directly, get a signed link to it, or email it (see format). Use it to hand a customer the lab paperwork backing everything they were billed for. This is a read-only operation with no side effects.

Returns 404 when the invoice has no attached lab results — i.e. none of its line items resolve to a batch or package that has a lab-result file. A COA that exists on the batch/package but is not yet uploaded as a file will not appear here. That 404's message reads This invoice has no lab results attached, which tells it apart from an unknown ID (Not Found).

The same permissions that govern downloading this PDF in the Distru web app apply to this endpoint; when format is email, the web app's permission for emailing it applies instead (documents the web app cannot email keep the download permission).

format selects how the generated PDF is delivered and has three modes: binary returns the raw PDF bytes as the response body (Content-Type: application/pdf); url returns a JSON envelope {"data": {"url": ..., "expires_datetime": ...}} with a temporary signed download URL; email sends the PDF to the addresses in email_addresses and returns a JSON envelope {"data": {"emailed_to": [...]}}. format is required, but for backward compatibility omitting it defaults to binary.

All PDF download endpoints share a single, combined rate limit for your account: 20 requests per minute and 1000 per day in total across every PDF endpoint (not per endpoint). Requests over the limit return 429 with a Retry-After header, and only successful downloads count toward it.

post/public/v1/invoices/{id}/test-results/pdf

Request

  • Base URL
    https://app.distru.com
  • Auth
    HTTP bearer

Path parameters

idstring required

The invoice's ID — the id returned by the list and show invoice endpoints.

Request body

format'binary' | 'url' | 'email' required

How the generated PDF is delivered. One of binary — the raw PDF bytes as the response body (Content-Type: application/pdf); url — a JSON body with a short-lived signed download URL (see the PdfResponse response); or email — emails the PDF to the addresses in email_addresses and returns a JSON body listing who it was emailed to. Required, but omitting it defaults to binary for backward compatibility.

email_addressesstring[]

Recipient email addresses, used only when format is email (required in that case, ignored otherwise). An entry may hold several comma-separated addresses; spaces, blank entries and repeats are dropped, and emailed_to lists the addresses actually emailed. At least one address is required and every address must be valid, otherwise the request is rejected with a 400. At most 200 addresses may be given, counted after that cleanup.

Response

When format is binary (or omitted), the raw PDF file (Content-Type: application/pdf). When format is url, a JSON body with a temporary signed download URL; when format is email, a JSON body listing the addresses the PDF was emailed to (see the PdfResponse schema).

Changes

No recorded changes to this operation across all 17 revisions of this API.