palbaseDocs

Palbase Notify · API

POST/notify/email

Send an email

Queues an email through the project's own provider: a template with its variables — the platform's, as the project overrode them, or one it made — or a message composed whole. The platform's shared sender, which a project with no email provider of its own has, sends none of them for the project's key: auth's templates (auth.*) leave it from auth's own flows alone — a sign-up's confirmation, a password reset, a sign-in link — with auth's link, to the address the flow is for, and a key's send of one is refused with 403 auth_template_reserved, but for an organization's invitation (auth.org_invitation, variables inviter_name, org_name, accept_link, expires_at): any project's key sends it through the shared sender, in the platform's words and counted against its shared limits, when its accept_link is a page of the project's own app — on its auth site_url's address, or matching its redirect allow-list — and is refused with 400 accept_link_not_allowed otherwise (503 auth_unavailable, nothing sent, when auth could not be asked); its inviter_name and org_name are names and its expires_at a time — one line each, with no link or web address — or it is refused with 400 invalid_invitation. Anything else is refused with 403 own_provider_required. Through the shared sender a project sends 10 emails a minute and 100 an hour on Free, 60 and 1,000 when it pays — its month is its quota's — (429 send_limit_reached, until the window's end); an address takes 5 shared emails an hour and 20 a day, every project's together (429 recipient_limit_reached; auth's own flows' are skipped, skip_reason recipient_limit); a recipient whose domain takes no mail is refused before anything is queued (400 invalid_email_domain); an address that bounced for good or reported a shared email as spam is sent nothing again (skipped, skip_reason suppressed); and a project at least 10 of whose shared emails, and a tenth of them, bounced for good in a day stops sending through it for the day (429 shared_sender_paused, notification.shared_paused, getDeliverability). Palbase's own project, Studio's, sends its notices and its organizations' invitations to Studio's developers through the shared sender with its key.

Called by your server, with the project's secret key.

Headers

Idempotency-Keystring · optionalMakes the write safe to send again (at most 255 characters). A retry with the same key and the same request gets the first answer back, marked `Idempotent-Replayed: true`, and changes nothing; the same key with a different request is refused with 422, and while the first request still runs a retry gets 409 with Retry-After. Answers are kept for 24 hours. A refusal made before the request ran — a limit or a quota reached, a provider or a template it needs, its recipient, its body — is not kept: a retry with the same key runs it again, and may succeed.

Request body

categorystring · optionalThe message's kind: transactional (the default) reaches every user; any other — marketing, news — only users who did not turn it off on this channel (preferences). 1 to 64 of a-z, 0-9, _ . -.
couponstring · optionalOne of iap's coupons: {{coupon}} is the user's (user_id) own code of it — a shared coupon's code, or one of its one-time codes given to them, recorded as theirs.
fromobject · optionalThe send's own sender, over the project's settings (its own provider only).
htmlstring · optional
localestring · optional
localesstring[] · optionalMore locales the send would take, most wanted first, after locale (10 at most): each, then its language alone, then the project's default and English.
metadataobject · optionalThe project's own data about the message (a JSON object, 4 KiB at most), kept with its report; null is none.
priority"high" | "normal" · optionalhigh: tried again sooner when it could not leave (5 s, 15 s, 1 min instead of 10 s, 30 s, 2 min).
reply_tostring · optionalWhere replies go (own provider only).
subjectstring · optional
templatestring · optionalA template's slug. Auth's (auth.*) are sent through the project's own provider: on the platform's shared sender they are auth's flows' alone (403 auth_template_reserved), but for an organization's invitation (auth.org_invitation), whose accept_link is a page of the project's own app (400 accept_link_not_allowed).
textstring · optional
tostring · requiredOne email address.
user_idstring · optionalThe user the message is for: their preferences hold, and deleting them deletes it.
variablesobject · optional
curl
curl -X POST "https://<your-ref>.palbase.studio/notify/email" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"to":"string"}'

Responses

202Queued

400Validation failed or a required field is missing

401Missing or invalid API key

403Not the project's secret key, or not what the shared sender sends for it (`own_provider_required`; `auth_template_reserved`: auth's templates, which auth's own flows alone send through it, but for an organization's invitation, auth.org_invitation); or a change to the platform's own project (`owner_only`) without its owner's access token (X-Palbase-Owner) or its operator's token (X-Palbase-Operator) beside the key. An owner's sign-in that is not a passkey one from the last 15 minutes is 401 `insufficient_user_authentication`.

404No such provider, template or message

409A request with this Idempotency-Key is still running

422A variable the template uses was not passed, or the Idempotency-Key was sent with a different request; or the coupon has no code for the user (`no_coupon_code`)

429Over the project's request limit, or its shared sends for this window

503Temporarily unavailable; retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation SendEmail of notify's contract.