Users API Routes

A user is an admin user that can authenticate and perform functionalities as an admin user.

An admin user can invite other users to join their team. Once they accept the invite, they'll become admin users as well.

These API routes allow admin users to manage their team.

GET /admin/users#

List Users

Retrieve a list of users. The users can be filtered by fields such as id. The users can also be sorted or paginated.

Authentication: cookie session, JWT bearer token.

Query parameters

fieldsstringOptional
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.
offsetnumberOptional
The number of items to skip when retrieving a list.
limitnumberOptional
Limit the number of items returned in the list.
orderstringOptional
The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with -.
qstringOptional
The search term to filter the user's searchable properties.
idstring | string[]Optional
Filter by a user's ID.
emailstringOptional
Filter by an email.
first_namestringOptional
Filter by a first name.
last_namestringOptional
Filter by a last name.
created_atobjectOptional
Filter by a user's creation date. Accepts the filter operators.
updated_atobjectOptional
Filter by a user's update date. Accepts the filter operators.
deleted_atobjectOptional
Filter by a user's deletion date. Accepts the filter operators.
with_deletedbooleanOptional
Whether to include deleted records in the result.

Request examples

Responses

200 OK

limitnumber
The maximum number of items returned.
offsetnumber
The number of items skipped before retrieving the returned items.
countnumber
The total number of items.
usersobject[]
The list of users.
estimate_countnumberOptional
The estimated count retrieved from the PostgreSQL query planner, which may be inaccurate.

400, 401, 404, 409, 422, 500: an error response is returned.


GET /admin/users/me#

Get Logged-In User

Retrieve the logged-in user's details.

Authentication: cookie session, JWT bearer token.

Query parameters

fieldsstringOptional
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.

Request examples

Responses

200 OK

userobject
The user's details.

400, 401, 404, 409, 422, 500: an error response is returned.


POST /admin/users/me#

Update Logged-In User

Update the logged-in user's details. Unlike the Update a User API route, this API route doesn't require the user:update permission, so any user can update their own details.

Authentication: cookie session, JWT bearer token.

Request body (application/json)

first_namestringOptional
The user's first name.
last_namestringOptional
The user's last name.
avatar_urlstringOptional
The URL of the user's avatar.
metadataobjectOptional
The user's metadata, can hold custom key-value pairs. Learn more in the Manage Metadata section.

Request examples

Responses

200 OK

userobject
The user's details.

400, 401, 404, 409, 422, 500: an error response is returned.

Emitted events

  • user.updated: Emitted when users are updated.

GET /admin/users/{id}#

Get a User

Retrieve a user by its ID. You can expand the user's relations or select the fields that should be returned.

Authentication: cookie session, JWT bearer token.

Path parameters

idstring
The user's ID.

Query parameters

fieldsstringOptional
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.

Request examples

Responses

200 OK

userobject
The user's details.

400, 401, 404, 409, 422, 500: an error response is returned.


POST /admin/users/{id}#

Update a User

Update a user's details.

Authentication: cookie session, JWT bearer token.

Path parameters

idstring
The user's ID.

Query parameters

fieldsstringOptional
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.

Request body (application/json)

first_namestringOptional
The user's first name.
last_namestringOptional
The user's last name.
avatar_urlstringOptional
The URL of the user's avatar.
metadataobjectOptional
The user's metadata, can hold custom key-value pairs. Learn more in the Manage Metadata section.

Request examples

Responses

200 OK

userobject
The user's details.

400, 401, 404, 409, 422, 500: an error response is returned.

Emitted events

  • user.updated: Emitted when users are updated.

DELETE /admin/users/{id}#

Delete a User

Delete a user.

Authentication: cookie session, JWT bearer token.

Path parameters

idstring
The user's ID.

Request examples

Responses

200 OK

idstring
The user's ID.
objectstring
The name of the deleted object.

Default: "user"

deletedboolean
Whether the user was deleted.

400, 401, 404, 409, 422, 500: an error response is returned.

Emitted events

  • user.deleted: Emitted when users are deleted.

GET /admin/users/{id}/auth-providers#

List Auth Providers of a User

Retrieve a list of auth providers that a user can authenticate with. These represent the auth providers that the user has previously used to log in or register with the system.

Authentication: cookie session, JWT bearer token.

Path parameters

idstring
The user's ID.

Request examples

Responses

200 OK

providersstring[]
The IDs of the auth providers the user can authenticate with, such as emailpass.

400, 401, 404, 409, 422, 500: an error response is returned.


POST /admin/users/{id}/reset-password#

Generate Reset Password Token for a User

Generate a reset password token for a user. This is useful if another user wants to reset the password of a user. The reset password token can be used to reset the user's password. This route only emits the auth.password_reset event. You can listen to this event to send a reset password email to the user, for example.

Authentication: cookie session, JWT bearer token.

Path parameters

idstring
The user's ID.

Request examples

Responses

200 OK

tokenstring
The generated reset password token. Append it to the admin's /reset-password page as a token query parameter to build a link the user can open to set a new password. The token is short-lived, can only be used once, and generating it invalidates any reset password token previously issued for the user.

400, 401, 404, 409, 422, 500: an error response is returned.

Emitted events

  • auth.password_reset: Emitted when a reset password token is generated. You can listen to this event to send a reset password email to the user or customer, for example.
Found a problem with this page?Report Issue
Edited Nov 14·Edit this page