Skip to main content

SCIM Provisioning

This guide covers provisioning Bandwidth users and groups from an identity provider (IdP) using SCIM 2.0 (RFC 7643, RFC 7644).

note

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.

  1. Open SSO Management.
  2. 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.

POSThttps://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>
note

Access tokens expire. When using a static header token, replace it in your IdP before it expires.

Endpoints​

ResourceEndpoints
UsersGET /Users, POST /Users, GET /Users/{id}, PUT /Users/{id}, PATCH /Users/{id}, DELETE /Users/{id}
GroupsGET /Groups, GET /Groups/{groupId}, PUT /Groups/{groupId}, PATCH /Groups/{groupId}
DiscoveryGET /ServiceProviderConfig, GET /ResourceTypes, GET /ResourceTypes/{id}, GET /Schemas, GET /Schemas/{id}

Attribute Mapping​

SCIMBandwidthNotes
idOpaque and server-generated. Cannot be set by the client.
userNameuserIdRequired and unique. Cannot be changed after creation.
name.givenNamefirstName
name.familyNamelastName
emails[primary]emailOnly the primary entry is used.
phoneNumbers[primary]phoneNumberOptional. Only the primary entry is used.
activestatustrue is ACTIVE. false is DEPROVISIONED.
groupsrolesRead-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.

note

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.

note

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.

PATCHhttps://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 name as 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 by GET /Groups (filtered on displayName), and POST /Groups returns 501.
  • The role id is the Group id. Use it in the {groupId} path.

Groups​

A Group is a Bandwidth role. Granting group membership grants the role to the user.

  • id is the role ID and displayName is the role name. Neither can be changed.
  • members is returned only with ?attributes=members, except as noted for writes.
  • basicAccess is a normal group.
  • Deprovisioned users are never group members.
PATCHhttps://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.

PUThttps://api.bandwidth.com/api/scim/v2/Groups/{groupId}

PUT replaces the membership and returns 200. schemas and displayName are required.

caution

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.

GEThttps://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​

EndpointSupported filter
GET /UsersuserName eq "<value>"
GET /GroupsdisplayName 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).

scimTypeStatusMeaning
invalidFilter400Unsupported or malformed filter.
invalidSyntax400Malformed request body.
invalidValue400A required value is missing or invalid.
invalidPath400Unsupported path in a PATCH operation.
noTarget400A remove operation has no path.
mutability400Attempt to change an immutable attribute.
uniqueness409The 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: false is returned for suspended and deprovisioned users. Sending active: false always deprovisions, and active: true always sets the user to ACTIVE. SCIM cannot suspend a user.
  • PUT preserves omitted optional fields. Omitting phoneNumbers keeps 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 with active: false instead.
  • emails and phoneNumbers hold one value. add behaves like replace, and remove returns 400 invalidValue.
  • remove on active, name.givenName, or name.familyName returns 400 invalidValue.
  • userName cannot be changed. Any PATCH on it returns 400 invalidPath.
  • Value-filter paths are not supported on users. Paths like emails[type eq "work"].value return 400 invalidPath.
  • Deprovisioning keeps roles. A deprovisioned user keeps their roles, and active: true reactivates 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. PUT with "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 4xx means nothing was changed. A 500 partway through can leave some members updated.
  • members echo differs by method. PATCH always returns members. PUT returns 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 returns 400 invalidValue. Omitting one causes no error.
  • Removing basicAccess from a user whose only role is basicAccess returns 400 invalidValue.

Not Supported​

  • POST /Groups and DELETE /Groups/{groupId}, GET /Me, POST /Bulk, and POST /.search return 501.
  • Sorting, ETags, changePassword, and schema extensions are not supported.
  • The $ref sub-attribute on group members and User.groups is never returned.