---
title: "Create a standing delegation"
method: POST
path: "/api/assistant/rules"
tags: ["Mailzero Assistant"]
---

# Create a standing delegation

`POST /api/assistant/rules`

## Request

- Base URL: `https://domani.run`
- URL: `https://domani.run/api/assistant/rules`
- Auth: HTTP bearer

Hand a kind of matter to an agent or a person once. `match` is an explicit predicate, never a model call: any of senderAddress, senderDomain, organisation, workKeyPrefix, senderKind, mailboxIds, labels, subjectPattern (anchored, case-insensitive), minOccurrences, minConfidence (the calibrated classifier's probability on a category: label, 0.5 to 1); every stated condition must hold. Rules are ordered and the first match wins; the level is observe unless said otherwise. A matching rule hands the next matching item to the assignee, tells it through the delegation notice, and Today shows why. Requires `assistant:write`; an agent token is refused.

## Request body

- AssistantRuleInput
  - `name` string
  - `enabled` boolean
  - `position` integer: Rules are tried in this order; the first match wins
  - `match` AssistantRuleMatch: The explicit predicate of a standing delegation; every stated condition must hold
    - `senderAddress` string: The sender's address
    - `senderDomain` string: The sender's domain; a subdomain matches too
    - `organisation` string: The organisation label of the sender's domain, for example tucows
    - `workKeyPrefix` string: The work item key starts with this, for example org:tucows or auto:
    - `senderKind` 'human' | 'automated'
    - `mailboxIds` string[]
    - `labels` string[]: The matter carries any of these labels: category:<kind> is its kind of matter (CT-01), tag:<name> one of the person's tags (CT-01b)
    - `subjectPattern` string: An anchored, case-insensitive pattern on the subject
    - `minOccurrences` integer: Only recurring matters: at least this many occurrences
    - `minConfidence` number: Only when the calibrated classifier put at least this probability on one of the rule's category: labels; without its answer the rule does not match
  - `assignee_type` 'agent' | 'member'
  - `assignee_ref` string: The agent identity slug, or the member's user id
  - `level` 'observe' | 'triage' | 'draft' | 'guarded_send' | 'operate': The autonomy granted; observe by default
  - `grants` AssistantGrants: Caps on the effects of a level: who an outward effect may reach, how many effects a day, when, how much model spend, which risk classes without an approver, and a required approver. On a rule and on an assignee, the stricter wins
    - `recipients` object
      - `mode` 'correspondents' | 'domains' | 'anyone', required: The matter's correspondents (the default), listed domains, or anyone
      - `domains` string[]
    - `volume` object
      - `effects_per_day` integer, required
    - `schedule` object
      - `hours` integer[]: Start (inclusive) and end (exclusive) hour
      - `days` integer[]: Sunday is zero
      - `timezone` string: An IANA zone; UTC when absent
    - `spend` object
      - `usd_per_day` number
      - `usd_per_matter` number
    - `risk` object
      - `allow` string[]: Risk classes the assignee may act on; none by default
      - `financial_threshold_usd` number: Amounts below this do not make a matter financial
    - `approver` object
      - `member_id` string, required

## Response `201`

The rule

- AssistantRule: A standing delegation: a kind of matter handed to an agent or a person once, with its autonomy level
  - `id` string, required
  - `name` string, required
  - `enabled` boolean, required
  - `position` integer, required
  - `match` AssistantRuleMatch, required: The explicit predicate of a standing delegation; every stated condition must hold
    - `senderAddress` string: The sender's address
    - `senderDomain` string: The sender's domain; a subdomain matches too
    - `organisation` string: The organisation label of the sender's domain, for example tucows
    - `workKeyPrefix` string: The work item key starts with this, for example org:tucows or auto:
    - `senderKind` 'human' | 'automated'
    - `mailboxIds` string[]
    - `labels` string[]: The matter carries any of these labels: category:<kind> is its kind of matter (CT-01), tag:<name> one of the person's tags (CT-01b)
    - `subjectPattern` string: An anchored, case-insensitive pattern on the subject
    - `minOccurrences` integer: Only recurring matters: at least this many occurrences
    - `minConfidence` number: Only when the calibrated classifier put at least this probability on one of the rule's category: labels; without its answer the rule does not match
  - `assignee` object, required
    - `type` 'agent' | 'member', required
    - `ref` string, required
    - `name` string, nullable
  - `level` 'observe' | 'triage' | 'draft' | 'guarded_send' | 'operate', required
  - `grants` AssistantGrants: Caps on the effects of a level: who an outward effect may reach, how many effects a day, when, how much model spend, which risk classes without an approver, and a required approver. On a rule and on an assignee, the stricter wins
    - `recipients` object
      - `mode` 'correspondents' | 'domains' | 'anyone', required: The matter's correspondents (the default), listed domains, or anyone
      - `domains` string[]
    - `volume` object
      - `effects_per_day` integer, required
    - `schedule` object
      - `hours` integer[]: Start (inclusive) and end (exclusive) hour
      - `days` integer[]: Sunday is zero
      - `timezone` string: An IANA zone; UTC when absent
    - `spend` object
      - `usd_per_day` number
      - `usd_per_matter` number
    - `risk` object
      - `allow` string[]: Risk classes the assignee may act on; none by default
      - `financial_threshold_usd` number: Amounts below this do not make a matter financial
    - `approver` object
      - `member_id` string, required
  - `match_count` integer, required
  - `last_matched_at` string, date-time, nullable
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: Invalid rule or match predicate
- `401`: Missing or invalid API key
- `404`: No such agent or member
- `409`: A hundred rules is the most an account carries
- `429`: Rate limit exceeded - wait and retry

---

[API](https://skmtc.dev/domani/apis/domani-run-api.md) · [All operations](https://skmtc.dev/domani/apis/domani-run-api/llms.txt) · [OpenAPI document](https://skmtc.dev/domani/apis/domani-run-api/revisions/7679f8159533?raw)
