> ## 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.
# Overview
> Create, version, generate, and publish Intent Rules through the public API.
Intent Rules are the workflows configured under [Automations → Intent Rules](/en/automations/rulebook). They use the `/v2/hc-rules` API family and have their own draft, version, publish, restore, and test-path lifecycle.
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
| Method | Path | Scope | Purpose |
| - | - | - | - |
| `GET` | `/v2/hc-rules/public` | `read` | List rules. Use `versionStatus` or `includeVersions` to select lifecycle data. |
| `GET` | `/v2/hc-rules/fields-context/public` | `read` | Get available fields. |
| `GET` | `/v2/hc-rules/:id/public` | `read` | Get a draft or published rule tree. |
| `POST` | `/v2/hc-rules/public` | `write` | Create with `status: "DRAFT"` or `"PUBLISHED"`. |
| `PATCH` | `/v2/hc-rules/:id/public` | `write` | Create a new draft or published version. |
| `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. |
| `DELETE` | `/v2/hc-rules/:id/versions/:versionId/public` | `write` | Delete one unpublished draft version. |
| `GET` | `/v2/hc-rules/:id/versions/:versionId/test-paths/public` | `read` | Generate deterministic paths through one saved version. |
| `POST` | `/v2/hc-rules/:id/versions/:versionId/test-paths/run/public` | `read` | Run one generated path against a saved version. |
| `POST` | `/v2/hc-rules/test-paths/config/public` | `read` | Generate deterministic paths from an unsaved flow config. |
| `POST` | `/v2/hc-rules/test-paths/config/run/public` | `read` | Run one generated path against an unsaved flow config. |
| `DELETE` | `/v2/hc-rules/:id/public` | `write` | Delete the rule and its agent assignments. |
## 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>
<Step title="Discard drafts you do not want to publish">
Call [Delete intent-rule draft version](/en/api-reference/delete-rule-draft-version) to remove an unpublished draft version from normal version-history reads.
</Step>
<Step title="Generate and run path tests">
Call [Get rule version test paths](/en/api-reference/get-rule-version-test-paths) to derive paths from the version, then call [Run rule version test path](/en/api-reference/run-rule-version-test-path) with the selected `pathId` and expected terminal node.
</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 include `id`, `companyId`, `name`, `description`, `flowConfig`, `botIds`, and lifecycle fields such as `version`, `versionId`, `status`, `parentVersionId`, `publishedAt`, `isStale`, and `currentPublishedVersionId`.
## Related topics
- [Overview](/en/api-reference/tags.md)
This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.
Intent Rules

