Skip to main content

Outcome

Your application lists the debtor correspondence of an accepted mandate, reads the text of each email, and stores its PDF rendering and attachments.

Prerequisites

  • A Bearer key with the case:correspondence:read scope. * covers it; case:mandates:read alone still lists the history but answers 403 on the correspondence routes.
  • The exact mandate UUID — from the claim’s current mandate_id, the order.accepted payload’s mandate_id, or mandate.created.
The collection contains the correspondence the client may read: the same set the paywise portal shows. A main-mandate request lists the emails of the main case and all its subcases; a direct subcase request lists that subcase only. Each row’s source_mandate names the track it belongs to.

1. List correspondence

Follow the response’s exact next URL until it is null. Narrow the list with channel and direction (inbound or outbound). List rows carry the envelope — subject, occurred_at, direction, the email addresses (from, to, cc), history_entry_ids, and pdf_url — but no text and no attachments; read the item for both.

2. Read one item

  • channel is an open enumeration. It is email today; treat it as a plain string and skip or store items with values your application does not know yet. email carries the addresses of an email item.
  • body holds the visible text of the new message part in text and quoted earlier messages in quoted_text. The text is projected from the stored mail and is never HTML. complete: false means the text was cut at the size limit or the mail could only be projected partially; the PDF and the attachments remain the full record. body is null when no body is stored.
  • attachments[] lists the files of the email. id is an opaque string, not a UUID. status is available or unavailable (open enumeration): available comes with a download_url; unavailable means the mail structure does not allow a download, so download_url is null. Keep the metadata of an unavailable attachment, and of any status your application does not know yet, without attempting a download. size_bytes is null when the mail does not declare it.
  • history_entry_ids names the published history entries that surface this email. It is empty for an email reachable only through a client request.

3. Download the PDF and the attachments

The PDF is rendered by paywise from the header block and the plain text; the original mail HTML is never rendered. An item without a stored body has no PDF and answers 404.
Use the download_url of an available attachment, or build the route from its opaque id. The response’s Content-Type is detected from the bytes and is never taken from the mail, so it can differ from the declared mime_type; store the file by the detected type. Every download is sent with Content-Disposition: attachment and a sanitised filename — never render an attachment inline in a browser context. Unknown and unavailable attachments answer 404.

Representative response

This complete response matches CorrespondenceDetail.

Incremental reads

Use updated_since for incremental reads, exactly as for the case history. The cutoff is inclusive and rows expose updated_at, so persist the greatest applied timestamp, overlap the next sweep, and upsert items by id, keeping their newest version. An item becomes readable through a status or client-request publication; that moment counts as an update, so updated_since also returns newly readable items. With a cutoff, rows are ordered by updated_at and then id and the next URL carries an opaque cursor; follow it exactly. Items changed less than a minute ago are held back until they settle. Only advance the saved timestamp after every page has been applied. Follow the shared pagination and synchronization guidance for overlap windows and recovery after an interrupted read. A history entry’s related_resources[] reference of type email links to the correspondence item in url; the reference’s url is null when paywise keeps no stored copy of that email. With expand=history.related_resources, the expanded email body also carries correspondence_url. Subscribe to mandate.correspondence.published to learn when an item first becomes readable — through a published status or a client request. The event is sent once per item; its data carries company_id, mandate_id, mandate_url, correspondence_id, correspondence_url, and channel. Fetch correspondence_url and upsert by correspondence_id. See Webhook events.

Runnable Python workflow

Python workflow
The workflow reads only the first page; use the history workflow’s bounded next iterator for a full sweep. Attachment downloads are authenticated: retain the Bearer header, and validate that a returned download_url stays on the API HTTPS origin before sending it.

Failure and recovery

  • 403: the key lacks case:correspondence:read. Grant the scope in the developer portal; case:mandates:read alone is not enough.
  • 404: verify the selected company, the exact mandate UUID, and the item ID. Unknown items and items of another company answer 404 alike. On the PDF route, 404 also means no body is stored; on the attachment route, the attachment is unknown or unavailable.
  • 400 invalid_parameter on the list: use the documented filters and values.
  • 429: wait at least Retry-After, then resume from the exact last uncommitted next URL.
  • 503 on a download: the document storage was briefly unavailable. Retry after Retry-After seconds.