Rules
Documentation for Rules
Base path: /api/v1/rules
Rules are decision logic components built using the GoRules JDM (JSON Decision Model) format. They support conditions, decision tables, expressions, and function nodes. Rules go through a draft β version lifecycle similar to workflows.
All endpoints require JWT authentication and an x-active-org header.
Endpoints Overview
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/rules/:threadId/messages | Send a message in a rules chat thread (SSE) |
| GET | /api/v1/rules | List all rules |
| GET | /api/v1/rules/:ruleId | Get rule details |
| GET | /api/v1/rules/:ruleId/versions | List rule versions |
| POST | /api/v1/rules | Save a rule from a draft |
| POST | /api/v1/rules/:ruleId/versions | Create a new rule version from a draft |
| POST | /api/v1/rules/drafts/:draftId/validate | Validate a rule draft |
| POST | /api/v1/rules/drafts/:draftId/test | Test a rule draft with inputs |
POST /api/v1/rules/:threadId/messages
Sends a message to the AI rules assistant in a chat thread and streams the response via SSE. Used to author/edit decision rule definitions through conversation.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string (UUID) | Thread ID (must be a rules thread) |
Request Body (multipart/form-data)
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
message | string | Yes | β | User message text |
isInterrupt | boolean | No | false | Whether this is a response to an interrupt |
inputs | JSON object | No | {} | Input values when responding to interrupts |
attachments | File[] | No | [] | File attachments |
model | string | No | "GPT-4o" | AI model to use |
Available models: GPT-4o, GPT-4o-mini, Claude-3-5-Sonnet, Claude-3-5-Haiku, Gemini-2.0-Flash, Gemini-2.5-Pro, DeepSeek-R1, o3-mini, o4-mini
Response
Returns an SSE stream (Content-Type: text/event-stream).
| Event | Data | Description |
|---|---|---|
ping | { "content": "ping" } | Keep-alive heartbeat |
message | { "content": "<text>" } | AI response text |
error | { "content": "<message>" } | Streaming error |
GET /api/v1/rules
Lists all rules in the active organization.
Response 200 OK
Rule fields:
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Rule ID |
name | string | Rule name |
description | string | null | Rule description |
createdAt | string (ISO 8601) | Creation time |
updatedAt | string (ISO 8601) | Last update time |
GET /api/v1/rules/:ruleId
Returns details of a specific rule including its current version definition.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
ruleId | string (UUID) | Rule ID |
Response 200 OK
GET /api/v1/rules/:ruleId/versions
Lists all published versions of a rule.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
ruleId | string (UUID) | Rule ID |
Response 200 OK
POST /api/v1/rules
Saves a new rule from a draft. Creates the rule record and its first version.
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
draftId | string | Yes | ID of the draft to save (thread or rule draft ID) |
name | string | Yes | Rule name (min length: 1) |
description | string | No | Rule description |
Response 200 OK
Returns the newly created rule.
Errors
| Status | Reason |
|---|---|
400 Bad Request | Draft is invalid (failed validation) |
404 Not Found | Draft not found |
POST /api/v1/rules/:ruleId/versions
Creates a new published version of an existing rule from a draft.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
ruleId | string (UUID) | Rule ID |
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
draftId | string | Yes | ID of the draft to publish as a new version |
Response 200 OK
Returns the new rule version.
Errors
| Status | Reason |
|---|---|
400 Bad Request | Draft is invalid |
404 Not Found | Rule or draft not found |
POST /api/v1/rules/drafts/:draftId/validate
Validates a rule draft against the JDM schema. Returns validation errors if any.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
draftId | string | Draft ID |
Request
No request body required.
Response 200 OK
On validation failure:
POST /api/v1/rules/drafts/:draftId/test
Runs a rule draft against provided test inputs and returns the output.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
draftId | string | Draft ID |
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
inputs | object | Yes | Key-value input map matching the rule's input schema |
Response 200 OK
Errors
| Status | Reason |
|---|---|
400 Bad Request | Draft is invalid and cannot be executed |
404 Not Found | Draft not found |
JDM Rule Definition Format
Rules use the GoRules JDM v1 format:
Node types: inputNode, outputNode, decisionTableNode, expressionNode, functionNode, switchNode, decisionNode