Attach an entity (assistant, user, model, vector_store, or organization) to a rule with priority and character limit configuration. ## Path parameters **`rule_id`** string required The rule ID ## Body parameters **`entity_type`** string required Entity type: `assistant`, `user`, `model`, `vector_store`, `organization` **`entity_id`** string required The entity ID to attach **`priority`** integer optional · Defaults to `50` Priority for rule application (1-100). Higher priority rules apply first. Use 90-100 for critical rules, 70-89 for high priority, 50-69 for standard, 30-49 for low, and 1-29 for optional rules. **`character_limit`** integer optional · Defaults to `50000` Maximum characters from this rule's content to include when applied. Useful for managing context window limits. Range: 100-50,000. ## Returns Returns the created attachment object. Basic ```bash curl -X POST https://api.aitronos.com/v1/rules/rule_abc123/attachments \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "entity_type": "assistant", "entity_id": "asst_abc123" }' ``` ```python import requests import os api_key = os.environ["FREDDY_API_KEY"] response = requests.post( "https://api.aitronos.com/v1/rules/rule_abc123/attachments", headers={ "X-API-Key": api_key, "Content-Type": "application/json" }, json={ "entity_type": "assistant", "entity_id": "asst_abc123" } ) attachment = response.json() ``` ```javascript const response = await fetch('https://api.aitronos.com/v1/rules/rule_abc123/attachments', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ entity_type: 'assistant', entity_id: 'asst_abc123' }) }); const attachment = await response.json(); ``` With Priority ```bash curl -X POST https://api.aitronos.com/v1/rules/rule_safety/attachments \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "entity_type": "assistant", "entity_id": "asst_abc123", "priority": 95, "character_limit": 5000 }' ``` ```python import requests import os api_key = os.environ["FREDDY_API_KEY"] response = requests.post( "https://api.aitronos.com/v1/rules/rule_safety/attachments", headers={ "X-API-Key": api_key, "Content-Type": "application/json" }, json={ "entity_type": "assistant", "entity_id": "asst_abc123", "priority": 95, "character_limit": 5000 } ) attachment = response.json() ``` ```javascript const response = await fetch('https://api.aitronos.com/v1/rules/rule_safety/attachments', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ entity_type: 'assistant', entity_id: 'asst_abc123', priority: 95, character_limit: 5000 }) }); const attachment = await response.json(); ``` Multiple Entity Types ```bash # Attach to assistant curl -X POST https://api.aitronos.com/v1/rules/rule_abc123/attachments \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"entity_type": "assistant", "entity_id": "asst_abc123", "priority": 80}' # Attach to user curl -X POST https://api.aitronos.com/v1/rules/rule_abc123/attachments \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"entity_type": "user", "entity_id": "usr_def456", "priority": 70}' # Attach to vector store curl -X POST https://api.aitronos.com/v1/rules/rule_abc123/attachments \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"entity_type": "vector_store", "entity_id": "vs_xyz789", "priority": 65}' # Attach to organization curl -X POST https://api.aitronos.com/v1/rules/rule_abc123/attachments \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"entity_type": "organization", "entity_id": "org_xyz789", "priority": 60}' ``` ```python import requests import os api_key = os.environ["FREDDY_API_KEY"] entities = [ {"entity_type": "assistant", "entity_id": "asst_abc123", "priority": 80}, {"entity_type": "user", "entity_id": "usr_def456", "priority": 70}, {"entity_type": "vector_store", "entity_id": "vs_xyz789", "priority": 65}, {"entity_type": "organization", "entity_id": "org_xyz789", "priority": 60} ] for entity in entities: response = requests.post( "https://api.aitronos.com/v1/rules/rule_abc123/attachments", headers={ "X-API-Key": api_key, "Content-Type": "application/json" }, json=entity ) print(f"Attached to {entity['entity_type']}: {response.json()}") ``` ```javascript const entities = [ { entity_type: 'assistant', entity_id: 'asst_abc123', priority: 80 }, { entity_type: 'user', entity_id: 'usr_def456', priority: 70 }, { entity_type: 'vector_store', entity_id: 'vs_xyz789', priority: 65 }, { entity_type: 'organization', entity_id: 'org_xyz789', priority: 60 } ]; for (const entity of entities) { const response = await fetch('https://api.aitronos.com/v1/rules/rule_abc123/attachments', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify(entity) }); const attachment = await response.json(); console.log(`Attached to ${entity.entity_type}:`, attachment); } ``` **Response:** 201 Created ```json { "success": true, "data": { "id": "ratt_xyz789", "rule_id": "rule_abc123", "entity_type": "assistant", "entity_id": "asst_abc123", "priority": 50, "character_limit": 50000, "is_active": true, "attached_by": "usr_456", "attached_at": "2025-11-24T12:00:00Z", "created_at": "2025-11-24T12:00:00Z", "updated_at": "2025-11-24T12:00:00Z" } } ``` 409 Conflict ```json { "success": false, "error": { "code": "ATTACHMENT_ALREADY_EXISTS", "message": "This entity is already attached to the rule.", "status": 409 } } ``` 422 Validation Error ```json { "success": false, "error": { "code": "VALIDATION_ERROR", "message": "Priority must be between 1 and 100", "status": 422, "details": { "field": "priority", "value": 150 } } } ```