Examples of SCIM operations
We can use the SCIM operations to search, create, modify, or delete users and groups in various scenarios.
Example 1
To get a list of all users, send the following request:
GET /users
Example 2
The following example shows how to get a list of all users but include only the displayName and id attributes. It also limits the result to the users from numbers 11 - 20.
Request:
GET /users?attributes=displayName,id&count=10&startIndex=11Results:
{ "schemas": [ "urn:scim:schemas:core:1.0" ] , "Resources": [ { "id":"7b401115-35f2-4a74-8384-a684cb4f31a1", "displayName":"Alexander Shelton" } , { "id":"44216fbe-36a1-4215-b6f7-032775bc5e07", "displayName":"Andy Walker" } , { "id":"c5292b7e-ffeb-4855-a086-7289d3445bd6", "displayName":"Alan White" } , { "id":"5ad2d53c-9844-48ca-8460-c0d80fec5972", "displayName":"Alan Worrell" } , { "id":"2b62e6a0-a698-4ffb-a107-1078b2d56437", "displayName":"Barbara Francis" } , { "id":"3904d440-3f54-46cf-b63a-aacab03ac767", "displayName":"Bjorn Free" } , { "id":"abb9526e-dfa8-452a-9d88-9eff3d79da90", "displayName":"Barbara Hall" } , { "id":"d7df93df-d0bd-4c60-ad52-ec2bf8917fbc", "displayName":"Benjamin Hall" } , { "id":"f98c9470-d7fe-490f-ab71-e84c9d3e9448", "displayName":"Barbara Jablonski" } , { "id":"87fd1385-7d13-4423-851a-fb1d047bc2f0", "displayName":"Bjorn Jensen" } ] , "totalResults":"163", "startIndex":"11", "itemsPerPage":"10" }
Example 3
The following example gets a list of all users where the familyName starts with k.
Request:
GET /users?filter=name.familyName sw “k”Results:
{ "schemas": [ "urn:scim:schemas:core:1.0" ] , "Resources": [ { "id":"6f0fa17b-d988-4f95-98c0-095a545cc44e", "externalID":"aknutson", "meta": { "created":"2013-04-16T09:14:02Z", "modified":"2013-04-16T09:14:02Z" } , "userName":"uid=aknutson,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Ashley Knutson", "name": { "givenName":"Ashley", "familyName":"Knutson" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 2169" } , { "type":"fax", "value":"+1 408 555 4774" } ] , "emails": [ { "type":"work", "value":"aknutson@example.com" } ] } , { "id":"6f7a3e28-db6c-4846-ae78-2346f39f65ee", "externalID":"ekohler", "meta": { "created":"2013-04-16T09:14:02Z", "modified":"2013-04-16T09:14:02Z" } , "userName":"uid=ekohler,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Elba Kohler", "name": { "givenName":"Elba", "familyName":"Kohler" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 1926" } , { "type":"fax", "value":"+1 408 555 9332" } ] , "emails": [ { "type":"work", "value":"ekohler@example.com" } ] } , { "id":"e5318e13-1534-4eb9-9237-e1367a2744e1", "externalID":"skellehe", "meta": { "created":"2013-04-16T09:14:02Z", "modified":"2013-04-16T09:14:02Z" } , "userName":"uid=skellehe,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Sue Kelleher", "name": { "givenName":"Sue", "familyName":"Kelleher" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 3480" } , { "type":"fax", "value":"+1 408 555 8721" } ] , "emails": [ { "type":"work", "value":"skellehe@example.com" } ] } , { "id":"3bac3d16-33ee-4a39-a6d1-063c5537530a", "externalID":"tkelly", "meta": { "created":"2013-04-16T09:14:02Z", "modified":"2013-04-16T09:14:02Z" } , "userName":"uid=tkelly,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Timothy Kelly", "name": { "givenName":"Timothy", "familyName":"Kelly" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 4295" } , { "type":"fax", "value":"+1 408 555 1992" } ] , "emails": [ { "type":"work", "value":"tkelly@example.com" } ] } ] , "totalResults":"4" }
Example 4
The following example shows how to search for the user with the id 2064f364-260b-4c29-8c28-b12583486ca3.
Request:
GET /users/2064f364-260b-4c29-8c28-b12583486ca3Results:
{ "id":"2064f364-260b-4c29-8c28-b12583486ca3", "externalID":"abergin", "meta": { "created":"2013-04-16T09:14:02Z", "modified":"2013-04-16T09:14:02Z" } , "userName":"uid=abergin,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Andy Bergin", "name": { "givenName":"Andy", "familyName":"Bergin" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 8585" } , { "type":"fax", "value":"+1 408 555 7472" } ] , "emails": [ { "type":"work", "value":"abergin@example.com" } ] , "groups": [ { "value":"57a96228-48a6-4f29-a8ad-345828fccd6a", "display":"QA Managers" } ] , "schemas": [ "urn:scim:schemas:core:1.0" ] }
Example 5
The following example shows how to get a list of all users created after a specified date.
Request:
GET /users?filter=meta.created gt “2013-05-17T00:00:00Z”Results:
{ "schemas": [ "urn:scim:schemas:core:1.0" ] , "Resources": [ { "id":"78a13de7-0ef9-42ae-ba7c-b9c64a2050aa", "externalID":"wlutz2", "meta": { "created":"2013-05-21T11:39:48Z", "modified":"2013-05-21T11:53:30Z" } , "userName":"uid=wlutz2,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Wendy Lutz", "name": { "givenName":"Wendy", "familyName":"Lutz" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 3358" } , { "type":"fax", "value":"+1 408 555 9332" } ] , "emails": [ { "type":"work", "value":"wlutz@example.com" } ] } , { "id":"a4cc7512-1530-4adc-952b-cd752aa79828", "externalID":"wlutz4", "meta": { "created":"2013-05-21T11:54:12Z", "modified":"2013-05-21T11:54:12Z" } , "userName":"uid=wlutz4,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Wendy Lutz", "name": { "givenName":"Wendy", "familyName":"Lutz" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 3358" } , { "type":"fax", "value":"+1 408 555 9332" } ] , "emails": [ { "type":"work", "value":"wlutz@example.com" } ] } , { "id":"9be8c033-cf93-448e-a96b-d1290ff6d445", "externalID":"abergin2", "meta": { "created":"2013-05-24T11:29:51Z", "modified":"2013-05-24T11:51:09Z" } , "userName":"uid=abergin2,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Andy Bergin Jr", "name": { "givenName":"Andy", "familyName":"Bergin" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 8585" } , { "type":"fax", "value":"+1 408 555 7472" } ] , "emails": [ { "type":"work", "value":"abergin@example.com" } ] } ] , "totalResults":"3" }
Example 6
To create a user, send the following request:
POST /usersThe body must contain information about the new user in JSON format as shown in the following example:
{ "externalID":"abergin2", "displayName":"Andy Bergin", "name": { "givenName":"Andy", "familyName":"Bergin" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 8585" } , { "type":"fax", "value":"+1 408 555 7472" } ] , "emails": [ { "type":"work", "value":"abergin@example.com" } ] }Results:
200 OK { "id":"9be8c033-cf93-448e-a96b-d1290ff6d445", "externalID":"abergin2", "meta": { "created":"2013-05-24T11:29:51Z", "modified":"2013-05-24T11:51:09Z" } , "userName":"uid=abergin2,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Andy Bergin", "name": { "givenName":"Andy", "familyName":"Bergin" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 8585" } , { "type":"fax", "value":"+1 408 555 7472" } ] , "emails": [ { "type":"work", "value":"abergin@example.com" } ] , "schemas": [ "urn:scim:schemas:core:1.0" ] }
Example 7
The following example shows how to modify a user. It changes only the displayName of the user that was created in the previous example with id b9be8c033-cf93-448e-a96b-d1290ff6d445.
Request:
PATCH /users/b9be8c033-cf93-448e-a96b-d1290ff6d445The HTTP body must contain the following information:
{ "displayName":"Andy Bergin Jr" }Results:
{ "id":"9be8c033-cf93-448e-a96b-d1290ff6d445", "externalID":"abergin2", "meta": { "created":"2013-05-24T11:29:51Z", "modified":"2013-05-24T11:51:09Z" } , "userName":"uid=abergin2,ou=People,DC=EXAMPLE,DC=COM", "displayName":"Andy Bergin Jr", "name": { "givenName":"Andy", "familyName":"Bergin" } , "phoneNumbers": [ { "type":"work", "value":"+1 408 555 8585" } , { "type":"fax", "value":"+1 408 555 7472" } ] , "emails": [ { "type":"work", "value":"abergin@example.com" } ] , "schemas": [ "urn:scim:schemas:core:1.0" ] }Note: To test the operations with a browser that does not have a PATCH command, we can set the value of the HTTP header X-HTTP-Method-Override to PATCH. We can also use this setting to work around firewalls that block certain HTTP methods.
Example 8
The following example shows how to delete the user with id 2064f364-260b-4c29-8c28-b12583486ca3.
Request:
DELETE /users/2064f364-260b-4c29-8c28-b12583486ca3Results:
200 OK
Example 9
To get a list of all groups, use the following request:
GET /groups
Example 10
The following example shows how to search for a specific group by its id.
Request:
GET /groups/5653c887-1d5a-42cf-a470-6a2fe2608730Results:
{ "id":"5653c887-1d5a-42cf-a470-6a2fe2608730", "externalID":"Accounting Managers", "meta": { "created":"2013-04-16T09:10:45Z", "modified":"2013-04-16T09:10:45Z" } , "displayName":"Accounting Managers", "members": [ { "value":"71e064d4-3791-4ac8-b7c6-62686ce710cd", "display":"Sam Carter" } , { "value":"6ba0ff5b-98b4-41c8-be28-331b99d94bde", "display":"Ted Morris" } ] , "schemas": [ "urn:scim:schemas:core:1.0" ] }
Example 11
The following example shows how to search for a group by its displayName.
Request:
GET /groups?filter=displayName eq “Accounting Managers”Results:
{ "id":"5653c887-1d5a-42cf-a470-6a2fe2608730", "externalID":"Accounting Managers", "meta": { "created":"2013-04-16T09:10:45Z", "modified":"2013-04-16T09:10:45Z" } , "displayName":"Accounting Managers", "members": [ { "value":"71e064d4-3791-4ac8-b7c6-62686ce710cd", "display":"Sam Carter" } , { "value":"6ba0ff5b-98b4-41c8-be28-331b99d94bde", "display":"Ted Morris" } ] , "schemas": [ "urn:scim:schemas:core:1.0" ] }
Example 12
The following example shows how to create a group.
Request:
POST /groupsThe body must contain the information about the new group:
{ "externalID":"Test Group", "displayName":"Test Group", "members": [ "5156d423-3c74-415b-844f-606a2aabafcc", "900faa78-d7c6-421c-9181-313134d17dd0" ] }Results:
201 Created { "id":"7e15ce9e-2fe7-4624-b5d5-adedc242e07a", "externalID":"Test Group", "meta": { "created":"2013-05-27T02:37:38Z", "modified":"2013-05-27T02:37:38Z" } , "displayName":"Test Group", "members": [ { "value":"5156d423-3c74-415b-844f-606a2aabafcc", "display":"Kirsten Vaughan" } , { "value":"900faa78-d7c6-421c-9181-313134d17dd0", "display":"Robert Daugherty" } ] , "schemas": [ "urn:scim:schemas:core:1.0" ] }
Parent topic:
SCIM object model