Users
Note:
- Please, check out our SCIM API Reference pages for details on all SCIM API endpoints.
- Before sending API requests, ensure you have completed the steps in Get started with SCIM.
Step 1. Obtain the necessary information
Headers | |
accept |
Indicates the types of content the client can accept. I.e. application/scim+json |
authorization |
You will only be able to use Oneflow's SCIM API with a valid SCIM API token. You can create a SCIM API token in the Oneflow web application. See Authentication to learn more. |
content-type |
Indicates the type of data that the client sends to the server. I.e. application/json |
Path parameters | |
USER_ID |
The unique ID of the user inside Oneflow. You can find the user ID using the users endpoint. |
Query parameters
|
|
sortBy
|
Indicates which field the list of users will be sorted by. I.e. displayName |
sortOrder
|
Determines the order in which the list of users will be sorted. I.e. ascending, descending
|
startIndex
|
Indicates the starting position in the list as a number. I.e. 1 |
count
|
Indicates the total number of records returned in the response. I.e. 100 |
Body | |
active |
The status of the user account within Oneflow. |
displayName (required) |
The name of the user. |
externalID |
The unique ID of the group in your identity provider or application. |
id |
The unique ID of the group inside Oneflow.
|
title
|
Contains the user's job title. |
username (required)
|
The unique username of the user. I.e. [email protected] |
locale
|
The selected language for the account indicated as a locale identifier. I.e. "en" for English, "sv" for Swedish |
schema |
A schema represents the user configuration. The schema used varies depending on the request type.
For PATCH requests:
|
phoneNumbers | |
primary
|
Indicates whether the phone number is set as primary or not. I.e. true or false |
type
|
Indicates the type of phone number. I.e. work, home |
value |
Contains the user's phone number.
|
groups | |
$ref |
Reference to the URI of the group the user belongs to.
|
type |
Indicates the type of resource. I.e. a group |
value |
Contains the Oneflow group ID. |
meta | |
created |
Indicates when the user was created in the system. |
lastModified |
Indicates when the user's information was last changed. |
location |
Indicates the location of the user as a URI. |
resourceType
|
Indicates the resource type. I.e. a user |
Step 2. Run the code
Create user
- To create a user, send a POST request to the Users endpoint with the SCIM API token in the request’s header.
- Pass the user's attributes (i.e. username) to the relevant SCIM attribute of the request.
Note:
- The
displayName
, anduserName
attributes are mandatory.
curl --request POST \
--url https://api.oneflow.com/scim/v1/Users \
--header 'accept: application/scim+json' \
--header 'authorization: Bearer [TOKEN]' \
--header 'content-type: application/json' \
--data '
{
"active": true,
"meta": {
"resourceType": "User"
},
"displayName": "Jane Doe",
"userName": "[email protected]",
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
]
}
'
import requests
url = "https://api.oneflow.com/scim/v1/Users"
payload = {
"active": True,
"meta": { "resourceType": "User" },
"displayName": "Jane Doe",
"userName": "[email protected]",
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"]
}
headers = {
"accept": "application/scim+json",
"content-type": "application/json",
"authorization": "Bearer [TOKEN]"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
- Refer to the Data model for the complete list of SCIM attributes in Oneflow.
Get user
- To get the attributes of a specific user, send a GET request to the Users endpoint along with their ID as a path parameter.
- I.e. In the following example, replace
[User_ID]
with the Oneflow user's ID.
- I.e. In the following example, replace
curl --request GET \
--url https://api.oneflow.com/scim/v1/Users/[USER_ID] \
--header 'accept: application/scim+json' \
--header 'authorization: Bearer [TOKEN]'
import requests
url = 'https://api.oneflow.com/scim/v1/Users/[USER_ID]'
headers = {
'accept': 'application/scim+json',
'authorization': 'Bearer [token]'
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.text)
Patch user (deactivate)
- Note that users cannot be permanently or physically deleted from the database.
- A soft delete operation is achieved by sending a PATCH request to the Users endpoint to set the
active
attribute tofalse
. - This effectively deactivates the user on Oneflow, however will not delete their data.
curl --request PATCH \
--url 'https://api.oneflow.com/scim/v1/Users/[USER_ID]' \
--header 'accept: application/scim+json' \
--header 'authorization: Bearer [TOKEN]' \
--header 'content-type: application/json' \
--data '{
"Operations": [
{
"op": "replace",
"path": "active",
"value": "false"
}
],
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:PatchOp"
]
}'
import requests
url = "https://api.oneflow.com/scim/v1/Users/[USER_ID]"
payload = {
"Operations": [
{
"op": "replace",
"path": "active",
"value": "false"
}
],
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
}
headers = {
"accept": "application/scim+json",
"content-type": "application/json",
"authorization": "Bearer [TOKEN]"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)
Update user
Note
Sending a PUT request will overwrite the entire record. if some fields are omitted from the request, then these will be saved as null.
To avoid data loss, send a GET request first and use this response as the base for the PUT request, or send a PATCH request to partially modify a user record.
- You can update an existing user by sending a PUT request to the Users endpoint.
- To modify one or more attributes (partially update) of a user, send a PATCH request to the Users endpoint.
- Include the operation in the
op
parameter (add
,remove
, orreplace
), the attribute you wish to modify in thepath
parameter, along with its newvalue
.
curl --request PATCH \
--url https://api.oneflow.com/scim/v1/Users/[USER_ID] \
--header 'accept: application/scim+json' \
--header 'authorization: Bearer [TOKEN] ' \
--header 'content-type: application/json' \
--data '{
"Operations": [
{
"op": "replace",
"path": "displayName",
"value": "J Doe"
}
],
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:PatchOp"
]
}'
import requests
url = 'https://api.oneflow.com/scim/v1/Users/[USER_ID]'
headers = {
'accept': 'application/scim+json',
'authorization': 'Bearer [TOKEN]'
}
data = {
'Operations': [
{
'op': 'replace',
'path': 'displayName',
'value': 'J Doe'
}
]
],
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
}
response = requests.patch(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
Example response
{
"active": true,
"displayName": "Jane Doe",
"externalId": null,
"groups": [
{
"$ref": "https://api.oneflow.com/scim/v1/Groups/227732",
"type": "Group",
"value": "227732"
}
],
"id": "998749",
"locale": "en",
"meta": {
"created": "2023-07-14T05:10:41+00:00",
"lastModified": "2023-08-25T07:29:54+00:00",
"location": "https://api.oneflow.com/scim/v1/Users/998749",
"resourceType": "User"
},
"phoneNumbers": [
{
"primary": true,
"type": "work",
"value": null
}
],
"roles": [],
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"title": null,
"userName": "[email protected]"
}
List users
- You can retrieve the list of users in your Oneflow account along with their attributes.
- To sort or filter the list of users, use the query parameters specified in the API reference.
- For instance, to list all users, send a GET request to the Users endpoint with the SCIM API token in the request’s header.
curl --request GET \
--url 'https://api.oneflow.com/scim/v1/Users?sortBy=displayName&sortOrder=ascending&startIndex=1&count=100' \
--header 'accept: application/scim+json' \
--header 'authorization: Bearer [TOKEN]'
import requests
url = 'https://api.oneflow.com/scim/v1/Users?sortBy=displayName&sortOrder=ascending&startIndex=1&count=100'
headers = {
'accept': 'application/scim+json',
'authorization': 'Bearer [TOKEN]'
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.text)
Example response
{
"Resources": [
{
"active": true,
"displayName": "Jane Doe",
"externalId": null,
"groups": [],
"id": "975828",
"locale": "en",
"meta": {
"created": "2022-12-02T07:52:16+00:00",
"lastModified": "2022-12-02T07:52:16+00:00",
"location": "https://api.oneflow.com/scim/v1/Users/975828",
"resourceType": "User"
},
"phoneNumbers": [
{
"primary": true,
"type": "work",
"value": null
}
],
"roles": [],
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"title": "Sales Manager",
"userName": "[email protected]"
},
{
"active": true,
"displayName": "John Doe",
"externalId": null,
"groups": [],
"id": "972592",
"locale": "en",
"meta": {
"created": "2022-10-28T06:21:54+00:00",
"lastModified": "2022-10-28T06:21:54+00:00",
"location": "https://api.oneflow.com/scim/v1/Users/972592",
"resourceType": "User"
},
"phoneNumbers": [
{
"primary": true,
"type": "work",
"value": null
}
],
"roles": [],
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"title": "Marketing Manager",
"userName": "[email protected]"
},
{
"active": true,
"displayName": "Oliver Queen",
"externalId": null,
"groups": [],
"id": "972597",
"locale": "en",
"meta": {
"created": "2022-10-28T06:21:54+00:00",
"lastModified": "2022-10-28T06:21:55+00:00",
"location": "https://api.oneflow.com/scim/v1/Users/972597",
"resourceType": "User"
},
"phoneNumbers": [
{
"primary": true,
"type": "work",
"value": null
}
],
"roles": [],
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"title": "Software Engineer",
"userName": "[email protected]"
}
],
"itemsPerPage": 3,
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:ListResponse"
],
"startIndex": 1,
"totalResults": 100
}
Response codes
Status | Meaning | Description |
---|---|---|
200 | OK | Operation completed successfully. |
201 | Created | Returns the created/updated user, optionally filtered by values in attributes or excludedAttributes parameters. |
204 | No content | The group was deleted successfully. |
400 | Bad Request | Invalid format or content of the request. |
401 | Unauthorized | The SCIM token is invalid. |
404 | Not found | The requested entity is missing. |
409 | Conflict | A conflict occurred with the current state of the target resource. |
See Handling errors with error codes for reasons and resolutions.
Updated over 1 year ago