> ## 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.

# Create rule

> Create a published rule.

Creates a published [`Rule`](/en/api-reference/rules#rule-object).

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token containing your Fini workspace API key. Format: `Bearer fini_...` The key needs `write` scope.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Body parameters

<ParamField body="name" type="string" required>
  Rule name.
</ParamField>

<ParamField body="description" type="string" required>
  Natural-language routing description. This is the text the planner uses when deciding whether the rule should run.
</ParamField>

<ParamField body="flowConfig" type="RuleNodeConfig">
  Optional rule tree. See [Rules](/en/api-reference/rules#rulenodeconfig-object) for the shared transport shape.
</ParamField>

<ParamField body="botIds" type="string[]">
  Optional agent IDs to assign after creation.
</ParamField>

<ParamField body="type" type="string">
  Optional rule type. Current values are `intent` and `business`. Send it explicitly rather than relying on the current default.
</ParamField>

<ParamField body="source" type="string">
  Optional source. Current public enum value is `widget`.
</ParamField>

<ParamField body="triggerType" type="string">
  Optional trigger type. Current public enum value is `on_escalation`.
</ParamField>

<ParamField body="defaultRuleId" type="string">
  Optional template rule ID.
</ParamField>

<ParamField body="inputSchema" type="InputSchemaField[]">
  Optional runtime input schema. See [Rules](/en/api-reference/rules#inputschemafield-object).
</ParamField>

## Response

Returns the created [`Rule`](/en/api-reference/rules#rule-object).

## Errors

<AccordionGroup>
  <Accordion title="400 Bad Request" icon="circle-exclamation">
    The body is malformed, a referenced agent ID is invalid, or the `flowConfig` references a missing or unsupported action or widget form.
  </Accordion>

  <Accordion title="401 Unauthorized" icon="lock">
    The API key is missing, malformed, revoked, or invalid.
  </Accordion>

  <Accordion title="403 Forbidden" icon="shield-halved">
    The API key does not include the `write` scope required for this route.
  </Accordion>

  <Accordion title="500 Internal Server Error" icon="triangle-exclamation">
    Fini failed while creating the rule in storage.
  </Accordion>
</AccordionGroup>
