Update Policy
Sprint 3
Update an existing policy. All fields are optional - only provided fields will be updated.
Endpoint
PATCH /api/v1/policies/{policy_id}
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <access_token> |
Content-Type | Yes | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
policy_id | integer | Yes | Policy ID |
Request Body
All fields are optional. Only provided fields will be updated.
{
"name": "Updated Policy Name",
"description": "Updated description",
"is_active": false,
"priority": 20,
"metadata": {}
}
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | Policy name (1-255 characters) |
description | string | No | Policy description |
is_active | boolean | No | Active status |
priority | integer | No | Priority (min: 0) |
metadata | object | No | Additional metadata |
Response
Success (200)
{
"success": true,
"data": {
"id": 1,
"organization_id": 1,
"workspace_id": 1,
"name": "Updated Policy Name",
"description": "Updated description",
"type": "row_level_security",
"is_active": false,
"priority": 20,
"updated_at": "2024-12-01T11:00:00Z",
"updated_by_user_id": 1
},
"message": "Policy updated successfully"
}
Error Codes
| Status | Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Invalid request data |
| 401 | UNAUTHORIZED | Invalid or missing authentication token |
| 404 | NOT_FOUND | Policy not found |
| 500 | INTERNAL_SERVER_ERROR | Internal server error |
Features
- Partial updates (only provided fields are updated)
- Organization-scoped access control
- Updates
updated_atandupdated_by_user_idautomatically
Example
curl -X PATCH "https://api.rivergen.com/api/v1/policies/1" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"is_active": false,
"priority": 20
}'
Related Endpoints
- Get Policy - Get current policy details
- Create Policy - Create new policy