Emails containing codes and links
A very common use case in automated CI and agentic flows is receiving an email with a link or code and extracting it (sign-in, sign-up, marketing and so on). Writing the regular expression for this in every project is busywork, so the API does it for you:
GET /subscriptions/{sid}/messages/{id}/extract
Same authentication and the same 404 rules as reading the message itself.
The response:
{
"codes": ["482913"],
"links": ["https://example.com/verify?t=a1b2c3"]
}
A message that contains neither answers 200 with two empty arrays. It is not
a 404 — the message exists, and "no code in this mail" is an answer your test
may want to assert on.
Extraction logic
Codes are read from the email body: runs of 4 to 8 digits that appear
within 40 characters of one of the trigger words code, OTP, PIN,
verification, verify or passcode, matched without regard to case. They
are returned in order of appearance, with repeats removed.
Links are every http:// or https:// URL in the text body and the HTML
body, in order of appearance, with repeats removed.
How to use
Fall back to the message body. GET /subscriptions/{sid}/messages/{id}
returns the text and html in full. When extraction does not fit your
template, match on the body yourself — the endpoint is a convenience, not a
dependency.
The request and response shapes, including every error status, are in the HTTP API contract and the API reference.