Update a rule
Endpoint
Section titled “Endpoint”PUT /v1/spending-rules/{ruleId}
Authentication
Section titled “Authentication”No authentication required.
Path Parameters
Section titled “Path Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
ruleId | string | Yes | Rule ID (UUID) |
Request Body
Section titled “Request Body”{ "version": 1, "name": "Daily spending limit", "ruleType": "usage_limit", "resolutionStrategy": "automatic", "status": "active", "metadata": { "category": "finance" }, "conditions": [ { "fieldType": "service", "fieldName": "openai", "operator": "equals", "value": "openai", "conditionGroup": "primary" } ], "parameters": [ { "parameterName": "Max daily transactions", "limitValue": "100", "measurementType": "count_transactions", "intervalValue": 24, "intervalUnit": "hours", "isRolling": true, "groupBy": [ "agent" ], "measurementScope": "all", "description": "Limits total API calls per day" } ], "agentIds": [ "550e8400-e29b-41d4-a716-446655440000" ]}cURL Example
Section titled “cURL Example”curl -X PUT "https://api.sapiom.ai/v1/spending-rules/{ruleId}" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "version": 1, "name": "Daily spending limit", "ruleType": "usage_limit", "resolutionStrategy": "automatic", "status": "active", "metadata": { "category": "finance" }, "conditions": [ { "fieldType": "service", "fieldName": "openai", "operator": "equals", "value": "openai", "conditionGroup": "primary" } ], "parameters": [ { "parameterName": "Max daily transactions", "limitValue": "100", "measurementType": "count_transactions", "intervalValue": 24, "intervalUnit": "hours", "isRolling": true, "groupBy": [ "agent" ], "measurementScope": "all", "description": "Limits total API calls per day" } ], "agentIds": [ "550e8400-e29b-41d4-a716-446655440000" ]}'Response
Section titled “Response”{ "id": "string", "tenantId": "string", "numericId": 0, "formattedId": "string", "name": "string", "ruleType": "usage_limit", "resolutionStrategy": "automatic", "status": "active", "version": 0, "metadata": null, "createdAt": "2025-01-15T10:30:00Z", "updatedAt": "2025-01-15T10:30:00Z"}Error Responses
Section titled “Error Responses”| Status | Code | Description |
|---|---|---|
| 400 | - | Invalid request data |
| 401 | - | Unauthorized - invalid or missing authentication |
| 403 | - | Forbidden - insufficient permissions |
| 404 | - | Rule not found |
| 409 | - | Version conflict - rule was modified by another user |
See API Introduction for error handling details.