Create Consumer Role
Endpoint
POST /apiops/projects/{projectName}/consumer-roles
Authentication
Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
Request Body
{
"name": "API_USER",
"oauthScope": "api.read"
}
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Name of the role. A missing or blank name answers 400 malformedRequest |
| oauthScope | string | No | OAuth scope name that the role answers to |
Response
201 Created with a Location header (/apiops/projects/{projectName}/consumer-roles/{roleName}).
The response is a write response. result is the role. runtimeDeployment.state is IN_SYNC when every environment acknowledged the change, or DEGRADED when the change is stored but at least one environment did not acknowledge it. Do not retry a DEGRADED write; redeploy instead. resourceVersion is not returned.
Errors
| Status | Error key | Cause |
|---|---|---|
| 400 | malformedRequest | The name is missing, or the OAuth scope name is invalid or already used. params.field names the field and params.reason the cause |
| 409 | duplicateName | Another role of the project or of the admin project holds the name, ignoring case |
cURL Example
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/consumer-roles" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "API_USER", "oauthScope": "api.read" }'
Permissions
- User must have
IDENTITY+MANAGEpermission in the project - A project outside the scope of the caller answers
404 resourceNotFound, never403 - The admin project is served: a call on
/apiops/projects/admin/consumer-rolesaddresses the roles of the admin project