Attachment targets

How the invoice PDF gets to Invoier.

An invoice is not complete until Invoier has received the invoice document, normally a PDF. The API does not take the file in the POST /invoices request. Instead, every invoice intent comes with attachment targets: places that Invoier has set up to receive the file for that one invoice.

You find them in attachmentTargets on the invoice intent. When you create the invoice from the intent, it inherits them. Some sessions have them as well.

Which kinds of targets you get depends on how your key is set up. Handle every kind you may be given.

Email targets

{
  "emailAddress": "<unique address>",
  "expiresAt": "2025-06-08T12:00:00+00:00",
  "transferNotice": "<text to include in the invoice>"
}

The address is unique to this intent. Send the invoice to the customer as you normally would, and add the address in BCC. That is the simplest integration, because most invoicing systems can add a BCC address.

An email target is valid for 7 days.

Url targets

{
  "expiresAt": "2025-06-06T12:00:00+00:00",
  "transferNotice": "<text to include in the invoice>",
  "url": "https://s3.eu-north-1.amazonaws.com/..."
}

A url target is a pre-signed upload. Send the file to it with an HTTP POST as multipart/form-data. If the response also contains fields, every one of them must be sent as a form field, before the file.

  • The file is at most 20 MB.
  • Content-Type is required.
  • Content-Disposition must start with attachment;.
curl -X POST "$TARGET_URL" \
  -F "<every entry of fields, as name=value>" \
  -F "Content-Type=application/pdf" \
  -F "Content-Disposition=attachment; filename=invoice.pdf" \
  -F "[email protected]"

A url target is valid for 5 days.

The transfer notice

Every target can have a transferNotice. It is the text that tells the customer that the invoice has been sold, and that they must pay Invoier instead. It has to appear in the invoice PDF. Add it when you generate the invoice, which is why you create the intent before you issue the invoice.

expiresAt

expiresAt is when the target stops working. It is not when the intent or the invoice expires. After that the address stops accepting mail and the upload url stops working. Expired targets are not returned.

After the file has arrived

When the file arrives, it is attached to the invoice, and attachments lists it with an attachmentId, a type and a time. The invoice status changes from AWAITING_ATTACHMENTS to READY when everything that is needed has arrived. Poll the invoice to see it.

GET /invoices/{invoiceId}/attachments/{attachmentId} downloads an attachment.