---
title: "Read a rule"
method: GET
path: "/email-rules/{id}"
tags: ["Email Rules"]
---

# Read a rule

`GET /email-rules/{id}`

## Request

- Base URL: `https://api.primitive.dev/v1`
- URL: `https://api.primitive.dev/v1/email-rules/{id}`
- Auth: HTTP bearer

A rule and its current version. The SQL the version renders to is included only when include_sql is true. Needs mail:read, a credential acting as a member with their full access (API keys, agent keys and narrowed tokens are refused), and the email rules feature on the organization.

## Path parameters

- `id` string, uuid, required

## Query parameters

- `include_sql` 'true' | 'false'

## Response `200`

Read a rule

- object
  - `success` true, required
  - `data` GetEmailRuleResult, required
    - `id` string, uuid, required
    - `name` string, required
    - `state` 'draft' | 'observe' | 'active', required
    - `current_version` integer, nullable, required
    - `author_user_id` string, uuid, required
    - `is_author` boolean, required: Whether the caller wrote the rule (under their current membership). Only the author edits a rule; anyone else who can see it may only disable or delete it.
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required
    - `current` object, nullable, required
      - `version` integer, required
      - `english` string, required
      - `tree` object, required
        - `version` 1, required
        - `vocabulary` string, required: The column contract version the rule is written against, for example v1.
        - `when` object, required: The rule's conditions: a condition ({column, op, value?, min_confidence?}) or a group ({all: [...]}, {any: [...]} or {not: ...}).
        - `questions` string[], required: Yes/no questions of the rule's own, asked about an email only after its conditions match. An email matches only if every answer is yes.
      - `explanation` string, required
      - `assumptions` string[], required
      - `warnings` string[], required
      - `compiled_by` string, required
      - `vocabulary` string, required
      - `created_at` string, date-time, required
      - `sql` object: Present only when include_sql was true.
        - `expression` string, required: A parameterized boolean expression over one row per email.
        - `params` unknown[], required: The values bound to $1, $2 and so on.
          - unknown

## Other responses

- `400`: Invalid request parameters
- `401`: Invalid or missing API key
- `403`: Authenticated caller lacks permission for the operation
- `404`: Resource not found
- `429`: Rate limit exceeded. The `ratelimit-*` headers describe the limiter that rejected this request, with its own limit and window, not the API budget that successful responses report. A limiter that reports only a wait sends `Retry-After` alone.

---

[API](https://skmtc.dev/primitive/apis/primitive-api.md) - [All operations](https://skmtc.dev/primitive/apis/primitive-api/llms.txt) - [OpenAPI document](https://skmtc.dev/primitive/apis/primitive-api/revisions/bce409c97acb?raw)
