Ana içeriğe geç

Create Consumer Role

Endpoint​

POST /apiops/projects/{projectName}/consumer-roles

Authentication​

Requires a Personal API Access Token.

Authorization: Bearer YOUR_TOKEN

Request​

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name

Request Body​

{
"name": "API_USER",
"oauthScope": "api.read"
}
FieldTypeRequiredDescription
namestringYesName of the role. A missing or blank name answers 400 malformedRequest
oauthScopestringNoOAuth 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​

StatusError keyCause
400malformedRequestThe name is missing, or the OAuth scope name is invalid or already used. params.field names the field and params.reason the cause
409duplicateNameAnother 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 + MANAGE permission in the project
  • A project outside the scope of the caller answers 404 resourceNotFound, never 403
  • The admin project is served: a call on /apiops/projects/admin/consumer-roles addresses the roles of the admin project