Skip to main content

Assign Policy

Sprint 3

Assign a policy to resources (data sources, datasets, queries, roles, users, workspaces).

Endpoint

POST /api/v1/policies/{policy_id}/assignments

Headers

HeaderRequiredDescription
AuthorizationYesBearer <access_token>
Content-TypeYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
policy_idintegerYesPolicy ID

Request Body

{
"data_source_id": 1,
"role_id": 2,
"user_id": 5,
"is_active": true,
"metadata": {}
}

Parameters

At least one target resource must be specified.

FieldTypeRequiredDescription
data_source_idintegerNoData source ID
dataset_idintegerNoDataset ID
query_idintegerNoQuery ID
role_idintegerNoRole ID
user_idintegerNoUser ID
workspace_idintegerNoWorkspace ID
is_activebooleanNoActive status (default: true)
metadataobjectNoAdditional metadata

Response

Success (201)

{
"success": true,
"data": {
"id": 1,
"policy_id": 1,
"data_source_id": 1,
"role_id": 2,
"role_name": "Analyst",
"user_id": 5,
"is_active": true,
"applied_at": "2024-12-01T09:00:00Z",
"applied_by_user_id": 1,
"metadata": {}
},
"message": "Policy assigned successfully"
}

Error Codes

StatusCodeDescription
400BAD_REQUESTInvalid request data - at least one target resource must be specified
401UNAUTHORIZEDInvalid or missing authentication token
500INTERNAL_SERVER_ERRORInternal server error

Validations

  • At least one target resource (data_source_id, dataset_id, query_id, role_id, user_id, or workspace_id) must be specified

Features

  • Assign to multiple resource types
  • Organization-scoped access control
  • Tracks who applied the assignment

Example

curl -X POST "https://api.rivergen.com/api/v1/policies/1/assignments" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"data_source_id": 1,
"role_id": 2
}'