SCIM Provisioning
This guide covers provisioning Bandwidth users and groups from an identity provider (IdP) using SCIM 2.0 (RFC 7643, RFC 7644).
SCIM provisioning is optional. To use these endpoints, enable SCIM for your account first; requests for an account without SCIM enabled return 400. Your credential must have ACCOUNT_ADMIN scope.
Base URL: https://api.bandwidth.com/api/scim/v2
Resource paths are case-sensitive: use /Users, not /users.
Enabling SCIM
SCIM is enabled per account, and the account must already have SSO configured.
- Open SSO Management.
- Find the account and turn on the SCIM toggle.
Authentication
SCIM uses OAuth 2.0 bearer tokens. Users and groups are limited to the accounts on the token. The discovery endpoints need no token.
Choose the credential carefully:
- Bind it to a single account. Users created or replaced through SCIM are assigned to every account on the token, so a credential with several accounts grants all of them.
- Give it every role you will manage through Groups. A group push for a role the credential does not hold returns
403.
OAuth 2.0 Client Credentials
This is the preferred method. Configure your IdP to request a token from the Bandwidth token endpoint with the client_credentials grant.
https://api.bandwidth.com/api/v1/oauth2/token
Send the client_id and client_secret of a credential with ACCOUNT_ADMIN scope. See the Authentication API Reference for details.
HTTP Header
If your IdP does not support the client credentials grant, mint a token yourself and configure the IdP to send it as an HTTP header on every request:
Authorization: Bearer <access_token>
Access tokens expire. When using a static header token, replace it in your IdP before it expires.
Endpoints
| Resource | Endpoints |
|---|---|
| Users | GET /Users, POST /Users, GET /Users/{id}, PUT /Users/{id}, PATCH /Users/{id}, DELETE /Users/{id} |
| Groups | GET /Groups, GET /Groups/{groupId}, PUT /Groups/{groupId}, PATCH /Groups/{groupId} |
| Discovery | GET /ServiceProviderConfig, GET /ResourceTypes, GET /ResourceTypes/{id}, GET /Schemas, GET /Schemas/{id} |
Attribute Mapping
| SCIM | Bandwidth | Notes |
|---|---|---|
id | Opaque and server-generated. Cannot be set by the client. | |
userName | userId | Required and unique. Cannot be changed after creation. |
name.givenName | firstName | |
name.familyName | lastName | |
emails[primary] | email | Only the primary entry is used. |
phoneNumbers[primary] | phoneNumber | Optional. Only the primary entry is used. |
active | status | true is ACTIVE. false is DEPROVISIONED. |
groups | roles | Read-only. Ignored if sent on PUT or PATCH. |
externalId is not used. There is no roles attribute: roles are managed only through Groups, and sending roles returns 400 invalidValue.
Use the user's email address as userName. GET /Users with userName eq "<value>" matches against the user's email, and if emails is omitted on create, userName is used as the email.
Creating a User
POSThttps://api.bandwidth.com/api/scim/v2/Users
Required: schemas, userName, and name. Accounts come from your token, not the request body. Returns 201 with the new id.
New users are created with basicAccess, which is required to sign in to the Bandwidth App. Grant any other role through a Group.
See the API Reference for request and response details.
Updating a User
PUThttps://api.bandwidth.com/api/scim/v2/Users/{id}
PUT replaces the user and returns 200. active is required. Echoing the current id is allowed. Any other id returns 400 with scimType mutability.
https://api.bandwidth.com/api/scim/v2/Users/{id}
PATCH supports add, replace, and remove on active, name.givenName, name.familyName, emails, and phoneNumbers. The body uses the PatchOp schema with an Operations array.
See the API Reference for request and response details.
Deprovisioning a User
Set active to false with PATCH or PUT. The user becomes DEPROVISIONED.
DELETE /Users/{id} always returns 403. It is not a deprovisioning path.
Finding Role Names
A Group is a Bandwidth role, so groups in your IdP must use the exact role names. List the roles to get them.
GEThttps://api.bandwidth.com/api/v1/roles
- Use
nameas the group name in your IdP. Groups map to existing roles only. SCIM cannot create new roles, so a group that matches no role is not found byGET /Groups(filtered ondisplayName), andPOST /Groupsreturns501. - The role
idis the Groupid. Use it in the{groupId}path.
Groups
A Group is a Bandwidth role. Granting group membership grants the role to the user.
idis the role ID anddisplayNameis the role name. Neither can be changed.membersis returned only with?attributes=members, except as noted for writes.basicAccessis a normal group.- Deprovisioned users are never group members.
https://api.bandwidth.com/api/scim/v2/Groups/{groupId}
add merges, replace overwrites, and remove revokes the listed members (or all members if none are listed). members[value eq "<id>"] is supported as a remove path. Each member is an object with the user's id as value.
https://api.bandwidth.com/api/scim/v2/Groups/{groupId}
PUT replaces the membership and returns 200. schemas and displayName are required.
Populate the IdP group before linking it. Most IdPs send PUT with the group's current membership when it is linked, and an empty list revokes the role from every current holder your credential can modify.
https://api.bandwidth.com/api/scim/v2/Groups/{groupId}?attributes=members
Returns the group with its members.
See the API Reference for request and response details.
Filtering and Pagination
| Endpoint | Supported filter |
|---|---|
GET /Users | userName eq "<value>" |
GET /Groups | displayName eq "<value>" |
Any other operator returns 400 with scimType invalidFilter. Use startIndex and count to page. count=0 returns totals only. attributes and excludedAttributes are supported.
Errors
Errors use the SCIM error envelope (urn:ietf:params:scim:api:messages:2.0:Error).
scimType | Status | Meaning |
|---|---|---|
invalidFilter | 400 | Unsupported or malformed filter. |
invalidSyntax | 400 | Malformed request body. |
invalidValue | 400 | A required value is missing or invalid. |
invalidPath | 400 | Unsupported path in a PATCH operation. |
noTarget | 400 | A remove operation has no path. |
mutability | 400 | Attempt to change an immutable attribute. |
uniqueness | 409 | The value is already in use. |
Other statuses: 401 unauthorized, 403 forbidden, 404 not found, 429 too many requests, 500 server error, 501 not implemented.
429 and 500 are retryable. A transient failure is never reported as a 4xx, so a 400 or 403 means the request itself needs to change.
Known Behavior
Users
active: falseis returned for suspended and deprovisioned users. Sendingactive: falsealways deprovisions, andactive: truealways sets the user toACTIVE. SCIM cannot suspend a user.PUTpreserves omitted optional fields. OmittingphoneNumberskeeps the current phone number. It does not clear it.- Every user needs at least one role. Revoking a user's last role through a Group returns
400 invalidValue. Deprovision withactive: falseinstead. emailsandphoneNumbershold one value.addbehaves likereplace, andremovereturns400 invalidValue.removeonactive,name.givenName, orname.familyNamereturns400 invalidValue.userNamecannot be changed. AnyPATCHon it returns400 invalidPath.- Value-filter paths are not supported on users. Paths like
emails[type eq "work"].valuereturn400 invalidPath. - Deprovisioning keeps roles. A deprovisioned user keeps their roles, and
active: truereactivates them with the same roles. Group changes made while the user was deprovisioned are not applied until the next group push.
Groups
- Empty membership revokes the role.
PUTwith"members": []clears the group, which revokes the role from every holder your credential can modify. IdPs commonly send this when a group is first linked, so populate the IdP group before linking it. - Writes are validated first. A
4xxmeans nothing was changed. A500partway through can leave some members updated. membersecho differs by method.PATCHalways returnsmembers.PUTreturns it only if the request included it. An empty membership is omitted from the response instead of returned as[].- Members must be visible to the caller. A user outside your token's accounts returns
400 invalidValue, the same as a user that does not exist. - Deprovisioned users are never group members. They are left out of
members, and naming one returns400 invalidValue. Omitting one causes no error. - Removing
basicAccessfrom a user whose only role isbasicAccessreturns400 invalidValue.
Not Supported
POST /GroupsandDELETE /Groups/{groupId},GET /Me,POST /Bulk, andPOST /.searchreturn501.- Sorting, ETags,
changePassword, and schema extensions are not supported. - The
$refsub-attribute on group members andUser.groupsis never returned.