Skip to main content

Create Routing Rule

Create a new routing rule with conditions on document properties and actions to apply when matched. Conditions can match document type, source, and other metadata.

Create a rule that automatically applies actions to incoming documents based on their metadata. Conditions define what to match (e.g. document type equals "invoice"), and actions define what to do (e.g. assign the finance schema). Rules are evaluated on every document_classified event.

The typical workflow is: create rules ordered by specificity — put narrow, high-priority rules first (e.g. "contracts from vendor X") and broader catch-all rules last. New rules are active immediately upon creation, so the next classified document will be evaluated against them.

The response returns the rule with is_active: true, a trigger_type of document_classified, and the assigned priority (defaults to 100 if omitted). The action_type is resolved from the actions object. Use the reorder endpoint after creation to adjust the priority relative to existing rules.

Pair with GET /v1/routing-rules to verify the full priority chain after creating a rule. Use source_connection_id to scope rules to documents from a specific source — documents from other sources will skip the rule entirely. To test a rule before going live, create it and immediately disable it via PATCH with is_active: false.

New rules are created with is_active: true by default. If you want to test a rule before activating it, create it, then immediately disable it via PATCH /v1/routing-rules/:id with is_active: false.
POST/v1/routing-rules

Response

Response fields (201 Created)

idstringRouting rule UUID.
namestringRule name.
trigger_typestringAlways document_classified for rules created via the API.
conditionsobjectCondition configuration.
action_typestringResolved action type.
actionsobjectAction configuration.
priorityintegerAssigned priority.
is_activebooleanAlways true for newly created rules.
review_requiredbooleanWhether matched documents require manual review.
source_connection_idstring | nullSource connection scope, if any.
created_atstringISO 8601 creation timestamp.
updated_atstring | nullISO 8601 last update timestamp.
linksobjectRelated resource URLs (self).

Response (201 Created)

{
  "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
  "name": "Route contracts to legal schema",
  "trigger_type": "document_classified",
  "conditions": { "field": "document_type", "operator": "eq", "value": "contract" },
  "action_type": "route_to_schema",
  "actions": { "type": "assign_schema", "schema_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901" },
  "priority": 100,
  "is_active": true,
  "review_required": false,
  "source_connection_id": null,
  "created_at": "2024-09-15T14:00:00.000Z",
  "updated_at": null,
  "links": {
    "self": "/v1/routing-rules/c3d4e5f6-a7b8-9012-cdef-123456789012"
  }
}

Errors

Error responses

401unauthorizedMissing or invalid API key.
429rate_limitedToo many requests. Retry after the period indicated in the Retry-After header.