Skip to main content

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

HeaderRequiredDescription
AuthorizationYesBearer <access_token>
Content-TypeYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
policy_idintegerYesPolicy 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

FieldTypeRequiredDescription
namestringNoPolicy name (1-255 characters)
descriptionstringNoPolicy description
is_activebooleanNoActive status
priorityintegerNoPriority (min: 0)
metadataobjectNoAdditional 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

StatusCodeDescription
400BAD_REQUESTInvalid request data
401UNAUTHORIZEDInvalid or missing authentication token
404NOT_FOUNDPolicy not found
500INTERNAL_SERVER_ERRORInternal server error

Features

  • Partial updates (only provided fields are updated)
  • Organization-scoped access control
  • Updates updated_at and updated_by_user_id automatically

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
}'