User role assignments


User role assignments

The users role assignments endpoint implements functions to create, read, and delete the role assignments associated with user resources.

Role assignments are defined by the role itself, and at a more granular level by the scope attribute associated with the role assignment. The role assignment scope identifies the type of platform resource that defines the scope, and the id of the specific resource to which the scope applies. The following sample shows the scope attribute, which includes the resource type and id attributes. In this case, the scope is restricted to the environment resource identified by its id.

{
  "scope": {
   "id": "d928aa51-c194-4333-9cf5-0fd0c9b7d62f",
   "type": "ENVIRONMENT"
   }
}

Role assignment scope types include:

  • Organization

    This scope type designates an organization resource as the assignment scope of the role.

  • Environment

    This scope designates an environment resource as the assignment scope of the role.

  • Population

    This scope designates a population resource as the assignment scope of the role.

User role assignments API operations

The user role assignments endpoints support the following operations:

For hands-on experience with the users API endpoints, click the Run in Postman button below to download a Postman collection that you can import and open in your local Postman application.

Users role assignments data model

Property Description
environment.id A string that specifies the environment associated with the user.
id A string that specifies the user role assignment ID.
readOnly A boolean that specifies whether this role assignment can be deleted by the current actor.
role.id A string that specifies the role ID.
scope.id A string that specifies the role assignment scope ID.
scope.type A string that specifies the type of resource defining the scope of the Role assignment. Options are ORGANIZATION, ENVIRONMENT, and POPULATION.

Response codes

Code Message
200 Successful operation.
201 Successfully created.
204 Successfully removed. No content.
400 The request could not be completed.
401 You do not have access to this resource.
404 The requested resource was not found.

Endpoint examples

Create user role assignments

You can manage the roles assigned to specific users. When you assign a role to a user, you provide the attribute values required to identify the role and designate the role assignment scope for this user.

The following sample shows the POST /environments/{environmentId}/users/{userId}/roleAssignments operation to create the role assignment for the user in the specified environment resource.

curl -X POST "https://api.pingone.com/v1/environments/{environmentId}/users/{userId}/roleAssignments" \
-H "Content-type: application/json" \
-H "Authorization: Bearer jwtToken" \
-d "{
    "role": {
        "id": "{roleID}"
    },
    "scope": {
        "id": "{envID}",
        "type": "ENVIRONMENT"
    }
}"

The request URL identifies the environment ID and user ID. The request body specifies the role ID and the scope attribute values. The scope attribute provides the resource ID and resource type to designate the role assignment scope associated with this actor. In this sample, the scope type is ENVIRONMENT and the specific environment to which the role assignment scope applies is specified in the id value.

The response data looks like this.

{
    "_links": {
        "self": {
            "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772/roleAssignments/d9b890bc-e8a8-4fd4-8650-a39c046fe5aa"
        },
        "user": {
            "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772"
        },
        "environment": {
            "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006"
        }
    },
    "id": "d9b890bc-e8a8-4fd4-8650-a39c046fe5aa",
    "scope": {
        "id": "88c23def-39c9-4646-8d41-aa91a14a1006",
        "type": "ENVIRONMENT"
    },
    "role": {
        "id": "0bd9c966-7664-4ac1-b059-0ff9293908e2"
    },
    "environment": {
        "id": "88c23def-39c9-4646-8d41-aa91a14a1006"
    },
    "readOnly": false,
    "user": {
        "id": "8ce55f02-2077-4493-9a6d-0385df1f0772"
    }
}

For more information about role assignment scopes, see Roles.

Get user role assignments

Users in PingOne can be assigned one or more roles. You can view the roles assigned to a specific user, and you can view the role assignment scopes that define the limitations of each role.

The GET /environments/{environmentId}/users/{userId}/roleAssignments operation returns the list of roles assigned to the user identified by the user’s ID.

curl -X GET "https://api.pingone.com/v1/environments/{environmentId}/users/{userId}/roleAssignments" \
-H "Authorization: Bearer jwtToken"

The request URL identifies the environment ID and the user’s ID. The response data for a user with more than one role looks like this.

{
    "_links": {
        "self": {
            "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772/roleAssignments"
        },
        "user": {
            "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772"
        },
        "environment": {
            "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006"
        }
    },
    "_embedded": {
        "roleAssignments": [
            {
                "_links": {
                    "self": {
                        "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772/roleAssignments/d9b890bc-e8a8-4fd4-8650-a39c046fe5aa"
                    },
                    "user": {
                        "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772"
                    },
                    "environment": {
                        "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006"
                    }
                },
                "id": "d9b890bc-e8a8-4fd4-8650-a39c046fe5aa",
                "scope": {
                    "id": "88c23def-39c9-4646-8d41-aa91a14a1006",
                    "type": "ENVIRONMENT"
                },
                "role": {
                    "id": "0bd9c966-7664-4ac1-b059-0ff9293908e2"
                },
                "environment": {
                    "id": "88c23def-39c9-4646-8d41-aa91a14a1006"
                },
                "readOnly": false,
                "user": {
                    "id": "8ce55f02-2077-4493-9a6d-0385df1f0772"
                }
            },
            {
                "_links": {
                    "self": {
                        "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772/roleAssignments/6559dcf2-a355-4662-9ea8-4562c8e143a7"
                    },
                    "user": {
                        "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006/users/8ce55f02-2077-4493-9a6d-0385df1f0772"
                    },
                    "environment": {
                        "href": "https://api.pingone.com/v1/environments/88c23def-39c9-4646-8d41-aa91a14a1006"
                    }
                },
                "id": "6559dcf2-a355-4662-9ea8-4562c8e143a7",
                "scope": {
                    "id": "88c23def-39c9-4646-8d41-aa91a14a1006",
                    "type": "ENVIRONMENT"
                },
                "role": {
                    "id": "b5057d0d-7281-47f6-9398-8a7e4cb71397"
                },
                "environment": {
                    "id": "88c23def-39c9-4646-8d41-aa91a14a1006"
                },
                "readOnly": false,
                "user": {
                    "id": "8ce55f02-2077-4493-9a6d-0385df1f0772"
                }
            }
        ]
    },
    "count": 2,
    "size": 2
}

Get one user role assignment

The GET /environments/{environmentId}/users/{userId}/roleAssignments/{roleAssignmentId} operation returns the specific role assignment assigned to the user identified by the user’s ID.

curl -X GET "https://api.pingone.com/v1/environments/{environmentId}/users/{userId}/roleAssignments/{roleAssignmentId}" \
-H "Authorization: Bearer jwtToken"

Delete role assignments

The following sample shows the DELETE /environments/{environmentId}/users/{userId}/roleAssignments/{roleAssignmentId} operation to delete the role assignment specified by its ID in the request URL. The role assignment is deleted only for the actor identified in the request URL.

curl -X DELETE "https://api.pingone.com/v1/environments/{environmentId}/users/{userId}/roleAssignments/{roleAssignmentId}" \
-H "Authorization: Bearer jwtToken" \

When successful, the DELETE request returns a code 204 No Content message.