Docs
Live demo
POST/api/v2/grants

Create access grants for subjects on targets. Supports both synchronous and asynchronous modes. Name the subject exactly one way: subject_id, or connector_id, provider, external_id and subject_kind together. A request with subject_id and any external identity field is refused with 400. The access check, the rule, the command record and the response all name that one subject, also for a template grant by subject_id. Either template_name or rules must be provided.

  • TTL: ISO 8601 duration (15 minutes to 30 days, e.g. PT1H) for a person only (creates a temporary account on databases and Kubernetes). Groups return policy.ttl_not_allowed.
mode Status Behavior
plan_only
—
Creates rule and plan
apply_sync
201
Creates rule, queues apply
apply_async
202
Creates rule, queues apply

Both apply modes return before the apply runs: status, terminal and outcome describe the grant request, not the apply. Poll job_id.

Parameters

Header1 optional
Idempotency-Keystringheader

Idempotency key for request deduplication. The key belongs to the organization and the console session that sent it: a retry from the same session gets the stored answer, another session runs its own request.

Request body application/json · GrantAccessRequest

Grant access request

Required2 of 15 fields
modestringrequired

Execution mode

plan_onlyapply_asyncapply_sync
target_idstringrequired

Target identification

Optional13 fields
commentstring
connector_idstring

For EnsureSubject

dry_run_reasonstring

Optional metadata

external_idstring

For EnsureSubject

operation_idstring

OperationID for idempotency (optional, generated if not provided)

providerstring

For EnsureSubject

2 fields
permissionsarray of stringrequired
min items 1
resourcesarray of stringrequired
min items 1
subject_idstring

The subject to grant to. Send either subject_id or connector_id, provider, external_id and subject_kind, not both.

subject_kindstring (entity.SubjectKind)

For EnsureSubject

usergroupservice
template_namestring

Policy definition (one of these must be provided)

template_varsmap of string → any
template_versioninteger
ttlstring

Rule with a TTL (I17): an ISO 8601 duration of 15 minutes to 30 days, for example PT1H. The grant creates a personal rule that Principal removes at that moment. On a database or Kubernetes target the rule gets its own temporary account. A group subject refuses it with policy.ttl_not_allowed.

example "PT1H"

Responses

201

Access granted (sync mode)

GrantAccessResponse · 14 fields
terminalbooleanrequired
outcomestring (entity.OperationOutcome)required

Final operation result, or null while the operation is active.

successfailurecancelledpartial
can be null

Safe operation failure. Explanation and recommended_action come from the static failure-code registry. The only text not written by Principal is cluster_answer.

8 fields
codestring (JobFailureCode)required

Closed registry of asynchronous operation failure causes, independent of HTTP problem codes.

ACCESS_PROFILE_STALEAMBIGUOUS_TARGET_OUTCOMEAPPLY_INTERRUPTEDAUTHENTICATION_FAILEDCLICKHOUSE_REPLICAS_OUT_OF_SYNCCLICKHOUSE_USER_NAME_RESERVEDCONNECTION_FAILEDCONNECTION_REFUSEDCONNECTION_TIMEOUTCONNECTOR_CREDENTIALS_MISSINGCONNECTOR_PAUSEDCONNECTOR_SOURCE_CHANGEDCONNECTOR_TYPE_UNAVAILABLECONSTRAINT_VIOLATIONCREDENTIAL_EXPIREDCREDENTIAL_NOT_FOUNDDATABASE_NOT_FOUNDDRIFT_BINDING_NOT_FOUNDDRIFT_DEFAULT_INHERITED_SKIPPEDDRIFT_NO_EXECUTABLE_DIFFDRIFT_PARTIAL_APPLYDRIFT_PLAN_GENERATION_FAILEDDRIFT_RESOURCE_MISMATCHDRIFT_RULE_DELETINGDRIFT_RUN_OUTDATEDDRIFT_SCOPE_MISMATCHGROUP_EXPANSION_LIMIT_EXCEEDEDHANDLER_NOT_FOUNDK8S_CHANGE_REJECTEDK8S_CLUSTER_UNREACHABLEK8S_NAMESPACE_FORBIDDENK8S_NAMESPACE_NOT_FOUNDK8S_RBAC_FORBIDDENKUBERNETES_MEMBER_CREDENTIALS_PENDINGKUBERNETES_SERVICE_ACCOUNT_KUBECONFIG_NOT_ISSUEDMARIADB_TRUNCATE_UNSUPPORTEDMARIADB_USAGE_UNSUPPORTEDMARIADB_GRANTS_AMBIGUOUSMUTATION_LOCKEDMYSQL_MANAGEMENT_PRIVILEGES_MISSING
34 more values
NOT_FOUNDOPERATION_BACKOFFOPERATION_CANCELLEDOPERATION_TIMEOUTOWNED_OBJECTS_DECISION_REQUIREDPERMISSION_DENIEDPLAN_APPLY_ARTIFACT_INVALIDPLAN_APPLY_ORPHANED_LOCKPLAN_APPLY_ROLLBACK_BASELINE_INVALIDPLAN_APPLY_RULE_CHANGEDPLAN_APPLY_TARGET_STATE_CHANGEDPLAN_APPLY_ACCESS_IMPACT_CHANGEDPOSTGRES_FUTURE_OBJECT_CREATORS_MISSINGPOSTGRES_GRANT_AUTHORITY_MISSINGPOSTGRES_MANAGEMENT_PRIVILEGES_MISSINGPOSTGRES_ROLE_ATTRIBUTE_UNSUPPORTEDPOSTGRES_ROLE_NAME_RESERVEDPOSTGRES_TLS_FILE_NOT_ALLOWEDPROVIDER_REQUEST_FAILEDRATE_LIMITEDROLE_EXISTSROLE_NOT_FOUNDROTATION_CHECK_REQUIREDSECRET_STORE_UNAVAILABLESERIALIZATION_ERRORTARGET_ACCOUNT_IDENTITY_MISMATCHTARGET_ACCOUNT_IDENTITY_UNVERIFIEDTARGET_ACCOUNT_IMPORT_PENDINGTARGET_ACCOUNT_PRINCIPAL_LOGINTARGET_ACCOUNT_TAKENTARGET_CONNECTION_MISSINGTARGET_REPAIR_REQUIREDUNKNOWN_ERRORVALIDATION_FAILED
titlestring

