REST Endpoints
The Foir public API is GraphQL-first, but a handful of surfaces are plain REST because their callers aren’t GraphQL clients — a mail client following an unsubscribe link, or an off-the-shelf OAuth library discovering how to sign people in. They all live on the same public host, https://api.foir.dev.
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/v1/events | GET | Admin key with events:read | Cursor-resumable read of the project’s event log |
/v1/email/unsubscribe | GET, POST | Signed token (query string) | RFC 8058 one-click unsubscribe from notification emails |
/.well-known/openid-configuration | GET | none | Discovery document for signing people in |
/oauth/authorize, /oauth/token, /oauth/revoke | GET, POST | PKCE / client | OAuth 2.1 authorization-code flow (see the hosted sign-in guide) |
/.well-known/jwks.json | GET | none | Public keys for verifying a person’s access token |
Event log
GET https://api.foir.dev/v1/events?after=<seq>&limit=<n>&event=<name>A cursor-paged read of the project’s durable event history, forward by seq. It is REST because its caller is usually a pipeline resuming from a stored cursor — a shell script, a Lambda, an ETL step — for which three query parameters and a list-plus-cursor response are simpler than a GraphQL client.
Authenticated with an admin key holding events:read. This is a user surface: neither a publishable nor a server key can hold that scope, and a request carrying a person’s token is refused whatever key accompanies it. Unlike the rest of the public API it is not response-cached, because a cached page of a log can re-serve events a consumer has already processed.
Full reference, including the 410 Gone cursor-expiry contract and the 90-day retention window: Event Log.
Email unsubscribe (RFC 8058)
Every notification email Foir sends carries an RFC 8058 List-Unsubscribe header pointing at:
https://api.foir.dev/v1/email/unsubscribe?token=<signed-token>The token is a self-contained, HMAC-signed value Foir mints when the email is queued; it identifies the recipient and is the only credential. There is nothing for you to call or configure — the endpoint exists so a recipient’s mail client (or the “unsubscribe” link in the email) can opt them out of notification emails in one click.
| Method | Behavior |
|---|---|
GET | Renders a confirmation page. Prefetch-safe — it never changes state, so a mail client or security scanner that prefetches the link can’t silently unsubscribe anyone. |
POST | Performs the opt-out. This is the RFC 8058 one-click target (mail clients POST it directly) and the confirmation page’s button. |
A successful opt-out records a global opt-out from notification emails for that recipient. Account and security emails are unaffected.
Responses: 200 with an HTML page on success; 400 with an HTML page when the token is missing, invalid, or expired.
Signing people in (OAuth)
Foir’s hosted sign-in is a standard OAuth 2.1 authorization server and OpenID Connect provider, one for every app whichever people it signs in. An app reaches these endpoints through an OpenID Connect library or the SDK’s code flow, both in the hosted sign-in guide, rather than calling them by hand.
If you’re integrating from a generic OAuth library, point it at the discovery document and let it configure itself:
https://api.foir.dev/.well-known/openid-configurationIt advertises these endpoints:
| Endpoint | Method | Purpose |
|---|---|---|
/oauth/authorize | GET | Authorization-code request. A public app must send a PKCE S256 challenge; a confidential app may leave it out. Sends the person to the hosted sign-in page. |
/oauth/token | POST | Exchange an authorization code for tokens (grant_type=authorization_code) or rotate a refresh token (grant_type=refresh_token). Form-encoded, per RFC 6749. A code redeems once, for the client and redirect URI it was issued to, with the PKCE verifier of its challenge when it was issued with one. |
/oauth/revoke | POST | Revoke a refresh token and its rotation family (RFC 7009 ). Name your app with client_id, or with HTTP Basic for a confidential app: a token issued to another app is refused unauthorized_client. |
/.well-known/jwks.json | GET | Public keys for verifying a person’s access token. |
Access tokens are EdDSA JWTs that live 15 minutes by default. Their issuer is https://api.foir.dev, or the login domain’s own address for a sign-in made through a login domain. Refresh tokens are opaque strings that live 30 days by default, rotated on every use with replay detection. You don’t need to verify tokens yourself, because the platform does, but a server of yours that wants to (one holding a user’s own session, say) can fetch the keys from the JWKS URL above. See Authentication for using user tokens against the GraphQL API.