Get Policy
Sprint 3
Get policy details by ID including rules and assignments.
Endpoint
GET /api/v1/policies/{policy_id}
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <access_token> |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
policy_id | integer | Yes | Policy ID |
Response
Success (200)
{
"success": true,
"data": {
"id": 1,
"organization_id": 1,
"workspace_id": 1,
"name": "RLS Policy - Region Filter",
"description": "Filter rows by user region",
"type": "row_level_security",
"is_active": true,
"priority": 10,
"rules": [
{
"id": 1,
"policy_id": 1,
"rule_name": "Region Filter Rule",
"rule_type": "filter_rows",
"rule_config": {
"condition": "user_region = current_user_region",
"table": "sales",
"column": "region"
},
"rule_order": 0,
"is_active": true,
"created_at": "2024-12-01T08:00:00Z",
"updated_at": "2024-12-01T08:00:00Z"
}
],
"assignments": [
{
"id": 1,
"policy_id": 1,
"data_source_id": 1,
"role_id": 2,
"role_name": "Analyst",
"is_active": true,
"applied_at": "2024-12-01T09:00:00Z",
"applied_by_user_id": 1
}
],
"metadata": {},
"created_by_user_id": 1,
"created_at": "2024-12-01T08:00:00Z",
"updated_at": "2024-12-01T10:00:00Z",
"updated_by_user_id": 1
},
"message": "Policy retrieved successfully"
}
Error Codes
| Status | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Invalid or missing authentication token |
| 404 | NOT_FOUND | Policy not found |
Features
- Returns complete policy configuration
- Includes all rules with configurations
- Includes all assignments
- Organization-scoped access control
Example
curl -X GET "https://api.rivergen.com/api/v1/policies/1" \
-H "Authorization: Bearer <access_token>"
Related Endpoints
- List Policies - List all policies
- Update Policy - Update policy configuration