title: Update a rule keywords: - update a rule - put - update - rule # Update a rule Update an existing rule. Requires edit or owner access. #### Path Parameters **`org_id`** string required The org id parameter. **`rule_id`** string required The rule id parameter. #### Request Body **`name`** string optional The name parameter. **`content`** string optional The content parameter. **`description`** string optional The description parameter. **`category`** RuleCategory optional The category parameter. **`rule_type`** RuleType optional The rule type parameter. **`scope`** RuleScopeAPI optional Rule scope (global scope restricted - admin only) **`apply_mode`** ApplyMode optional The apply mode parameter. **`is_public`** boolean optional The is public parameter. **`is_active`** boolean optional The is active parameter. ## Returns **`id`** string Rule ID with rule_ prefix **`name`** string Rule name **`description`** string or null Rule description **`content`** string Full rule content **`content_length`** integer Total character count of content **`category`** string or null Rule category **`rule_type`** string or null Rule type **`scope`** string or null Rule scope **`apply_mode`** string or null Rule apply mode **`organization_id`** string Organization ID **`created_by`** string User ID who created the rule **`is_public`** boolean Whether rule is public **`is_active`** boolean Whether rule is active **`version`** integer Rule version number **`usage_count`** integer Number of active attachments **`can_edit`** boolean Whether current user can edit this rule **`created_at`** string Creation timestamp **`updated_at`** string Last update timestamp **`attached_entities`** array of object or null List of attached entities Example ```bash cURL curl -X PUT "https://api.aitronos.com/v1/organizations/{org_id}/rules/{rule_id}" \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") rule = client.rule_operations.update_rule( "org_abc123", "rule_abc123", content="Updated rule content with new guidelines.", ) print(f"Updated to version {rule.version}") ``` ```python Python import os import requests api_key = os.environ["FREDDY_API_KEY"] response = requests.put( "https://api.aitronos.com/v1/organizations/{org_id}/rules/{rule_id}", headers={"X-API-Key": api_key} ) print(response.json()) ``` ```javascript JavaScript const apiKey = process.env.FREDDY_API_KEY; const response = await fetch('https://api.aitronos.com/v1/organizations/{org_id}/rules/{rule_id}', { method: 'PUT', headers: { 'X-API-Key': apiKey, 'Content-Type': 'application/json' } }); const data = await response.json(); console.log(data); ``` **Response:** ```json 200 OK { "id": "rule_abc123def456", "name": "My Resource", "description": "A description of the resource", "content": "Response content", "content_length": 1, "category": "general", "rule_type": "default", "scope": "organization", "apply_mode": "default", "organization_id": "org_abc123def456", "created_by": "example_created_by", "is_public": true, "is_active": true, "version": 1, "usage_count": 42, "can_edit": false, "created_at": "2025-11-15T10:30:00Z", "updated_at": "2025-11-15T10:30:00Z", "attached_entities": [ { "id": "abc123def456", "entity_type": "default", "entity_id": "abc123def456", "priority": 1, "is_active": true } ] } ``` Errors ```json 401 Unauthorized { "success": false, "error": { "code": "AUTHENTICATION_REQUIRED", "message": "Authentication required. Please provide a valid API key.", "system_message": "Missing or invalid authorization header", "type": "authentication_error", "status": 401, "trace_id": "req_abc123xyz", "timestamp": "2025-11-11T10:30:00Z", "details": {} } } ``` ```json 403 Forbidden { "success": false, "error": { "code": "INSUFFICIENT_PERMISSIONS", "message": "You do not have permission to access this resource.", "system_message": "Insufficient permissions for this operation", "type": "authorization_error", "status": 403, "trace_id": "req_def456uvw", "timestamp": "2025-11-11T10:30:00Z", "details": {} } } ``` ## Related Resources - [Create Rule](/docs/api-reference/rules/create) - [List Rules](/docs/api-reference/rules/list)