Skip to content

Create users and invitations from your app

An application often onboards its own users: a customer’s administrator adds a colleague in your application, and that colleague should be able to sign in with your application’s roles. Your application can do this itself, calling the platform as its service account, without anyone opening the console.

POST /api/applications/{appCode}/users creates one user owned by your application:

  • a CLIENT user, homed at a client your application is enabled for (by client id or identifier);
  • holding at least one of your application’s roles (orders:clerk, or the short clerk); a role of another application is refused (403 ROLE_APP_FORBIDDEN), a name that is not a role is refused (400 UNKNOWN_ROLE);
  • with an invitation, sent the way you choose (below).

An email that already exists is refused (409 EMAIL_EXISTS). A user whose email domain signs in through an organisation’s identity provider is created without a password and never gets a set-password invitation: they sign in with their SSO.

Your service account’s built-in role allows this (user:create, user:view, invitation:view, invitation:manage, all confined to its own application). Mint a new token after the role gains permissions. Check your own user’s right to invite (an “invite users” permission in your application) before calling: the platform authorises your service account, not the person.

Pattern Request What happens
The platform emails (default) nothing extra The platform sends its “set your password” email. After setting a password the user lands on the platform’s landing page, or on inviteRedirectUri when you give one.
Your email, login-detected (recommended for your own branding) sendInvitation: false The platform sends nothing. You send your own welcome email linking to your application. When the user first signs in, the hosted login sees an account with no password yet, emails them a set-password link (proving they own the mailbox), and after they set it, returns them through the normal OAuth redirect to your application.
Your email, platform link returnInviteLink: true The response carries inviteLink, a live 72-hour set-password link, and the platform sends nothing. Put the link in your own email. Add inviteRedirectUri (any absolute http(s) URL, typically your application’s page that starts sign-in) to bring the user back to you afterwards.

The answer is 201 {id, inviteLink?, invitationSent}: invitationSent is true only when the platform emailed the invitation (false for a federated user, a returned link, or a delivery that failed, which is logged; resend it). A client that is unknown, not enabled for your application, or out of your reach is one answer: 403 “client is not available to this application”. At least one role is required (400 ROLES_REQUIRED).

returnInviteLink: true always suppresses the platform’s email, because each link can be minted only once: asking for it means you deliver it. Treat the link like a password: never log it, store it or put it in an audit record. A malformed inviteRedirectUri refuses the whole request (INVITE_REDIRECT_URI_INVALID) and creates nobody. If the second-factor policy of the user’s email domain requires it, enrolment happens before the redirect.

var users = client.applicationUsers();
users.invite("orders", new InviteApplicationUserRequest()
.email("ann@acme.test")
.name("Ann")
.clientId("acme") // id or identifier of an enabled client
.roles(List.of("orders:clerk"))
.sendInvitation(false)); // login-detected pattern
Call Route
List your users (CLIENT users at your enabled clients holding one of your roles) GET /api/applications/{appCode}/users
One user GET /api/applications/{appCode}/users/{id}
Pending and lapsed invitations (status PENDING or EXPIRED); never includes a link GET /api/applications/{appCode}/invitations
Resend: mints a fresh link, the earlier one stops working POST /api/applications/{appCode}/invitations/{id}/resend
Revoke: removes the link and deactivates the user DELETE /api/applications/{appCode}/invitations/{id}
var pending = users.invitations("orders", "PENDING", 0, 50);
users.resend("orders", userId, null); // a new link; the old one dies
users.revoke("orders", userId);

Another application’s code, users or invitations answer 404, the same as something that does not exist. A resend must deliver something: sendInvitation: false without returnInviteLink is refused (400 INVITATION_DELIVERY_REQUIRED). User lists filter by q, active, clientId and roles and page with page (from 0) and pageSize (default 50, at most 200).

Tools that act as a platform or client administrator (not as an application) create users with POST /api/principals/users, which takes the same sendInvitation, returnInviteLink and inviteRedirectUri flags: client.principals().createUser(...) in Java and TypeScript, FlowCatalyst::admin()->principals() in PHP, c.Principals().CreateUser in Go. It needs the administrator’s user-management permissions, which an application’s service account does not have.