Skip to content

Public access requests ​

When self-registration for your app is closed, a prospective customer asks for access instead of signing up. TenancyEnginePublicClient wraps the three public endpoints of that flow. No API key is ever sent, so the client is safe to use from a public-facing backend.

Requires TenancyEngine.Sdk 2.3.0 for GetAccessStateAsync, ValidateAccessGrantAsync and SubmitAccessRequestAsync. The optional TurnstileToken on PublicAccessRequest is in the source (2.12.0) and not yet released: until it is on nuget.org, send the Turnstile token from the browser straight to the platform (see Bot check).

This flow does not sign anyone in. It collects a request, lets the platform's team approve it, and hands the person a single-use link to sign up. Sign-in is a separate step: see Customer sign-in from a .NET app.

Set up the client ​

csharp
using TenancyEngine.Sdk;

var http = new HttpClient { BaseAddress = new Uri("https://api.saasruntime.com") };
var publicClient = new TenancyEnginePublicClient(http);

The base address is the TenancyEngine API origin for your lane (production shown). Take it from the same configuration key you use for the rest of the SDK.

Which sites accept requests ​

siteSlug is your application slug. The platform resolves it only when the application exists, is Active and is not a system application (AccessRequestService.ResolveSiteAsync). Anything else is a 404, which the client reports as null from GetAccessStateAsync and as a validation error from the other calls.

Closed switch ​

csharp
PublicAccessState? state = await publicClient.GetAccessStateAsync("your-app-slug");
// state is null for an unknown or inactive site
// state.SignupOpen == true  : show your normal sign-up
// state.SignupOpen == false : show the request-access form

For a registered application, SignupOpen is the application's self-registration switch (the application's Self registration panel in the console). A closed switch means requests are stored for review. It never creates an account.

Submit a request ​

csharp
await publicClient.SubmitAccessRequestAsync(
    "your-app-slug",
    new PublicAccessRequest(Name: "Ada Lovelace", Email: "[email protected]", Company: "Analytical Ltd", Note: "We run 40 locations."));
FieldRule
NameRequired.
EmailRequired, a valid work address.
CompanyRequired.
NoteOptional, at most 2000 characters.
WebsiteHoneypot. Leave it null. A filled value is accepted silently and discarded.

The platform answers 202 with a message. One live request is kept per person per product: a repeat submit is acknowledged, not duplicated, and sends no second email.

ResultException from the clientError code
202none
429TenancyEngineRateLimitedException (honours Retry-After)too_many_requests
400 / 404TenancyEngineValidationException (message is the platform's own wording)invalid_name, invalid_company, invalid_note, invalid_email, reserved_company, site_not_found, bot_check_failed
503TenancyEngineApiExceptionbot_check_unavailable

The extra fields (country, region, intended use and so on) in the platform endpoint apply to the TenancyEngine platform sites only. A registered application uses the short form above.

Bot check ​

The request endpoint is protected by Cloudflare Turnstile. In production the check is mandatory: the platform refuses with 503 bot_check_unavailable when it has no check configured, and with 400 bot_check_failed when the token is missing or rejected.

Your server cannot solve a Turnstile challenge. Render the Turnstile widget in your own page, receive the token in the browser, send it to your backend, and pass it through unchanged:

csharp
// TenancyEngine.Sdk 2.12.0 or later (not yet released)
new PublicAccessRequest("Ada Lovelace", "[email protected]", "Analytical Ltd") { TurnstileToken = tokenFromYourPage }

The property is left out of the request body when null. Until 2.12.0 is on nuget.org, have the browser post the form to POST /api/v1/public/access/{siteSlug}/requests directly with turnstileToken in the JSON body (the endpoint allows cross-origin calls from any origin). A server-side call without a token fails the bot check in production.

When the team approves a request, the platform emails the person a signup link that carries a single-use token. The token is stored hashed, bound to the approved email address, and expires. An invitation that expired unused, or a decline older than the platform's resubmission window, lets the person submit again.

Your sign-up page validates the token before showing the form:

csharp
bool valid = await publicClient.ValidateAccessGrantAsync("your-app-slug", tokenFromQueryString);

ValidateAccessGrantAsync returns true only when the platform says the token is currently valid. The underlying endpoint (GET /api/v1/public/access/{siteSlug}/grant?token=) also returns the approved email so a page can lock the address field. The released client returns only the boolean; read the email from that endpoint yourself if you need it.

Approval is done by people with the access-requests permission through the admin API or console (POST /api/v1/admin/access-requests/{id}/approve), not through the public client.

TenancyEngine platform documentation