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 the audience public and set creation to invited in the sign-in settings for each environment (step 1; step 2). Your AI assistant then invites each person (step 3).
What your AI does #
- Reads the
add-sign-inskill (read_context, idskill:add-sign-in) and follows it. - Explains that invitation-only sign-up refuses both work-account methods,
entraandoidc. Asks before removing either if your request leaves that open. If the manifest setsrealm.sign_in_methods, removes the work-account method there and resubmits. 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 #
Your AI assistant checks these requirements before starting.
- A connected, signed-in AI assistant (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 refusesentraandoidc.
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 from the declared Microsoft Entra tenant or company OpenID Connect issuer (Add work-account or Apple sign-in).
Choose whether visitors must sign in to reach your pages. That choice goes in audience. Choose separately who can create an app account. That choice goes in the realm's creation setting. An invited audience requires invitations even if creation is set to open.
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 |
The audience requires an invitation even with creation set to open |
| Only invited people, with a notice page of your own | public |
invited, set as step 2 describes |
invited and workforce usually require an end-user session. The platform's /__account/ paths, its own scheduled runs, and paths in session_free_paths need no end-user session. Without a session, GET and HEAD can read /.well-known/ documents that the realm's native client declarations enable.
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 another service's callback arrives without an end-user session. For either audience, list the callback path in session_free_paths, for example {"kind": "invited", "session_free_paths": ["/webhooks/stripe"]}. The router forwards requests on that path without requiring a session or checking who sent them. It still refuses an invalid bearer token if a caller sends one. Check the provider's signature in the callback route itself and refuse a request without a valid signature.
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". Call tzcloud_read_app_sign_in for the environment you want to verify and look for realm.effective_creation: "invited". realm.creation shows the saved setting and detail explains the audience rule. If you are checking both production and development, read each environment separately.
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" }
The invited audience refuses both work-account methods, entra and oidc. If the manifest lists either in realm.sign_in_methods, validation rejects it there. If the manifest omits that list and an existing realm offers either method, the submission returns declared_audience_contradicts_route. Ask the owner before removing a work-account method if the request leaves that decision open. Read the current methods and keep the ones the owner still wants. If the manifest sets realm.sign_in_methods, remove the work-account method there and resubmit. Otherwise, pass the complete list of methods to keep to tzcloud_configure_app_sign_in for each environment being changed.
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 #
For your first batch of invitations, use this checklist.
- Confirm which app and environment the group should use. Check that sign-up is invitation-only there.
- Collect one address per person. Include your own if you have never signed in to the app.
- Have your AI assistant give each returned link to the app owner. The owner sends it privately to the person named in the invitation. Turn Zero sends no email. Keep each invitation ID so you can check it later.
- Use
tzcloud_list_invitationsto check which links were redeemed. Usetzcloud_list_end_usersto check who has an app account.
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 while you have it, and record invitation.id so you can find or revoke the invitation later.
Your Turn Zero account gives you no end-user sign-in to the application. If you have not signed in before, ask your AI assistant 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 assistant 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.
The link opens the application's sign-in page without showing invitation details. A used or expired link can look the same. Opening the link does not use the invitation. It can create one new app user in the selected environment when the person signs in with a method that verifies the invited address.
A new invitation link uses the app’s sign-in hostname. For production, that is the custom domain once sign-in moves there. Links issued before the domain went live still point to the managed hostname, so send fresh invitations after the move. Links issued for the custom domain stop working when you detach it, so invite those people again.
Someone whose sign-in method is already linked to an app user can sign in without using the invitation. Under open sign-up, a new user can also sign in without it. tzcloud_list_invitations shows redeemed after the invitation was used to create a user. Manage end users explains how to check, revoke or replace a link.
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. An existing realm keeps its methods. A new realm stores Google, GitHub, email code, and passkey sign-in by default. The audience can narrow the list. Email codes require the platform's mail sender and code service, and passkeys require the email-code route.
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 assistant 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 assistant 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 #
With the invited audience, the tzcloud_submit_manifest response confirms the end-user realms. In the tzcloud_read_app_sign_in response for each environment you check, realm.effective_creation is "invited", realm.creation gives the saved setting, and detail explains the audience rule. With a public audience and invitation-only sign-up, realm.creation and realm.effective_creation both read "invited" for the environment you configured.
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. When someone uses the invitation to create an app user, tzcloud_list_end_users shows the new user and their sign-in route, and tzcloud_list_invitations shows redeemed. A sign-in to an existing app user can leave the invitation standing.
On the deployed hostname:
- a new user who verifies the invited address can use the invitation to sign up and reach the pages;
- under invitation-only sign-up, a new user without a usable invitation gets
unrecognized_invitationand no app user is created; - under the
invitedaudience, opening a protected page in a signed-out browser redirects to the sign-in page. An API request without a session to a protected path returns 401. - 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. | For a native app, accept the invitation in the browser before trying native sign-in again. Use the address on the invitation. If it is missing or no longer works, ask the realm owner for a fresh one. |
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 or oidc on an existing realm. |
If the manifest sets realm.sign_in_methods, remove the work-account method (entra or oidc) there. Otherwise, remove it with tzcloud_configure_app_sign_in. Then submit the manifest again. |
invited_realm_refuses_work_account |
409 | tzcloud_configure_app_sign_in combined invitation-only creation with entra or oidc. |
Leave both work-account methods 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.