iam.grants.createGrant capabilities on one resource to a user, group or role
Each capability id stands for a fixed set of IAM actions; the caller must already hold every action being granted, or the call is refused naming the one they lack. The resource must be one named thing in the caller’s own organization — a wildcard such as zone/* is refused, since org-wide reach belongs on the policy pages.
Depending on the resource, the call checks iam:AttachGroupPolicy, iam:AttachRolePolicy instead; hold all of them to be sure it is allowed.
Request syntax
POST /iam/api/grants
{
"principal": "object",
"resource": "string",
"capabilities": "array of string"
}Request body
principalRequiredobject
Who receives the capabilities: {kind: user|group|role, id}
Constraints: JSON
resourceRequiredstring
The RN of one named resource of this organization; a wildcard is refused
Constraints: 1-500 chars
capabilitiesRequiredarray of string
Capability IDs, e.g. repository.push or database.view; each must apply to the resource’s type, and you must hold every action it stands for
Constraints: 1-64 chars
Response
201 with { policyId, policyName, resource, capabilities, actions, principal { kind, id, name } }: the policy written and attached, and the actions it allows.
A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.
Errors
- 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
- 401No credentials, or an access key that is unknown, revoked or expired.
- 403The caller's policies do not allow iam:AttachUserPolicy on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
- 404The resource does not exist in your organization.
Examples
The required parameters only, with example values. Replace id and the other placeholders with your own.
dcloud iam grants create --principal '{}' --resource example --capabilities '["example"]'curl -X POST "https://console.platform-development.deutschecloud.app/iam/api/grants" \
-H "Authorization: EWS-ACCESS-KEY $ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{"principal":{},"resource":"example","capabilities":["example"]}'Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_iam_grants_create.