docs
/
AppEngine API

Action links

One link that does one registered thing, such as approve this or decline that, sent to a person by email, text, WhatsApp, in-app notice or chat, and run as that person when they press its button.

ActionLinkModule makes direct action links. A link carries one registered action with fixed params, the person it acts as, an expiry and a number of uses. The person who gets it opens a page that says what it will do; pressing its button runs the action once, through the owning module's own function and as that person, so every rule the app holds them to still holds.

Datatype: action_link.

  • Only a sha256 hash of the link's token is stored. The token is in the URL and nowhere else, and no read returns the hash.
  • Opening a link never acts. Mail scanners and chat previews open links on their own, so only the page's button (a POST) runs the action.
  • A link that acts as a person goes only to that person's own email or phone on file.

Registered actions

A module registers what its links can do when it starts. Each action names whose authority it runs with:

actAsRuns asWho it can be sent to
usera staff user of the orgthat user's own email or phone only
customera customer of the orgthat customer's own email or phone only
anyoneno one in particularany address given

The one action registered today:

ActionactAsparamsLasts by default
approval.decideuser{ taskId, decision: 'approve' | 'reject' }7 days

approval.decide is the Approve and Decline pair in an approval email. Its page shows the workflow's name, the request's title and description, Asked by, Reason, the rows the workflow wrote or the fields of the record it is about, Stage and Asked on. It offers Note (optional), and on Decline a Why choice from the org's decline reasons. It runs the same decision as POST /approval/task/:taskId/approve or reject, so only the people the task waits on (or an admin) can decide, never their own request, and the stage's count still applies. An access request can't be approved from a link, because it needs a role or group picked: the page says Choose a role or group first and links to the app. A task already decided reads Already approved, Already declined or Withdrawn; one that moved off the person reads Not waiting on you.

Workflows add these links to their decision emails when Approve from the email is on. See Stage emails and Approvals.

Staff routes

GET/action-link/actionsJWT
POST/action-linkJWT
POST/action-link/sendJWT
GET/action-linkJWT
POST/action-link/:id/revokeJWT

All take the orgid header and are for signed-in staff; a customer token or a site's app token is refused.

  • actions lists the registered actions: name, actAs, defaultExpiryHours.
  • POST /action-link makes a link without sending it. Body: { action, params, actAs: { id | email | phone }, expiresAt? | expiresInHours?, maxUses? }. Answers { id, url, expiresAt }. The url holds the only copy of the token.
  • send makes one link and sends it. Body: the same as above, plus to: [{ channel, address? }], and optionally text (your own words above the link; without them the action's title is sent) and subject. channel is email, sms, whatsapp, notification or chat. For a link that acts as someone, leave address out and their own is used. chat posts in the direct conversation between the sender and them. One link goes on every channel named, and whichever is used first counts. Answers { id, url, expiresAt, sent, failed }.
  • GET /action-link lists links about a record (?datatype=&id=) or of one action (?action=), newest first, with each link's state now and never its token.
  • revoke withdraws a link. It stops working at once.

Expiry and uses. Without expiresAt or expiresInHours, the action's default applies (72 hours when it has none), capped at 90 days. maxUses is 1 unless given, at most 100.

Refusals answer 400 with a reason:

reasonWhen
unknown-actionNo action has that name
act-as-requiredactAs is empty for a user or customer action
unknown-personNo such user (No one in this team signs in as …) or customer
person-lockedThe person can't sign in, so a link can't act for them
not-their-addressAn address was given that isn't the person's own
no-addressThe person has no email or phone on file for that channel
channel-invalid, to-required, address-required, expiredA bad channel, no to, an anyone link with no address, or an expiry already past

The addresses are checked before the link is made, so a refused send leaves no link behind.

GET/action-link/go/:token?orgid=No auth
POST/action-link/go/:token?orgid=No auth
GET/action-link/open/:tokenNo auth
POST/action-link/open/:tokenNo auth

No sign-in: the token is the key. go/:token is the page the link opens (HTML, with the business's name and logo), and its form posts back to the same path. open/:token is the same thing as JSON for an app that draws its own page, with the orgid header.

  • GET open/:token answers { state, title, eyebrow, intro, facts, confirmLabel, tone, inputs, message?, openUrl?, expiresAt, actingAs }. It never acts. state is ready, used, expired, revoked, invalid or unavailable.
  • POST open/:token with the inputs the link asks for runs it once and answers { ok, message, title, tone, openUrl? }.

The page reads For name when the link acts as someone, and This link works until … Only you can use it, once. A link that can't be used says why instead of showing the button: Already done, This link has expired, This link was withdrawn, This link is not valid or Nothing to do here. A link whose person has since left or been locked reads This link cannot be used any more. Two presses at once are held apart: the second answers 409 This link is being used right now.

Each link keeps its last 50 events (opened, used, failed, with time, IP and browser), where it was sent (sentTo), its uses, usedAt and the last result.

Field
action, paramsWhat it runs, fixed when it was made
actAskind (user · customer · anyone), id, email, phone, name
targetdatatype, id: the record it is about, so its links can be listed from it
sentToEach send: channel, address, at
expiresAt, maxUses, uses, usedAt
statusactive · used · expired · revoked
revokedAt, revokedBy
resultok, message of the last use
eventsat, kind, ip, userAgent, message