Skip to content
Last updated

Create a new rule that defines AI behavior, formatting guidelines, safety constraints, or other instructions. Rules can be attached to assistants, users, models, vector stores, or organizations.

POSThttps://api.aitronos.com/v1/organizations/{organization_id}/rules

Create a new rule with specified configuration. The creator automatically receives owner access. Optionally attach entities during creation for atomic rule deployment.

Path Parameters

organization_id string required

Organization ID (org_ prefixed string) where the rule will be created.

Request Body

name string required

Rule name (1-255 characters). Must be unique within organization. Example: "Professional Communication Standard".

content string required

Rule content or instructions (1-50,000 characters). Injected into system message when applied. Supports plain text or markdown.

description string optional

Description explaining the rule's purpose (max 5,000 characters).

category string optional

Rule category. Values: safety, professional, creative, technical, custom.

rule_type string optional

Rule type. Values: behavior, guardrails, formatting, context, content_policy, constraint.

scope string optional

Rule scope. Values: organization, model, assistant, user, vector_store. Note: global scope restricted to admin only.

apply_mode string optional

Application mode. Values: always, auto, manual.

is_public boolean optional · Defaults to false

Whether rule is publicly visible to other organizations.

is_active boolean optional · Defaults to true

Whether rule is active and can be applied.

attachments array optional

Entities to attach during creation. Allows atomic rule deployment with attachments in a single request.

Each attachment object contains:

  • entity_type string required - Entity type: assistant, vector_store, user, model, organization
  • entity_id string required - Entity ID (e.g., asst_abc123)
  • priority integer optional - Priority 1-100 (default: 50)
  • character_limit integer optional - Character limit 100-50,000

Returns

Returns the created Rule object with full details. If attachments were provided, includes attached_entities array with attachment details.

Bash
curl https://api.aitronos.com/v1/organizations/org_abc123/rules \
  -H "X-API-Key: $FREDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Customer Support Guidelines",
    "content": "Always be polite and professional. Respond within 24 hours to customer inquiries."
  }'

Response:

{
  "id": "rule_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "name": "Professional Communication Rule",
  "description": "Ensures professional communication standards",
  "content": "Always maintain a professional and courteous tone in all communications. Use formal language and avoid slang.",
  "content_length": 120,
  "category": "professional",
  "rule_type": "behavior",
  "scope": "organization",
  "apply_mode": "always",
  "organization_id": "org_abc123",
  "created_by": "usr_456def",
  "is_public": false,
  "is_active": true,
  "version": 1,
  "usage_count": 2,
  "can_edit": true,
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": "2025-01-15T10:30:00Z",
  "attached_entities": [
    {
      "id": "ratt_xyz789",
      "entity_type": "assistant",
      "entity_id": "asst_abc123",
      "priority": 80,
      "character_limit": 1000,
      "is_active": true
    },
    {
      "id": "ratt_abc456",
      "entity_type": "vector_store",
      "entity_id": "vs_def456",
      "priority": 70,
      "character_limit": 2000,
      "is_active": true
    }
  ]
}