Make sign-up invitation-only #
On this page
Prompt:
Only let people I invite use this for now. Everyone else should see a short coming-soon page.
Also works:
- "Lock the app down to the beta group until launch."
- "Nobody gets in without an invite yet, and search engines shouldn't see it."
For every page behind sign-in, set the manifest's audience to invited (step 2). For a notice page of your own, keep public and make each realm's creation invited instead (step 1; step 2). Your AI tool then invites each person (step 3).
What your AI tool does #
- Reads the
add-sign-inskill (read_context, idskill:add-sign-in) and follows it. - Explains that invitation-only sign-up cannot keep the
entrawork-account route. Asks before removing it where your request does not say. If the manifest setsrealm.sign_in_methods, removesentrathere and resubmits the manifest. Otherwise, usestzcloud_configure_app_sign_in. - For a notice page, keeps the
publicaudience and writes the page into the application, with the session check on every page request and the optional header of step 5. - Asks you which of the two invitation-only set-ups in step 1 you want, where the prompt does not say, and for the addresses to invite where it names none.
What you need #
- The email addresses of the people to invite, your own included if you have not signed in to the application before, and a way to send each person their invitation link yourself.
- If you want a notice page, provide its wording in your chosen language.
Before your AI starts #
For the AI tool: Check the following before starting.
- A connected, signed-in AI tool (Connect your AI assistant).
- A manifest that declares the accounts service, and the application's identifier (Add sign-in to your app).
- Each realm's sign-in methods, from
tzcloud_read_app_sign_in: invitation-only sign-up cannot be combined with theentraroute.
Steps #
1. Choose who may sign up #
Two settings decide who may become a user and who may reach the pages. The realm's creation is open or invited. Under open, anyone who signs in becomes a user. Under invited, a first sign-in without an invitation creates no user and is refused unrecognized_invitation.
The manifest's audience sets who may reach the application. The platform checks it before it forwards a request.
publicneeds no end-user sign-in.invitedneeds an end-user session and accepts new users only by invitation.workforceallows only signed-in users of the declared Microsoft Entra tenant (Add work-account or Apple sign-in).
Choose one of these three combinations of audience and sign-up settings:
| You want | Audience | Creation |
|---|---|---|
| Anyone may sign up | public |
open, the new realm's default |
Only invited people, every page behind sign-in except the webhook paths you list in session_free_paths |
invited |
Invitation-only by the audience |
| Only invited people, with a notice page of your own | public |
invited, set as step 2 describes |
Under invited and workforce, a request without an end-user session is refused, on every path but /__account/ and the paths the audience lists as session-free.
The router treats a GET or HEAD whose Accept header names text/html as a page visit, unless it is a WebSocket upgrade. That visit gets a 302 redirect to /__account/signin. Other requests get 401 authentication_required, with WWW-Authenticate: Bearer. A page script's fetch with its default Accept: */*, a POST, and a WebSocket upgrade therefore get 401. A bearer the router cannot verify is refused before this choice and never gets the sign-in redirect.
A valid end-user session passes this gate regardless of method or Accept header; same-origin fetch('/api/notes') sends the session cookie by default, so it passes too.
A payment provider's webhook, or any other service's callback, has no session. To receive one under those two audiences, list its path in the audience's session_free_paths, for example {"kind": "invited", "session_free_paths": ["/webhooks/stripe"]}. The platform lets every request to a listed path through without checking who sent it. So the route at each listed path checks the provider's signature itself and refuses a request without a valid one.
The list has at most ten paths. Each starts with /, is not / alone, contains no spaces and no .., and is outside /__account/ and /__router/ in any letter case. A listed path also covers every path below it: /webhooks/stripe covers /webhooks/stripe/events, but not /webhooks/stripe-test. A public audience lists none, because it lets every request through already. A path that breaks a rule is refused manifest_invalid at its own place in the list.
A request whose path contains a dot segment, .., or an encoded dot, slash, backslash, or percent sign is never read as a listed path and is gated as usual.
The manifest's health path is gated like every other path. The platform's own deploy check still reaches it, and a request from outside without a session is refused unless the list names the path. Choosing the health path says what listing it opens.
One manifest covers every environment, so the audience applies to each. Under a public audience, anyone who knows the development hostname can reach the application. Your backend must still control access to its data. The platform does not publish that hostname, and every response includes X-Robots-Tag: noindex, nofollow. Protect development data with your own access checks or an invited audience.
2. Turn it on #
For a complete manifest with a database, sign-in, an invited audience and a plain setting, see A manifest that works.
For every page behind sign-in, set the manifest's audience to {"kind": "invited"}, with any session_free_paths, and submit it. Every realm of the application is then invitation-only, whatever its creation setting. tzcloud_configure_app_sign_in refuses creation: "open". In tzcloud_read_app_sign_in, check for effective_creation: "invited" to confirm the realm requires an invitation. creation still shows the configured value, with a detail explaining the audience override.
To allow new users to sign in without an invitation, change the audience to public and resubmit the manifest. Also make creation open: in the manifest if it sets realm.creation, or with tzcloud_configure_app_sign_in otherwise.
For a notice page, keep the public audience. If the manifest sets realm.creation, change it to invited there and resubmit the manifest. Otherwise, call tzcloud_configure_app_sign_in with creation: "invited" for production and, if it exists, development.
{ "application": "<application id>", "creation": "invited" }
Do not combine the invited audience with entra. If the submitted manifest omits realm.sign_in_methods, an existing realm with entra causes declared_audience_contradicts_route. If the manifest lists entra, validation rejects it at realm.sign_in_methods instead. Explain that entra must be removed and ask first where the person's request does not say. Then remove it in the manifest if it sets that field, or with tzcloud_configure_app_sign_in otherwise.
Under invitation-only sign-up, an emailed code is sent only to an address that belongs to a user of the realm or matches the invitation that browser opened. The page looks the same either way, so it does not reveal which addresses are known.
3. Invite each person #
Call tzcloud_invite_end_user with application and the person's email. For development, add environment: "development". Leave out invitation, which revokes an invitation instead. The answer gives an invitation with its id, email, single-use url, and expires_at, 14 days away by default. The platform does not email the invitation. Send the URL to the person yourself.
Your Turn Zero account gives you no end-user sign-in to the application. If you have not signed in before, ask your AI tool to invite an address you can read mail at. Your Turn Zero account may list a different email address or none. Open the invitation URL yourself and sign in with the invited address. Each invitation names one email address, so give your AI tool each person's, including yours. Turn Zero's application page has no invite control. People who signed in before you made sign-up invitation-only keep access.
Opening the URL opens the application's sign-in page with the realm's sign-in methods. The sign-in page shows no invitation details. It looks the same if the URL is expired or has already been used. The person signs in with a route that verifies the invited address. tzcloud_list_invitations shows the invitation as standing, then redeemed after the person signs in. Manage end users covers listing and revoking invitations.
A page for the owner alone #
Use the platform's application sign-in to keep a whole app, or one page inside a public app, private to its owner. Declaring the accounts service supplies that sign-in; you do not build an accounts system.
Your Turn Zero sign-in does not sign you in to the application. Invite your own address as step 3 describes, then open the invitation and sign in there.
Keep the whole app private #
If the request leaves sign-in methods open, ask the account owner which ones to offer. If nobody can answer, omit realm.sign_in_methods to keep the realm’s current methods.
For a new application, submit this complete manifest and invite only the owner:
{
"manifest_version": 1,
"services": [{ "kind": "accounts" }],
"health": "/health",
"region": "usa",
"egress": [],
"audience": { "kind": "invited" },
"packages": []
}
The server still answers /health. The platform's own health check reaches it without making that path public. Do not put private pages or actions in session_free_paths.
An existing user's access survives a change to invitation-only sign-up. For an existing app, review its users and outstanding invitations in Manage end users. Ask before suspending other users or revoking invitations to leave the owner alone.
Keep one page private in a public app #
Keep the audience public, declare accounts, set realm.creation to invited, and invite the owner. Keep sign-in methods compatible with invitation-only sign-up, as step 2 explains. Other routes remain public; each route that reads private data or changes it must check the owner itself.
Before the first deploy, store and bind the owner's verified email address as OWNER_EMAIL. Your AI tool reads account.address from read_account under the owner's signed-in session or an authorized computer's token. Otherwise, the person names the address. Let only you reach an admin route gives the setup and guards.
If the address is unknown and nobody can be asked, leave OWNER_EMAIL unset and omit its binding. The private page refuses every request until the address is stored and bound in a deployed version. Your AI tool reports that owner access stays closed.
Development and production have separate realms. Store the address at each environment's scope, bind it in the manifest's settings, and sign in there with that verified address. Do not make the first person who signs in the owner.
The router's x-turnzero-cloud-session header alone grants no access; do not extract its user field and trust it without verification.
For this handler, add sessionOf and the keyless route client from Tell which user sent a request. Build that client without realm or realmKeys, so verification returns the user's addresses. Dispatch GET /owner to the handler:
async function serveOwnerPage(request, response) {
const verdict = await route.verifySession(sessionOf(request), {
sessionHeader: request.headers['x-turnzero-cloud-session'] ?? null,
});
if (!('user' in verdict)) {
response.writeHead(401).end();
return;
}
const owner = process.env.OWNER_EMAIL;
const matches = owner && verdict.user.addresses.some((address) =>
address.verified === true && address.email.toLowerCase() === owner.toLowerCase());
if (!matches) {
response.writeHead(403).end();
return;
}
response.writeHead(200, { 'content-type': 'text/plain; charset=utf-8' });
response.end('Owner page');
}
Put private reads or writes after the check, and handle a failed verification request without serving private content. Apply the same check to every related data or action route. For actions, use POST or DELETE and check the request's Origin as step 6 says. A link to /__account/signin lets the owner sign in from the public page.
Check the owner's session, no session, another user's session and a session that ended. Only the owner receives the private page. A signed-out request gets 401; a verified different user gets 403.
4. A private beta: a notice page of your own #
A private beta with a notice page takes three pieces your application already controls, and an optional fourth. The platform has no single switch for it. Each piece is a few lines of your own code, and the notice's words, language, and design stay yours:
- Invitation-only sign-up under a
publicaudience (step 2). - Sign-in required on every page: your backend verifies the session on every page request, as Tell which user sent a request shows. Invitation-only sign-up restricts new users; it does not remove users who signed up earlier.
- A notice page for everyone else, this step.
- Optionally, a request header for your own tools (step 5).
The notice page needs the public audience. Under the invited audience, the platform sends a visitor without a session to the sign-in page before any code of yours runs, so the visitor never sees the notice page.
For a visitor without a session, serve a static page of your own. While the beta lasts, keep search engines out:
- give the page
<meta name="robots" content="noindex">; - send it with the response header
X-Robots-Tag: noindex, nofollow; - leave every path allowed in
/robots.txt, or serve none. A search engine readsnoindexonly on a page it may fetch, soDisallow: /would hide the noindex and leave the address listable.
The notice page is a file in your application. You choose its wording and language. Give it a link to the sign-in page for the people you invited.
5. Optional: a request header for your own tools #
Your own tools may need to read pages that show no user's data during the beta, such as a coding agent with a shell or a check script. For those pages only, accept one request header, for example X-Show-Page. Serve them to any request that includes the header, with any value. Send the same noindex headers, and Vary: X-Show-Page.
Ordinary browser navigation and crawlers do not send this header. A script can request the page with curl -H "X-Show-Page: 1" <url>.
The header is a convenience, not security: anyone who learns its name can read the pages. That is the same protection a beta notice gives. Never let the header open a page that shows a user's data; keep such pages behind sign-in.
Expected result #
Under the invited audience, tzcloud_submit_manifest responds with the realms confirmed. tzcloud_read_app_sign_in shows effective_creation: "invited". It also gives the configured creation value and a detail explaining the audience override. Under a public audience with invitation-only sign-up, tzcloud_configure_app_sign_in and tzcloud_read_app_sign_in show creation: "invited".
tzcloud_invite_end_user with email returns the invitation's id, email, single-use url, and expires_at, and its detail says nothing was emailed. After the person uses the URL, tzcloud_list_end_users lists them with standing: "active" and the route they used, and tzcloud_list_invitations shows the row as redeemed.
On the deployed hostname:
- a person who opens an invitation URL signs in and reaches the pages;
- a sign-in without an invitation creates no user and is refused
unrecognized_invitation; - under the
invitedaudience, a visitor without a session is sent to the sign-in page; - under a
publicaudience with a notice page, a visitor without a session receives your notice page with the noindex header, and/robots.txtdisallows no path; - a request from a shell with the optional header receives the page, and a browser without a session still receives the notice.
Refusals #
See the refusals reference for other platform errors.
| Refusal | Status | Cause | Remedy |
|---|---|---|---|
unrecognized_invitation |
403 | Under invitation-only sign-up, a first sign-in came without a valid invitation for that address. | Issue a new invitation for the address the person signs in with, and deliver its URL. |
creation_contradicts_audience |
409 | tzcloud_configure_app_sign_in named creation: "open" under the invited audience. |
Leave creation out or name invited. To allow new users without invitations, follow Turn it on: use public and make creation open. |
declared_audience_contradicts_route |
409 | tzcloud_submit_manifest declared invited, omitted realm.sign_in_methods, and found entra on an existing realm. |
Remove entra in the manifest if it sets realm.sign_in_methods, or with tzcloud_configure_app_sign_in otherwise. Then submit the manifest again. |
invited_realm_refuses_work_account |
409 | tzcloud_configure_app_sign_in combined invitation-only creation with the entra route. |
Leave entra out of sign_in_methods (Add work-account or Apple sign-in). |
manifest_invalid |
400 | A session_free_paths entry breaks a rule of step 1. The detail names its place in the list. |
Correct or remove that path and submit the manifest again. |
authentication_required |
401 | Under an invited or workforce audience, a request other than a page visit came without an end-user session, to a path the audience does not list as session-free. |
The person signs in at /__account/signin first. |
invalid_request |
400 | tzcloud_invite_end_user named no valid email, or gave both email and invitation. |
Give the person's address, leave out invitation, and call again. |
Related #
- Add sign-in to your app turns sign-in on and tells your backend which user sent a request.
- Manage end users lists, revokes, and reissues invitations, and suspends or deletes users.
- Receive a signed webhook opens a webhook's path under a private audience and checks its signature.
- The manifest defines the audience kinds.
- tzcloud_invite_end_user and tzcloud_list_invitations in the generated reference give each action's arguments and result.