Skip to main content
Version: 26.2

Projects and users

Use these endpoints to manage projects, their members, and the users and machine-to-machine clients that can be added to them.

None of these endpoints use the X-Project-Id header.

Projects​

MethodPathDescriptionRequired role
POST/api/projectsCreate a project.Admin or Tenant admin
GET/api/projectsList projects.Any
GET/api/projects/{id}Get a project.Any
PATCH/api/projects/{projectId}Update a project's name, description, or members.Tenant admin or Project admin
POST/api/projects/{id}/leaveRemove the caller from the project.Member
GET/api/projects/{id}/user/roleGet the caller's role in the project.Any

Tenant admins see every project. Other callers only see the projects they are a member of, and a project they are not a member of is reported as 404.

Project roles​

Project members are assigned one of the following roles. The API uses the role names on the right.

Role in the interfaceAPI value
Domain viewerDOMAIN_VIEWER
Project viewerVIEWER
Project editorCOLLABORATOR
Project adminADMIN

Create a project​

curl -X POST "https://<authorization-hub-url>/api/projects" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Payments",
"description": "Policies for the payments platform",
"members": [
{ "userId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d", "role": "ADMIN" }
]
}'
FieldRequiredDescription
nameYes1 to 500 characters, without leading or trailing spaces. Must be unique.
descriptionNoUp to 4000 characters.
membersYesAt least one member. Each member needs a userId (the user's or client's Authorization Hub ID, as returned by /api/principal) and a role. A user can only be listed once.

The response is 201 with the project, including its id, which you use as the X-Project-Id header in all project requests. The project is created with the default attributes and the Default cache profile.

note

The user who creates a project is not added as a member automatically. Include them in members if they need access.

Update a project​

PATCH /api/projects/{projectId} accepts application/json with any of name, description, and members. Omitted fields are not changed. Each entry in members has a userId, an action (ADD, UPDATE, or REMOVE), and a role. The role is required for ADD and UPDATE.

{
"description": "Updated description",
"members": [
{ "userId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d", "action": "UPDATE", "role": "COLLABORATOR" },
{ "userId": "0e9d8c7b-6a5f-4e3d-8c2b-1a0f9e8d7c6b", "action": "REMOVE" }
]
}

A Tenant admin always has the Project admin role in the projects they are a member of. Assigning them another role is rejected.

Project errors​

StatuserrorCodeCause
400DUPLICATE_USERSThe same user is listed more than once.
400ROLE_REQUIREDAn ADD or UPDATE member has no role.
400MEMBER_MUST_EXISTA user in the request does not exist, or an UPDATE targets a user that is not a member.
403INSUFFICIENT_PERMISSIONSThe caller is a member but not a Project admin, or a user without the Admin or Tenant admin role tried to create a project.
404PROJECT_DOES_NOT_EXISTThe project does not exist, or the caller has no access to it.
409PROJECT_NAME_EXISTSA project with this name already exists.
409TENANT_ADMIN_MUST_BE_PROJECT_ADMINA Tenant admin was given a role other than ADMIN.

Users​

MethodPathDescriptionRequired role
GET/api/principal/usersList users.Any
GET/api/principal/users/currentGet the authenticated user.Any
GET/api/principal/users/emailGet a user by email address. Send the address in the User-Email header.Any
POST/api/principal/usersInvite users.Admin or Tenant admin
PATCH/api/principal/usersUpdate a user's name, roles, or status.Admin or Tenant admin
note

These endpoints are not part of the Swagger UI.

Invite users​

The request body is an array. Each user needs an email and at least one platform role: USER, USER_ADMIN (shown as Admin in the interface), or TENANT_ADMIN.

[
{ "email": "alex.smith@example.com", "roles": ["USER"] }
]

The response is 201 with an array that has one user response per invited user, and each user's status is INVITED. If an invitation email could not be sent, that user's entry also has an actionsRequired array with the code PWD_USER_INVITATION_EMAIL_FAILED or IDP_USER_INVITATION_EMAIL_FAILED. Follow up with the user manually in that case.

warning

Users are created one after the other. If one fails, no users are saved in Authorization Hub, but those already created in Keycloak remain. Invite one user per request if you need to retry individual failures.

Update a user​

Identify the user with id or email. If both are sent, id is used. Only the following fields can be changed:

FieldDescription
firstName, lastNameThe user's name.
rolesThe platform roles. At least one is required if sent.
statusINVITED, ACTIVATED, or DEACTIVATED. Deactivating a user signs them out. Setting a deactivated user to ACTIVATED or INVITED sends a new invitation and sets the status to INVITED.

The rules in Platform roles apply.

User response​

The user endpoints do not return the user directly. Each user is wrapped in an object with the user in user, and an actionsRequired array when a follow-up is needed. Endpoints that return several users return an array of these objects.

{
"user": {
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"firstName": "Alex",
"lastName": "Smith",
"email": "alex.smith@example.com",
"roles": ["USER"],
"status": "ACTIVATED"
}
}

The user object has the following fields:

FieldDescription
idThe user's Authorization Hub ID.
externalUserIdThe ID of the user in Keycloak. It is the sub claim in the user's tokens.
firstName, lastName, emailThe user's details.
rolesThe platform roles.
statusINVITED, ACTIVATED, or DEACTIVATED.
invitedOn, verifiedOn, lastLogin, deactivatedOnTimestamps.

User errors​

StatuserrorCodeCause
403INSUFFICIENT_PERMISSIONSA rule in Platform roles was violated.
404USER_NOT_FOUNDNo user matches the ID or email.
409DUPLICATE_USERA user with this email already exists.

Clients​

MethodPathDescription
GET/api/principal/clientsList the machine-to-machine clients that can be added to projects.

The list contains the clients defined in Keycloak, except the built-in clients that Authorization Hub needs to operate. Read Client management to create one. The call also synchronizes Authorization Hub with Keycloak, so newly created clients appear in the list, and clients that are deleted or disabled in Keycloak are shown as DEACTIVATED.

Each entry has an id, which is the value to use as userId when you add the client to a project, along with the clientId, name, description, and status.