Before you start
- Your organization is on the Enterprise plan; see Plans. See Authentication for the keys each operation accepts, including workspace API tokens for Enterprise SSO workspaces, and Conventions for base URLs, pagination, errors, and rate limits.
- The key owner has the access the task needs: the Admin role to manage seats, set the seat assignment mode, add users, and read audit logs; the
user_management:readpermission to list users; anduser_management:writeto change roles. See Role-based access. - The curl examples read the key from
CODERABBIT_API_KEY. The CLI examples use thecoderabbit apicommand with a key file.
Which credential does what
In an SSO workspace, a workspace token covers every task that the API offers. For the general rules, see Which key for which job.
List users
-
Call List all users in the organization. To find who has a seat or a role, filter by seat status or by role.
-
Read the response.
seats_purchasedandseats_assigneddescribe the subscription, andseat_assignment_modeshows whether seats are assigned automatically or manually. For each user,user_idis the Git providerâs user ID, which the seat and role operations expect, androleis the userâs role ID. -
While
next_cursorisnâtnull, request the next page withcursorset to that value and the same filters. See Pagination.
membership=non_org to list outside contributors, such as authors of pull requests on public repositories, or membership=all to list both.
With a workspace token and no org_id, the response has one row per person across the workspace, with each personâs linked Git accounts. Add org_id to list a single organization of the workspace.
Assign or unassign seats in bulk
-
Collect the Git provider user IDs from
user_idin the user list. -
Call Assign or unassign seats for multiple users with the
actionto take and the usersâ IDs inuser_ids.The CLI reads the body from the file you pass with--inputand sends aPOST. -
Check the result. A
200response can still report failures for some users.statusissuccess,partial_success, orfailure,succeededlists the processed IDs, and eachfailedentry has acode, such asSEAT_NOT_AVAILABLEwhen no seat is free.
Workspace tokens and offboarding
A workspace token sends amembers array keyed by email, or by cr_user_id for a member without an email. Manage seats and identities shows the body.
A workspace token sets one seat per person for the whole workspace, not one per organization. CodeRabbit keeps the seat on the workspace member and applies it to every linked Git account, so one call changes the seat in all of the workspaceâs organizations. A Git account that isnât linked to a member keeps its own seat; find it in the workspace user list and send its cr_user_id.
To take a seat from a leaver, send "seat_assigned": false for the member. This works in Automatic mode too: the Automatic and Manual modes control who gets a seat when a pull request opens, and donât block an unassignment through the API. In Automatic mode, the person gets a seat again when one of their linked Git accounts opens a new pull request, as long as a seat is free.
If your identity provider provisions members through SCIM, remove the person there instead. SCIM deprovisioning removes the member, their linked Git identities, and their seat. See SCIM.
Set the seat assignment mode
Inautomatic mode, a person gets a seat when they open a new pull request, as long as a seat is available. In manual mode, admins assign seats. Seat assignment describes both modes, including when CodeRabbit releases inactive seats.
The API changes the mode only for organizations on self-hosted CodeRabbit or on a self-managed Git provider. Other organizations get 403 SELF_HOSTED_ONLY and change the mode in the app: an organization admin in Team Management, and an Enterprise SSO workspace admin in Workspace Team Management, as described in Enterprise SSO workspaces.
-
Read the current mode from
seat_assignment_modein the user list. -
Call Update the seat assignment mode with
modeset toautomaticormanual.
400.
Seat new joiners before their first pull request
In an Enterprise SSO workspace, Automatic mode assigns a seat only when someone opens a pull request. To give a new joiner a seat earlier, for example when your HR system adds them, call Assign or unassign seats for multiple users with a workspace token and send their email with"seat_assigned": true in members. CodeRabbit creates the workspace member when the email is new. To link their Git account in the same request, add it in identities. Manage seats and identities shows the body.
Change roles
-
Pick the role ID:
cr_adminfor Admin,cr_memberfor Member, or a custom roleâs UUID. On GitHub Cloud, List organization roles returns every role ID. It is a product operation, so a workspace token must select the organization. On other platforms, read therolefield of a user who already has the custom role in the user list. The API canât assign Billing Admin (cr_billing_admin) or change the role of a Billing Admin. -
Call Change roles for multiple users with
roleand up to 500 Git provider user IDs inuser_ids. A workspace token also needsorg_id, theprovider_organization_idthat List organizations returns.With a workspace token, add the organization inorg_id: -
Check
status,succeeded, andfailed, as for seats. ACANNOT_CHANGE_BILLING_ADMIN_ROLEfailure marks a Billing Admin.
Change a role on every organization of a self-hosted instance
With a self-hosted instance key, setorg_id to ALL, in any case, to apply the change to every active organization on the instance, or to one organizationâs ID to change only that organization.
CodeRabbit writes each organization separately, so an ALL change isnât atomic. A user is listed in succeeded only when the change succeeded in every organization. If any organization failed, the user is listed in failed with the first error code; send the request again for those users. Other key types that send ALL get 400 INVALID_REQUEST.
Create and edit custom roles
The custom role operations are product operations, so they work for GitHub Cloud organizations; check which keys they accept. Use a workspace token with one of the workspaceâs GitHub Cloud organizations selected, or a user key from one of them. A user keyâs owner needs the Role Management permission in that organization:role_management:read to list and read roles, role_management:write to create and update them, and role_management:delete to delete them. The built-in Admin role has all three. Billing Admin has only read and canât create API keys. A workspace admin who needs this key creates it in an organization where they hold the Admin role.
Every organization in a workspace shares the same custom roles. In a workspace with several organizations, such as an Enterprise SSO workspace, create a role once with a key from any of its GitHub Cloud organizations, and the role is available in all of them. You still assign it per organization.
- Call List supported role permissions to get the
resource_idsandaccess_types(read,write,delete) a role can hold. - Call Create a custom role with
name, an optionaldescription, and an optionalduplicate_from, the ID of the role to copy. This operation doesnât accept permissions. The response returns the new role with its ID inrole. - Call Update a custom role with the roleâs complete
nameand its fullpermissionslist, each entry with aresource_idand anaccess_type. The list replaces all of the roleâs permissions. - Assign the role to users with Change roles, once for each organization where they need it.
Add users to a self-hosted organization
This operation works only for organizations on self-hosted CodeRabbit or on a self-managed Git provider.- Call Add users and assign seats for a self-hosted organization with up to 500 entries in
users, each with the Git provideruser_idanduser_name, and optionallyemailandname. - Check
status,succeeded, andfailedfor each user.
user_id is processed once, using its first entry. SSO workspaces canât use this operation and get 400 SSO_WORKSPACE_UNSUPPORTED; use workspace seat management instead.
Read audit logs
-
Call List audit log entries, filtered by actor, action, resource type, or date range. Write
date_fromanddate_toas UTC timestamps that end inZ: a date without a time, or a time with an offset such as+02:00, returns400. -
Read
datafor the entries andfilter_optionsfor the values you can filter by. Each entryâscreatedAtis a UTC timestamp. -
While
pagination.has_next_pageistrue, increasepageby one and repeat the request.page_sizeaccepts up to 100.
format, return 400. To hand the log to a tool that expects CSV, collect every page and convert the entries.
With a workspace token, omit org_id to read every organization in the workspace together with workspace-level events. For what CodeRabbit logs, see Audit Logs.
Handle errors
For response formats and other codes, see Errors and Rate limits.
Whatâs next
SSO user management API
Manage workspace members, seats, and linked Git identities with a workspace API token.
Seat assignment
Learn how automatic and manual seat assignment work and when seats are released.
Custom roles and permissions
Decide which permissions each custom role grants before you script role changes.