Short name of the failure from the same registry, for lists and queues where the explanation is too long. Absent on failures saved before the field existed.

max length 32
explanationstringrequired
recommended_actionstringrequired
retryablebooleanrequired

Whether the failed attempt was eligible for an automatic retry under the actual queue policy.

phasestring

Known operation phase at failure, when available.

resolution_codestring

Stable code of the action that can resolve this failure, the same vocabulary as a problem's resolution.code, for example upstream.check_connection. Absent when no single action does. A screen that offers the action shows it next to the failure, otherwise it shows recommended_action.

max length 128 · pattern ^[a-z][a-z0-9_-]*(\.[a-z0-9_-]+)*$
cluster_answerstring

The Kubernetes cluster's own answer to a change its admission policy or webhook refused: the policy or webhook name and its message. Only a step failure with code K8S_CHANGE_REJECTED carries it, as plain text without control characters, cut to 500 characters. The cluster administrator writes it, not Principal. Given only to callers with access:read in the rule's organization. Absent for runs saved before the field existed.

max length 500
substatestring (entity.OperationSubstate)required

Qualifies the status and outcome of an operation where they alone would hide what the operator must know. Null when none applies.

rollback_in_progressrolled_backneeds_repairoutcome_unknowninterruptedrequires_approvalholds_lockawaiting_confirmationexpiredtimed_outrescheduled
can be null
apply_run_idstring
command_idstring
errorsarray of ErrorDetail
3 fields
codestring
fieldstring
messagestring
job_idstring
operation_idstring
plan_idstring

The saved plan the grant generated. In an apply mode the job executes this plan exactly when POST /policies/{id}/plan would report exact_apply_supported true. Otherwise, for example for a group policy applied per member, the job applies the policy's current state and records the plan it builds on its own apply run (see job_id), while plan_id keeps naming the generated plan for tracing.

plan_summaryPlanSummary
3 fields
estimated_timestring
operations_countinteger
resource_countinteger
policy_idstring

Where a background operation is in the shared lifecycle (decision S1). outcome says how a finished operation ended and substate qualifies the state.

queuedrunningfinished
subject_idstring
202

Access grant initiated (async mode)

GrantAccessResponse · 14 fields
terminalbooleanrequired
outcomestring (entity.OperationOutcome)required

Final operation result, or null while the operation is active.

successfailurecancelledpartial
can be null

Safe operation failure. Explanation and recommended_action come from the static failure-code registry. The only text not written by Principal is cluster_answer.

8 fields
codestring (JobFailureCode)required

Closed registry of asynchronous operation failure causes, independent of HTTP problem codes.

