# Organizations, memberships and invitations

A membership joins one end user to one organization of the same environment, with a role slug and a state (`active`, `pending` or `inactive`).

## Memberships

- `POST /v1/organizations/{org}/memberships` adds a user.
- `GET /v1/organizations/{org}/memberships` lists them.
- `PATCH /v1/organizations/{org}/memberships/{membership}` changes the role or state.
- `DELETE /v1/organizations/{org}/memberships/{membership}` removes the user from the organization.

The role works with [authorization](/authorization/): it becomes the `role` claim, and role assignments add more roles and permissions.

## Invitations

`POST /v1/invites` emails an invitation, to an organization or to the environment. An invitation lasts 7 days and works once; `POST /v1/invites/{invite}/revoke` cancels it. An invalid, used or expired one answers [`invite_invalid`](/errors/invite_invalid/). The answer to accepting an invitation does not reveal whether the address already had an account.

## Organization switcher

When a user belongs to several organizations, the hosted login asks which one to use. Your app can also pass `organization_id` on the authorize request; the hosted pages then apply that organization's sign-in method rules. The [SDKs](/sdks/) offer a `switchOrganization` call that runs the hosted login again; a live hosted session completes it without asking for credentials.

## Blocking a user

Set a user's state to `blocked` with `PATCH /v1/users/{user}`. A blocked user cannot sign in ([`user_blocked`](/errors/user_blocked/)).
