Overview
Administer an organization over REST — clients, pages, domains, tenants, members, webhooks.
Everything the console does, it does through the /organizations routes
documented in this tab, one page per endpoint. Hosts, the OAuth endpoints and
discovery are in the Client API.
Who can call it
Every route here takes a user access token, Authorization: Bearer …. The
token is checked against the keys of the org whose host the request arrives
on, so the host and the token have to match. There are two ways in:
| Token | Send it to | Org it can manage |
|---|---|---|
Console token: issued to a console-class client of LoginWith’s own org (the console itself, or a client you register with POST /oauth/register there) | https://loginwith.loginwith.dev | Any org you are a member of |
| Org token: an ordinary token issued to a client of your org | https://acme.loginwith.dev | acme only |
The {org} in the path has to name an org the token can manage: any org you
are a member of with a console token, the host’s org with an org token. Any
other org, whether it exists or not, gets 404 not_found.
With a console token you don’t need to switch orgs to manage one:
GET /organizations lists them,
and you name the one you want in the path.
The examples in this tab use a console token on https://loginwith.loginwith.dev.
Roles
Being let in is not enough on its own. Your role in the org decides what you can do:
| Action | Needs |
|---|---|
| Reading clients, pages, kits, tenants, members, webhooks, email settings | Org member |
| Creating, changing or deleting anything, impersonating | Org owner (403 forbidden otherwise) |
| Reading the event log | Org owner (404 otherwise) |
| Adding, editing or removing tenant members | Org owner, or owner / admin of that tenant |
| Listing or removing a tenant member’s MFA factors | Org member |
| Sending yourself a test email | Org member |
Each endpoint page states its own rule under Authorization.
Conventions
- Ids carry a prefix:
org_,cli_,pge_,kit_,dom_,tnt_,usr_,lbl_,whk_,mfa_. An id with the wrong prefix in a path is a404, the same as an id that does not exist. {org}accepts either form:org_…is read as an id, anything else as a slug.- Bodies are JSON. An unknown key is
400 invalid_request, and so is a value that fails validation. The error names the first bad field. - PATCH: the body is the mask. The keys you send are the fields that
change, and keys you leave out stay as they are. There is no
?mask=parameter. An empty body is400(“nothing to change”). Only the fields an endpoint page marks clearable can be cleared. - Errors come back as
{ "error": "…", "error_detail": "…" }, whereerroris a stable code (invalid_request,forbidden,not_found,conflict, …) anderror_detailsays what went wrong in words. A request with no usable token is a401. - Lists are not paginated, and return a plain JSON array. The exception is the event log.
- Deletes answer
204with no body. Deleting something still in use is a409 conflictthat says what is using it. - Secrets are shown once. A client secret or webhook secret appears only in the response that creates it.
# The orgs this console token can manage
curl https://loginwith.loginwith.dev/organizations \
-H "Authorization: Bearer $TOKEN"
# Create a confidential client in acme
curl -X POST https://loginwith.loginwith.dev/organizations/acme/clients \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Acme backend","confidential":true,"redirect_uris":["https://app.acme.com/lgw/callback"]}'
Resources
| Resource | What it is |
|---|---|
| Organizations | The orgs you can manage |
| Clients | The applications that sign people in |
| Pages | Hosted login pages, {slug}.loginwith.page |
| Kits | Brand kits: the branding a page or an email wears |
| Domains | Custom domains for pages |
| Emails | Which kit each transactional email wears |
| Tenants | The groups your users sign in to |
| Tenant members | Who is in a tenant, and their role |
| Member MFA | A tenant member’s second factors |
| Labels | Named groups inside a tenant |
| Org members | Who administers the org |
| Webhooks | Endpoints LoginWith POSTs events to |
| Events | The org’s audit log |
| Impersonation | Sign in as one of your users |