# Manage Mediafly User Identities with SCIM You can provision and manage your Mediafly user identities across systems with the open standard System for Cross-Domain Identity Management (SCIM). The Mediafly implementation provides extensions to the SCIM 2.0 specification so that you can edit and manage Mediafly user properties using REST API operations. For more information about SCIM, see the [SCIM 2.0 Specification](http://www.simplecloud.info/#Specification.html). ## Example User While this example contains the core user attributes, you can configure Mediafly to support additional attributes to meet your business needs. ``` { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id":"005RM000002FZAlYAO", "externalId":"dschrute", "userName":"dschrute@example.com", "name":{ "familyName":"Schrute", "givenName":"Dwight" }, "emails":[ { "type":"work", "primary":true, "value":"dschrute@example.com" } ], "active":true, "meta":{ "created":"2020-10-19T10:11:52Z", "lastModified":"2020-10-19T10:11:52Z", "resourceType":"User" } } ``` ## Example Group While this example contains the core group attributes, you can configure Mediafly to support additional attributes to meet your business needs. ``` { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:Group" ], "id":"e9e30dba-f08f-4109-8486-d5c6a331660a", "displayName":"Sales Reps", "members":[ { "value":"2819c223-7f76-453a-919d-413861904646", "display":"Dwight Schrute" }, { "value":"902c246b-6245-4190-8e05-00816be7344a", "display":"Jim Halpert" } ], "meta":{ "resourceType":"Group", "created":"2010-01-23T04:56:22Z", "lastModified":"2011-05-13T04:42:34Z" } } ``` ## Operations For manipulation of resources, SCIM provides a REST API with a rich but simple set of operations: - Create: POST https://scim.mediafly.com/{companycode}/scim/v2/{resource} - Read: GET https://scim.mediafly.com/{companycode}/scim/v2/{id} - Replace: PUT https://scim.mediafly.com/{companycode}/scim/v2/{id} - Delete: DELETE https://scim.mediafly.com/{companycode}/scim/v2/{id} - Update: PATCH https://scim.mediafly.com/{companycode}/scim/v2/{id} - Search: GET https://scim.mediafly.com/{companycode}/scim/v2/{resource}?filter={attribute}{op}{value}&sortBy={attributeName}&sortOrder={ascending|descending} ## Search Resources Fetch users or groups with the option to filter, sort and page results. Query string parameters: - filter: expression to filter results - format: `{attribute} {op} {value}` - ex: `userName eq "dschrute@example.com"` - Mediafly only supports a subset of filter expressions that the SCIM spec defines. - startIndex: 1-based index of the first query result. - count: Specifies the desired maximim number of query results per page. - sortBy: Attribute to sort results by - sortOrder: Either ascending or descending ### Examples - Find user by userName - `/{companycode}/scim/v2/Users?filter=userName eq "dschrute@example.com"` - Sort by userName - `/{companycode}/scim/v2/Users?sortBy=userName&sortOrder=ascending` - Fetch first 100 users - `/{companycode}/scim/v2/Users?startIndex=1&count=100` - Fetch next 100 users - `/{companycode}/scim/v2/Users?startIndex=101&count=100` - Find group by displayName - `/{companycode}/scim/v2/Groups?filter=displayName eq "Sales"` Request ``` GET https://scim.mediafly.com/{companycode}/scim/v2/Users?startIndex=1&count=100 ``` Response ``` HTTP/1.1 200 OK { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:ListResponse" ], "totalResults":2, "startIndex":1, "itemsPerPage":2, "Resources":[ { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id":"005RM000002FZAlYAO", "externalId":"dschrute", "userName":"dschrute@example.com", "name":{ "familyName":"Schrute", "givenName":"Dwight" }, "emails":[ { "type":"work", "primary":true, "value":"dschrute@example.com" } ], "active":true, "meta":{ "created":"2020-10-19T10:11:52Z", "lastModified":"2020-10-19T10:11:52Z", "resourceType":"User" } }, { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id":"005RM000002FZAlYAO", "externalId":"jhalpert", "userName":"jhalpert@example.com", "name":{ "familyName":"Halpert", "givenName":"Jim " }, "emails":[ { "type":"work", "primary":true, "value":"jhalpert@example.com" } ], "active":true, "meta":{ "created":"2020-10-19T10:11:52Z", "lastModified":"2020-10-19T10:11:52Z", "resourceType":"User" } } ] } ``` ## Get Resource Get user or group by id Get User Request ``` GET https://scim.mediafly.com/{companycode}/scim/v2/Users/005RM000002FZAlYAO ``` Response ``` HTTP/1.1 200 OK { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id":"005RM000002FZAlYAO", "externalId":"dschrute", "userName":"dschrute@example.com", "name":{ "familyName":"Schrute", "givenName":"Dwight" }, "emails":[ { "type":"work", "primary":true, "value":"dschrute@example.com" } ], "active":true, "meta":{ "created":"2020-10-19T10:11:52Z", "lastModified":"2020-10-19T10:11:52Z", "resourceType":"User" } } ``` Get Group Request ``` GET https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a ``` Response ``` { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:Group" ], "id":"e9e30dba-f08f-4109-8486-d5c6a331660a", "displayName":"Sales Reps", "members":[ { "value":"2819c223-7f76-453a-919d-413861904646", "display":"Dwight Schrute" }, { "value":"902c246b-6245-4190-8e05-00816be7344a", "display":"Jim Halpert" } ], "meta":{ "resourceType":"Group", "created":"2010-01-23T04:56:22Z", "lastModified":"2011-05-13T04:42:34Z" } } ``` ## Create User To create a user object with SCIM, send a POST request to the Users endpoint. Does not support adding users to groups. Request: ``` POST https://scim.mediafly.com/{companycode}/scim/v2/Users/ { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "externalId":"dschrute", "userName":"dschrute@example.com", "name":{ "familyName":"Schrute", "givenName":"Dwight" }, "emails":[ { "type":"work", "primary":"true", "value":"dschrute@example.com" } ] } ``` Response ``` HTTP/1.1 201 Created { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id":"005RM000002FZAlYAO", "externalId":"dschrute", "userName":"dschrute@example.com", "name":{ "familyName":"Schrute", "givenName":"Dwight" }, "emails":[ { "type":"work", "primary":true, "value":"dschrute@example.com" } ], "active":true, "meta":{ "created":"2020-10-19T10:11:52Z", "lastModified":"2020-10-19T10:11:52Z", "resourceType":"User" } } ``` ## Update User Update the attributes of a user by either replacing the user object or updating individual attributes. ### Replace User Object Use PUT to replace the entire user object. Does not support modifying group memberships. ``` PUT https://scim.mediafly.com/{companycode}/scim/v2/Users/005RM000002FZAlYAO { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id":"005RM000002FZAlYAO", "externalId":"dschrute", "userName":"dschrute@example.com", "name":{ "familyName":"Schrute", "givenName":"Dwight" }, "emails":[ { "type":"work", "primary":"true", "value":"dschrute@example.com" } ], "active": true } ``` ### Deactivate User Use PATCH to set `active` to `false` to deactivate user. PUT also supports deactivating user. ``` PATCH https://scim.mediafly.com/{companycode}/scim/v2/Users/005RM000002FZAlYAO { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"replace", "value":{ "active":false } } ] } ``` ### Activate user Use PATCH to set `active` to `true` to activate user. PUT also supports activating user. ``` PATCH https://scim.mediafly.com/{companycode}/scim/v2/Users/005RM000002FZAlYAO { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"replace", "value":{ "active":true } } ] } ``` ## Delete User This will hard delete the User from Mediafly. We recommend deactivating user instead of deleting in most use cases. ``` DELETE https://scim.mediafly.com/{companycode}/scim/v2/Users/005RM000002FZAlYAO ``` ## Create Group To create a group object with SCIM, send a POST request to the Groups endpoint. Does support adding users to group. Request: ``` POST https://scim.mediafly.com/{companycode}/scim/v2/Groups/ { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:Group" ], "displayName":"Sales Reps", "members":[ { "value":"2819c223-7f76-453a-919d-413861904646", "display":"Dwight Schrute" }, { "value":"902c246b-6245-4190-8e05-00816be7344a", "display":"Jim Halpert" } ] } ``` Response ``` HTTP/1.1 201 Created { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:Group" ], "id":"e9e30dba-f08f-4109-8486-d5c6a331660a", "displayName":"Sales Reps", "members":[ { "value":"2819c223-7f76-453a-919d-413861904646", "display":"Dwight Schrute" }, { "value":"902c246b-6245-4190-8e05-00816be7344a", "display":"Jim Halpert" } ], "meta":{ "resourceType":"Group", "created":"2010-01-23T04:56:22Z", "lastModified":"2011-05-13T04:42:34Z" } } ``` ## Update Group Update the attributes of a group by either replacing the group object or updating individual attributes. ### Replace Group Object Use PUT to replace the entire group object. This will also replace the group memberships. ``` PUT https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a { "schemas":[ "urn:ietf:params:scim:schemas:core:2.0:Group" ], "id":"e9e30dba-f08f-4109-8486-d5c6a331660a", "displayName":"Sales Reps", "members":[ { "value":"2819c223-7f76-453a-919d-413861904646", "display":"Dwight Schrute" }, { "value":"902c246b-6245-4190-8e05-00816be7344a", "display":"Jim Halpert" } ] } ``` ### Update Group Display Name ``` PATCH https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"replace", "value":{ "displayName":"Sales 2.0" } } ] } ``` ### Add User(s) To Group ``` PATCH https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"add", "path":"members", "value":[{ "value": "e6b8fc82f6a84102ae4a8cf3c0dc6503", "displayName": "Pam Beesly" }] } ] } ``` ### Remove User(s) From Group ``` PATCH https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"remove", "path":"members[value eq \"e6b8fc82f6a84102ae4a8cf3c0dc6503\""]" } ] } ``` ### Set Group Users This operation replaces all the group members with the supplied object values. ``` PATCH https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"replace", "path":"members", "value":[ { "value":"2819c223-7f76-453a-919d-413861904646", "display":"Dwight Schrute" }, { "value":"902c246b-6245-4190-8e05-00816be7344a", "display":"Jim Halpert" } ] } ] } ``` ## Delete Group This will hard delete the Group from Mediafly. ``` DELETE https://scim.mediafly.com/{companycode}/scim/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a ``` ## Authentication All API calls require authentication. Include the Mediafly Access Token in the Authorization header ``` Authorization: Bearer {Access Token} ``` You will also need your Mediafly `Company Code` as a path parameter. Contact Mediafly on how to obtain an Access Token and Company Code. ## X-HTTP-Method-Override When a client is limited to sending GET or POST methods but wants to invoke other HTTP methods, a client can set request header `X-HTTP-Method-Override` to specify the intended HTTP method. Example: Client sending a user patch request with a POST method and setting `X-HTTP-Method-Override` to `PATCH`. The SCIM API will treat this request as if it were HTTP method PATCH. ``` POST https://scim.mediafly.com/{companycode}/scim/v2/Users/005RM000002FZAlYAO X-HTTP-Method-Override: PATCH { "schemas":[ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations":[ { "op":"replace", "value":{ "active":false } } ] } ```