REST /api/v1/report-history-policies 5 endpoints
GET /api/v1/report-history-policies/api/v1/report-history-policies

List configured RLS and retention policies for report history access

Public

Response Example

{
  "data": [
    {
      "policy_id": "pol_01LA3M7R8S9T0U1V2W3X4Y5Z",
      "org_id": "org_bufdir_oslo_42",
      "policy_name": "org_scope_filter",
      "policy_type": "row_level_security",
      "role_constraint": "report_viewer",
      "retention_days": 2555,
      "is_active": true,
      "created_at": "2025-06-01T00:00:00Z",
      "updated_at": "2025-06-01T00:00:00Z"
    },
    {
      "policy_id": "pol_02MB4N8S9T0U1V2W3X4Y5Z6A",
      "org_id": "org_bufdir_oslo_42",
      "policy_name": "admin_full_access",
      "policy_type": "row_level_security",
      "role_constraint": "org_admin",
      "retention_days": 2555,
      "is_active": true,
      "created_at": "2025-06-01T00:00:00Z",
      "updated_at": "2025-06-01T00:00:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 2
  }
}
GET /api/v1/report-history-policies/api/v1/report-history-policies/:policy_id

Retrieve a single RLS policy configuration

Public

Response Example

{
  "policy_id": "pol_01LA3M7R8S9T0U1V2W3X4Y5Z",
  "org_id": "org_bufdir_oslo_42",
  "policy_name": "org_scope_filter",
  "policy_type": "row_level_security",
  "role_constraint": "report_viewer",
  "retention_days": 2555,
  "filter_expression": "org_id = current_setting('app.current_org_id')",
  "is_active": true,
  "created_at": "2025-06-01T00:00:00Z",
  "updated_at": "2025-06-01T00:00:00Z"
}
POST /api/v1/report-history-policies/api/v1/report-history-policies

Create a new RLS or retention policy for report history

Public

Request Example

{
  "org_id": "org_bufdir_bergen_17",
  "policy_name": "org_scope_filter",
  "policy_type": "row_level_security",
  "role_constraint": "report_viewer",
  "retention_days": 2555,
  "filter_expression": "org_id = current_setting('app.current_org_id')",
  "is_active": true
}

Response Example

{
  "policy_id": "pol_03NC5O9T0U1V2W3X4Y5Z6A7B",
  "org_id": "org_bufdir_bergen_17",
  "policy_name": "org_scope_filter",
  "policy_type": "row_level_security",
  "role_constraint": "report_viewer",
  "retention_days": 2555,
  "filter_expression": "org_id = current_setting('app.current_org_id')",
  "is_active": true,
  "created_at": "2026-03-26T12:00:00Z",
  "updated_at": "2026-03-26T12:00:00Z"
}
PUT /api/v1/report-history-policies/api/v1/report-history-policies/:policy_id

Update an existing RLS or retention policy

Public

Request Example

{
  "retention_days": 3650,
  "is_active": true,
  "role_constraint": "report_viewer"
}

Response Example

{
  "policy_id": "pol_01LA3M7R8S9T0U1V2W3X4Y5Z",
  "org_id": "org_bufdir_oslo_42",
  "policy_name": "org_scope_filter",
  "policy_type": "row_level_security",
  "role_constraint": "report_viewer",
  "retention_days": 3650,
  "filter_expression": "org_id = current_setting('app.current_org_id')",
  "is_active": true,
  "created_at": "2025-06-01T00:00:00Z",
  "updated_at": "2026-03-26T12:05:00Z"
}
DELETE /api/v1/report-history-policies/api/v1/report-history-policies/:policy_id

Deactivate and remove an RLS policy

Public

Response Example

{
  "policy_id": "pol_01LA3M7R8S9T0U1V2W3X4Y5Z",
  "deleted": true,
  "deleted_at": "2026-03-26T13:00:00Z"
}

Additional Metadata

{
  "contract_summary": {
    "total_contracts": 410,
    "total_endpoints": 2416,
    "api_styles_used": [
      "rest"
    ]
  },
  "generated_at": "2026-03-26T06:55:53.316Z"
}