ACCESS_PROFILE_STALEAMBIGUOUS_TARGET_OUTCOMEAPPLY_INTERRUPTEDAUTHENTICATION_FAILEDCLICKHOUSE_REPLICAS_OUT_OF_SYNCCLICKHOUSE_USER_NAME_RESERVEDCONNECTION_FAILEDCONNECTION_REFUSEDCONNECTION_TIMEOUTCONNECTOR_CREDENTIALS_MISSINGCONNECTOR_PAUSEDCONNECTOR_SOURCE_CHANGEDCONNECTOR_TYPE_UNAVAILABLECONSTRAINT_VIOLATIONCREDENTIAL_EXPIREDCREDENTIAL_NOT_FOUNDDATABASE_NOT_FOUNDDRIFT_BINDING_NOT_FOUNDDRIFT_DEFAULT_INHERITED_SKIPPEDDRIFT_NO_EXECUTABLE_DIFFDRIFT_PARTIAL_APPLYDRIFT_PLAN_GENERATION_FAILEDDRIFT_RESOURCE_MISMATCHDRIFT_RULE_DELETINGDRIFT_RUN_OUTDATEDDRIFT_SCOPE_MISMATCHGROUP_EXPANSION_LIMIT_EXCEEDEDHANDLER_NOT_FOUNDK8S_CHANGE_REJECTEDK8S_CLUSTER_UNREACHABLEK8S_NAMESPACE_FORBIDDENK8S_NAMESPACE_NOT_FOUNDK8S_RBAC_FORBIDDENKUBERNETES_MEMBER_CREDENTIALS_PENDINGKUBERNETES_SERVICE_ACCOUNT_KUBECONFIG_NOT_ISSUEDMARIADB_TRUNCATE_UNSUPPORTEDMARIADB_USAGE_UNSUPPORTEDMARIADB_GRANTS_AMBIGUOUSMUTATION_LOCKEDMYSQL_MANAGEMENT_PRIVILEGES_MISSING
34 more values
NOT_FOUNDOPERATION_BACKOFFOPERATION_CANCELLEDOPERATION_TIMEOUTOWNED_OBJECTS_DECISION_REQUIREDPERMISSION_DENIEDPLAN_APPLY_ARTIFACT_INVALIDPLAN_APPLY_ORPHANED_LOCKPLAN_APPLY_ROLLBACK_BASELINE_INVALIDPLAN_APPLY_RULE_CHANGEDPLAN_APPLY_TARGET_STATE_CHANGEDPLAN_APPLY_ACCESS_IMPACT_CHANGEDPOSTGRES_FUTURE_OBJECT_CREATORS_MISSINGPOSTGRES_GRANT_AUTHORITY_MISSINGPOSTGRES_MANAGEMENT_PRIVILEGES_MISSINGPOSTGRES_ROLE_ATTRIBUTE_UNSUPPORTEDPOSTGRES_ROLE_NAME_RESERVEDPOSTGRES_TLS_FILE_NOT_ALLOWEDPROVIDER_REQUEST_FAILEDRATE_LIMITEDROLE_EXISTSROLE_NOT_FOUNDROTATION_CHECK_REQUIREDSECRET_STORE_UNAVAILABLESERIALIZATION_ERRORTARGET_ACCOUNT_IDENTITY_MISMATCHTARGET_ACCOUNT_IDENTITY_UNVERIFIEDTARGET_ACCOUNT_IMPORT_PENDINGTARGET_ACCOUNT_PRINCIPAL_LOGINTARGET_ACCOUNT_TAKENTARGET_CONNECTION_MISSINGTARGET_REPAIR_REQUIREDUNKNOWN_ERRORVALIDATION_FAILED
titlestring

Short name of the failure from the same registry, for lists and queues where the explanation is too long. Absent on failures saved before the field existed.

max length 32
explanationstringrequired
recommended_actionstringrequired
retryablebooleanrequired

Whether the failed attempt was eligible for an automatic retry under the actual queue policy.

phasestring

Known operation phase at failure, when available.

resolution_codestring

Stable code of the action that can resolve this failure, the same vocabulary as a problem's resolution.code, for example upstream.check_connection. Absent when no single action does. A screen that offers the action shows it next to the failure, otherwise it shows recommended_action.

max length 128 · pattern ^[a-z][a-z0-9_-]*(\.[a-z0-9_-]+)*$
cluster_answerstring

The Kubernetes cluster's own answer to a change its admission policy or webhook refused: the policy or webhook name and its message. Only a step failure with code K8S_CHANGE_REJECTED carries it, as plain text without control characters, cut to 500 characters. The cluster administrator writes it, not Principal. Given only to callers with access:read in the rule's organization. Absent for runs saved before the field existed.

max length 500
substatestring (entity.OperationSubstate)required

Qualifies the status and outcome of an operation where they alone would hide what the operator must know. Null when none applies.

rollback_in_progressrolled_backneeds_repairoutcome_unknowninterruptedrequires_approvalholds_lockawaiting_confirmationexpiredtimed_outrescheduled
can be null
apply_run_idstring
command_idstring
errorsarray of ErrorDetail
3 fields
codestring
fieldstring
messagestring
job_idstring
operation_idstring
plan_idstring

The saved plan the grant generated. In an apply mode the job executes this plan exactly when POST /policies/{id}/plan would report exact_apply_supported true. Otherwise, for example for a group policy applied per member, the job applies the policy's current state and records the plan it builds on its own apply run (see job_id), while plan_id keeps naming the generated plan for tracing.

plan_summaryPlanSummary
3 fields
estimated_timestring
operations_countinteger
resource_countinteger
policy_idstring

Where a background operation is in the shared lifecycle (decision S1). outcome says how a finished operation ended and substate qualifies the state.

queuedrunningfinished
subject_idstring
400

Invalid request

404

Subject or target not found

409

Conflict

422

Unprocessable Entity - Future objects stay on for a PostgreSQL rule while one of its rows names its objects by name or by a name mask. Field_errors names the switch

500

Internal Server Error

Common errors: 401 403 413 429 503 504. They mean the same for every operation, see Errors.

↑ ↓ to moveEnter to openEsc to close