Use this API to create a new Group.
This API only sets the Group’s
name,policy_id, andreference. It does not add member users or admins — Group membership is managed on the User resource, not through this API.
Resource URL
https://<subdomain>.onelogin.com/api/2/groupsHeader Parameters
Authorization required string | Set to Set The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using any one of the following scopes: |
Content-Type required string | Set to application/json. |
Request Parameters
name required string | The name of the Group. Must be unique within the account. |
policy_id integer | Optional. ID of a Security Policy on the same account to assign to this Group. |
reference string | Optional. An external reference/identifier for the Group. Must be unique within the account. This value is write-only and is never returned in the API response. |
Sample Responses
- 201 Created
- 401 Unauthorized
- 422 Unprocessable Entity
{
"id": 123,
"name": "Sample Group",
"policy": {
"id": 7765,
"name": "Sample Policy"
},
"admins": [],
"users": []
}Typically, this error means that your access token value is invalid.
{
"message": "Unauthorized",
"statusCode": 401,
"name": "UnauthorizedError"
}Indicates that the syntax of the request is good but a value supplied is not valid, e.g. name is blank/already taken, or policy_id does not reference an existing Policy on the account.
{
"message": "Validation failed: Name has already been taken",
"statusCode": 422,
"name": "UnprocessableEntityError"
}Postman Collection
- Clicking Run in Postman button navigates to the page where you can fork the collection to your workspace. Forking the collection into your workspace will enable you to contribute to the source collection using pull requests. You can also view the collection in a public workspace if you like and even import a copy of the collection using the links present on the screen.
Sample Code
cURL
Replace sample values indicated by < > with your actual values.
Create Group
curl 'https://<subdomain>.onelogin.com/api/2/groups' \
-X POST \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"name":"<group name>",
"policy_id": <policy_id>
}'Have a Question?
Found a problem or a bug? Submit a support ticket.
Looking for walkthroughs or how-to guides? Check out our Knowledge Base.
Have a product idea or request? Share it in our Ideas Portal.