> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usefini.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Intent Rules

> Create, version, generate, and publish Rulebook intent rules through the public API.

Intent rules are the workflows configured under [Automations → Rulebook](/en/automations/rulebook). Send `type: "intent"` when creating them and `type=intent` when listing them.

Intent rules have a version lifecycle. A rule can have a current published version, draft versions, and archived historical versions. Drafts have no agent assignments and do not run in production until published.

## Intent-rule endpoints

### Endpoints shared with Business Rules

| Method   | Path                                 | Scope   | Intent-rule usage                                                                           |
| -------- | ------------------------------------ | ------- | ------------------------------------------------------------------------------------------- |
| `GET`    | `/v2/hc-rules/public`                | `read`  | List with `type=intent`. Use `versionStatus` or `includeVersions` to select lifecycle data. |
| `GET`    | `/v2/hc-rules/fields-context/public` | `read`  | Get available fields with `type=intent`.                                                    |
| `GET`    | `/v2/hc-rules/:id/public`            | `read`  | Get a draft or published rule tree.                                                         |
| `POST`   | `/v2/hc-rules/public`                | `write` | Create with `type: "intent"` and `status: "DRAFT"` or `"PUBLISHED"`.                        |
| `PATCH`  | `/v2/hc-rules/:id/public`            | `write` | Create a new draft or published version.                                                    |
| `DELETE` | `/v2/hc-rules/:id/public`            | `write` | Delete the rule and its agent assignments.                                                  |

### Intent-only endpoints

| Method | Path                                                           | Scope   | Purpose                                                                                |
| ------ | -------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------- |
| `POST` | `/v2/hc-rules/generate/public`                                 | `write` | Use natural-language instructions and an LLM to generate or refine draft rule content. |
| `GET`  | `/v2/hc-rules/:id/versions/public`                             | `read`  | List draft, published, and archived versions.                                          |
| `GET`  | `/v2/hc-rules/:id/versions/:versionId/public`                  | `read`  | Get one version with its full tree.                                                    |
| `POST` | `/v2/hc-rules/:id/publish/public`                              | `write` | Publish a selected draft version and assign agents.                                    |
| `POST` | `/v2/hc-rules/:id/versions/:versionId/restore-as-draft/public` | `write` | Copy any historical version into a new draft.                                          |

## Typical draft workflow

<Steps>
  <Step title="Generate the draft content">
    Call [Generate intent-rule draft with AI](/en/api-reference/generate-intent-rule-draft) with natural-language instructions. The LLM returns a draft name, description, and rule tree. The response is not persisted yet.
  </Step>

  <Step title="Create the draft">
    Call [Create intent rule](/en/api-reference/create-intent-rule) with `status: "DRAFT"` and the generated fields or your own tree. Do not send `botIds` for a draft.
  </Step>

  <Step title="Update the draft">
    Call [Update intent rule](/en/api-reference/update-intent-rule) with `status: "DRAFT"`. Sending the status explicitly prevents an existing published version from being updated instead.
  </Step>

  <Step title="Publish and assign">
    Read the draft's `versionId`, then call [Publish rule draft](/en/api-reference/publish-rule-draft) with that `draftVersionId` and at least one agent ID.
  </Step>
</Steps>

<Warning>
  A draft becomes stale when its `parentVersionId` no longer matches the current published version. The publish route rejects stale drafts. Restore or recreate the draft from the current version before publishing.
</Warning>

## Intent-rule response fields

Intent-rule responses use the shared [`Rule`](/en/api-reference/rules#rule-object) shape and add lifecycle fields such as `version`, `versionId`, `status`, `parentVersionId`, `publishedAt`, `isStale`, and `currentPublishedVersionId`.
