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

# Publish rule draft

> Publish a draft rule and assign it to one or more agents.

Publishes one draft [`Rule`](/en/api-reference/rules#rule-object) and assigns it to one or more agents.

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

## Path parameters

<ParamField path="id" type="string" required>
  Draft rule ID to publish.
</ParamField>

## Body parameters

<ParamField body="botIds" type="string[]" required>
  Agent IDs to assign after publishing. At least one ID is required.
</ParamField>

## Response

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

## Errors

<AccordionGroup>
  <Accordion title="400 Bad Request" icon="circle-exclamation">
    The body is malformed, the `botIds` array is empty, or one or more agent IDs do not belong to your workspace.
  </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="404 Not Found" icon="ghost">
    The draft rule ID does not exist in your workspace, or it is no longer a draft.
  </Accordion>

  <Accordion title="500 Internal Server Error" icon="triangle-exclamation">
    Fini failed while publishing the draft or syncing agent assignments.
  </Accordion>
</AccordionGroup>
