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:
actAs | Runs as | Who it can be sent to |
|---|---|---|
user | a staff user of the org | that user's own email or phone only |
customer | a customer of the org | that customer's own email or phone only |
anyone | no one in particular | any address given |
The one action registered today:
| Action | actAs | params | Lasts by default |
|---|---|---|---|
approval.decide | user | { 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
/action-link/actionsJWT/action-linkJWT/action-link/sendJWT/action-linkJWT/action-link/:id/revokeJWTAll take the orgid header and are for signed-in staff; a customer token or a site's app token is refused.
actionslists the registered actions:name,actAs,defaultExpiryHours.POST /action-linkmakes a link without sending it. Body:{ action, params, actAs: { id | email | phone }, expiresAt? | expiresInHours?, maxUses? }. Answers{ id, url, expiresAt }. Theurlholds the only copy of the token.sendmakes one link and sends it. Body: the same as above, plusto: [{ channel, address? }], and optionallytext(your own words above the link; without them the action's title is sent) andsubject.channelisemail,sms,whatsapp,notificationorchat. For a link that acts as someone, leaveaddressout and their own is used.chatposts 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-linklists links about a record (?datatype=&id=) or of one action (?action=), newest first, with each link'sstatenow and never its token.revokewithdraws 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:
reason | When |
|---|---|
unknown-action | No action has that name |
act-as-required | actAs is empty for a user or customer action |
unknown-person | No such user (No one in this team signs in as …) or customer |
person-locked | The person can't sign in, so a link can't act for them |
not-their-address | An address was given that isn't the person's own |
no-address | The person has no email or phone on file for that channel |
channel-invalid, to-required, address-required, expired | A 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.
The person who got the link
/action-link/go/:token?orgid=No auth/action-link/go/:token?orgid=No auth/action-link/open/:tokenNo auth/action-link/open/:tokenNo authNo 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/:tokenanswers{ state, title, eyebrow, intro, facts, confirmLabel, tone, inputs, message?, openUrl?, expiresAt, actingAs }. It never acts.stateisready,used,expired,revoked,invalidorunavailable.POST open/:tokenwith 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.
action_link
| Field | |
|---|---|
action, params | What it runs, fixed when it was made |
actAs | kind (user · customer · anyone), id, email, phone, name |
target | datatype, id: the record it is about, so its links can be listed from it |
sentTo | Each send: channel, address, at |
expiresAt, maxUses, uses, usedAt | |
status | active · used · expired · revoked |
revokedAt, revokedBy | |
result | ok, message of the last use |
events | at, kind, ip, userAgent, message |