Adds an invitations collection where authorized users invite an email address to one or more offers defined by the site, such as a club membership or a team role. The emailed link works once and expires after a configurable number of days. The host supplies send and grant functions and access rules, and the plugin handles token hashing, answering, withdrawal, limits and audit events. It requires Payload 3.80 or later and a database with transactions, and has been tested on MongoDB only.
Invitations for Payload: invite people by an emailed link that works once, with hashed tokens, expiry, withdrawal, an answer the person confirms, limits that fail closed and audit hooks.
Installation
npm i @extantape/payload-plugin-invitations0
Stars
0
Forks
0
Open Issues
2 days ago
Last Updated
0
Weekly Downloads
v
npm Version
Dependencies
00 since Nov 29
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1476459087-root)<a href="https://payloaddirectory.dev/plugins/1476459087-root"><img src="https://payloaddirectory.dev/badge/1476459087-root.svg" alt="Payload Directory"></a>README
Invitations for Payload: invite people by an emailed link that works once, with hashed tokens, expiry, withdrawal, an answer the person confirms with a button, limits that fail closed and audit hooks.
Status: first build, not published. The tests pass against an in-memory MongoDB replica set with made-up data: 140 of them, covering access through the Local API, REST and GraphQL, the lock after send, withdrawal, a withdrawal held between its read and its write while the person answers (the withdrawal is refused), expiry, rate limits, 16 answers to one link at the same moment (one wins), 8 to 10 sends to one address at the same moment, through the Local API, REST and both mixed (one is saved and every other one reads a 409 with the reason) and 12 tries at the same moment against a limit of 10 (10 pass). They also start a site on a database with transactions turned off (it refuses to start, and with allowNoTransactions: true it starts and sends) and a site with two copies of the plugin on one database, where lookupOffer and answerOffer reach only the collection the caller names. A send and a withdrawal whose request has no transaction are tried six ways each: refused by default, with nothing saved and no email, and let through with allowNoTransactions: true. It has not run on a live site, and it hasn't been tried with a real mail service or behind a real proxy. Invite codes handed over in person, per-site scoping, held invitations, batch send and React components are designed (docs/architecture/0001-design.md) and aren't built yet.
invitations. Each record offers a person one or more things your site defines, such as membership of a club or the captain's place on a team.send function once.grant function for each accepted offer, and your code adds the membership, role or seat under your own rules.canManage passes. A sender who withdraws their own invitation gets the id and the new status back. A withdrawal lands only while the invitation still waits. If the person answers first, even a moment before, the withdrawal is refused with a 409 and the answered record is left as it was.onEvent function at each step, so the trail lands in whatever audit log your site keeps. Events never carry a token, a hash or free text.send function with the link, and your code writes and sends the message.Access passes only on an exact true from your functions. A function that throws, rejects or returns anything else counts as no.
npm install @extantape/payload-plugin-invitations
For Payload 3 (^3.80.0) on Node 22 or later. The built-in limit counter is a normal Payload collection with a unique field, and the invitations collection has one unique field too. Both rules need their unique index in the database. On a SQL adapter that means a migration for the two unique fields, the limiter's slot and the invitation's liveKey. Nobody has written or run one yet, so on anything other than MongoDB those two rules are not enforced and the plugin is untested there. On MongoDB the plugin makes sure of the two indexes at startup, and adds a third so old counter rows clear themselves.
import { invitations } from '@extantape/payload-plugin-invitations'
export default buildConfig({
plugins: [
invitations({
offers: [
{ value: 'member', label: 'Member of the club' },
{ value: 'captain', label: 'Captain of a team', relationTo: ['teams'] },
],
canInvite: ({ req }) => req.user?.role === 'admin',
canManage: ({ req }) => req.user?.role === 'admin',
linkUrl: 'https://example.com/invite', // the link ends with ?token=...
limits: { proxies: 1 }, // one proxy in front of the site; see "The caller's address" below
send: async ({ req, invitation, url }) => {
await req.payload.sendEmail({ to: invitation.email, subject: 'You are invited', text: url })
},
grant: async ({ req, offer, user }) => {
// add the membership, role or seat for this account
},
}),
],
})
| Option | What it sets | Default |
|---|---|---|
offers | The kinds of thing an invitation can offer: value, label, and an optional relationTo list of collections the target comes from. With relationTo, every offer of that kind needs a target. | required |
grant({ req, invitation, offer, user }) | Your code that gives one accepted offer to the account. Throwing refuses that offer and the others carry on. The person who answered is told that offer was refused, with no reason. A host whose grant refuses an account a guardian has vetoed is one example: the adult who answered reads refused for that offer. Staff and the audit trail can't tell. The record, the history and the events say accepted, which is what the person chose. Nobody is given the error or its message. Keep your own note of a refusal inside grant if you need one. | required |
send({ req, invitation, url }) | Your code that emails the link. Called once, after the save is committed, so a save that is rolled back sends nothing. If it throws, the invitation stays waiting and the history says so. | required |
linkUrl | The page where the person opens the invitation. A string gets ?token=<token> added. A function gets the token and returns the whole address. | required |
canInvite({ req, data, operation }) | Who may send this invitation. Only an exact true passes. operation is create for a send. When the sender of a waiting invitation withdraws it, the function is asked again with operation: 'withdraw' and the stored record as data. Nobody else is asked about a withdrawal. | nobody |
canManage({ req, doc }) | Who may read it, and withdraw it whoever sent it. Only an exact true passes. | nobody |
canDelete({ req, doc }) | Who may delete a record. Only an exact true passes. A delete from server code that passes overrideAccess: true goes through and canDelete is not asked, as with every Payload collection. | nobody |
canAccept({ req, invitation, offers, user }) | Whether the account may take these offers. Only an exact true allows. Anything else refuses before anything is spent, with one plain message that is the same for every reason and every caller. Explain your rules on your own page. A refusal leaves the invitation pending, so the person can try again, and writes no history line and sends no event. | allows, and grant decides |
onEvent(event) | Receives each step: created, sent, sendFailed, withdrawn, answered, offerAccepted, offerDeclined, limitHit. offerAccepted means the person took the offer and grant was called. A failure is logged and changes nothing. created is sent inside the save's transaction, before the commit, so your audit hook has already heard of a save that is then rolled back, by Payload or by your own code. No sent follows a rolled-back save. event.req carries that transaction: a line your hook writes with event.req is rolled back too, and a line it writes without it stays. | does nothing |
senderLabel(user) | A name for the sender on the offer page. | none |
isReadOnly(req) | Return true for a session that must not write, such as an administrator viewing the site as someone else. Every write and answer is refused. | never read-only |
limits | proxies or addressOf(req) says where the caller's address comes from, and one of them is required. link and send each take { max, seconds } (10 an hour and 50 an hour). allow(name, subject) brings your own limiter, and the plugin then stores no counters. | built-in counter |
linkDays | How long an emailed link lasts. | 7 |
slug | The collection's slug. The counter's is <slug>-limits. | invitations |
usersSlug | Your auth collection. | admin.user, else users |
secret | The key for hashing tokens. Changing it ends every waiting link. | Payload's own secret |
enabled | Off keeps the collection and refuses every send and answer. Only true or false is taken, and anything else stops the site at startup. | true |
allowNoTransactions | Lets the site start on a database that has no transactions, and lets a send or a withdrawal through when its request carries no transaction. Without it the site refuses to start there, and such a write is refused with a 500. Read the warning under Limits to know before you turn it on. Only true or false is taken. | false |
overrides | labels, group and extra fields for the collection. Extra fields can be filled at create and are locked after. | none |
Every option that takes a function is checked when the site starts: grant, send, canInvite, canManage, canDelete, canAccept, onEvent, senderLabel, isReadOnly, limits.allow and limits.addressOf. Any other value, such as canInvite: true, stops the site from starting, with a message that names the option.
The link limit counts per network address, and a caller can write anything into x-forwarded-for. So the plugin reads no header until you say which part of it your own proxies wrote, and it won't start until you do.
limits.proxies is the number of proxies you run in front of the site, each adding the address it saw to the end of x-forwarded-for. With 1 the plugin reads the last entry. With 2 it reads the one before it. Everything further left came from the caller and is ignored. x-real-ip is never read.limits.addressOf(req) reads the address your own way and is used in place of proxies.A request with no address, because the header is missing, shorter than proxies or your function returned nothing, is refused with a 429. It is refused by itself and shares a counter with nobody, so it can't use up another person's tries. If you set proxies higher than the real number, callers can pick their own address again.
Both are POST and take the token in the body, never in the address. Both are open to signed-out callers and limited per address.
POST /api/invitations/offer with { "token": "..." } returns what is offered: name, note, from, expires and an offers list with an index, kind, label and target. It spends nothing.POST /api/invitations/answer with { "token": "...", "accept": [0, 2] } takes the offers at those positions. An empty list declines everything and needs no account. It returns the result for each offer: accepted, declined or refused. refused means the person took the offer and your grant threw. It comes with no reason.The answer goes to the account that owns the invited address, because opening the link shows the person holds the mailbox. A person signed in as someone else is told to sign out. An address with no account is told to sign up first, and the link stays alive. The plugin never creates an account.
The same two functions are exported for server code: lookupOffer(req, token) and answerOffer(req, { token, accept }). They return a result object with ok and, on a refusal, status and error (invalid, rate-limited, not-allowed, no-account, wrong-account, read-only or bad-request).
Both take the collection's slug as an optional last argument: lookupOffer(req, token, 'guest-invitations') and answerOffer(req, { token, accept }, 'guest-invitations'). With one copy of the plugin on the site you can leave it out. With more than one copy, each under its own slug, you have to pass it, and a call that names no collection throws an error that lists the slugs to choose from. A slug that isn't one of the plugin's collections throws too. A link looked up or answered in another copy's collection reads as a dead link.
create once to do that, for the collection of each copy of the plugin on that database. Any other database error is passed on as it came. That includes one that only carries MongoDB's retry label, such as a write that arrives while the replica set changes its primary, which reads as a 500 over REST and never as a waiting invitation. Tested on MongoDB only.canManage lets them read it. Telling them about anyone else's would show who has been invited.POST /answer opens none. So when grant throws for an answer over REST, or from server code that opened no transaction, nothing is undone: the link stays spent, the record says answered, and the person can't use the link to try again. This is deliberate. A link that came back to life after a refusal could be tried again and again against grant. To give the person another try, send a new invitation, or call answerOffer inside your own transaction and roll it back yourself.grant runs for each accepted offer. When grant throws, the person who answered is told that offer was refused, with no reason, so they know what they did not get. Staff see nothing of it. It isn't stored, it isn't in the history and no event carries it, so someone reading a record or the audit trail can't tell a refused grant from a given one. This has a cost: anyone who holds a live link and can answer it learns that grant refused, and a link can be forwarded. Each link gives that answer once, because the link stays spent.commitTransaction and rollbackTransaction at startup. The sent history line is written after the email, so the record a save returns shows only created.transactionOptions: false. Turn transactions on if you can. A plugin with enabled: false skips this check, because it sends nothing.disableTransaction: true, and a database can stop giving transactions after the site has started. Such a write reads a 500 that says why. Nothing is saved, no try is counted and no email goes out. allowNoTransactions: true lets it through, under the warning below. An answer is treated differently: it needs no transaction, as described above.allowNoTransactions: true gives up the wait for a commit. With it the site starts on such a database, and the email goes out straight after the save, inside the same request, with the sent or sendFailed event and history line. The same goes for a single send or withdrawal with no transaction on a database that has them. Nothing can be rolled back there. If a later step of the same request fails, such as one of your own hooks, the invitation stays saved and the person already holds a working link, even though the caller read an error. A withdrawal's writes are not grouped either, so a failure between them can leave the status changed and the history line missing. One waiting invitation per sender and address still holds, because the unique field does that without a transaction.tokenHash and liveKey fields are taken out of the GraphQL types by editing the types Payload built, which leans on how graphql keeps a type's fields. A test fails if a new version changes that. Their values are refused by field access either way.canManage on every record, so it suits the hundreds or low thousands of records an invitation list holds.expired. Nothing is written when one expires.MIT. Copyright (c) 2026 EXTANT APE.
payload plugin masq
Read-only masquerade for Payload admins to sign in as another user with a banner, time-limited session and audit hooks
691.3k/wk0v3
multi tenant
Manage multiple tenants and tenant-scoped content from a single Payload admin panel
100165.4k/wk46.1kv3 v4
payload plugin sharing
Share records with users and organizations through groups with Owner, Manager and Viewer levels
76425/wk0v3
payload plugin positions
Scoped, dated position grants for users on a site, organization or project, with host-defined types and an audit trail
76382/wk0v3
payload plugin guard
Central access policy file, typed predicates and guarded endpoints for Payload plugins and Local API calls
73664/wk37v3
payload plugin organizations
Organizations with member levels, approval of pending organizations, email-domain matching and an organization picker…
67596/wk0v3