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

# Update politics

> Update fields by replacement and/or granular array operations

The endpoint accepts two kinds of fields in the same body:

1. **Replacement fields** (`name`, `description`, `rules`, `knowledgeFiles`,
   `contactNotifications`, `outputFormat`) overwrite the stored value.
2. **Granular operations** (`addRules`, `removeRules`, `updateRule`,
   `addKnowledgeFiles`, `removeKnowledgeFiles`, `addContactNotifications`,
   `removeContactNotifications`) mutate the current array without requiring the
   client to send the full value.

Replacement and granular ops on the same array are applied in that order:
first the replacement, then the granular ops.

`updatedAt` is always refreshed.

## Path parameters

<ParamField path="id" type="string" required>
  24-character hex ObjectId of the politics.
</ParamField>

## Headers

<ParamField header="api-token" type="string" required />

## Body — replacement fields

<ParamField body="name" type="string" />

<ParamField body="description" type="string" />

<ParamField body="rules" type="Rule[]">
  Must be non-empty when provided.
</ParamField>

<ParamField body="knowledgeFiles" type="File[]">
  Same validation as on create.
</ParamField>

<ParamField body="contactNotifications" type="string[]" />

<ParamField body="outputFormat" type="object" />

## Body — granular operations

<ParamField body="addRules" type="Rule[]">
  Append one or more rules to the end of the array.
</ParamField>

<ParamField body="removeRules" type="integer[]">
  Indices (0-based) of rules to remove.
</ParamField>

<ParamField body="updateRule" type="object">
  Modify one rule in place.

  <Expandable title="updateRule">
    <ParamField body="index" type="integer" required />

    <ParamField body="name" type="string" />

    <ParamField body="description" type="string" />
  </Expandable>
</ParamField>

<ParamField body="addKnowledgeFiles" type="File[]" />

<ParamField body="removeKnowledgeFiles" type="integer[]">
  Indices to remove.
</ParamField>

<ParamField body="addContactNotifications" type="string[]" />

<ParamField body="removeContactNotifications" type="string[]">
  Exact string match is used to decide which entries to drop.
</ParamField>

## Response

<ResponseField name="success" type="boolean" />

<ResponseField name="data" type="Politics">The updated document.</ResponseField>

<RequestExample>
  ```bash Replace name + add rule theme={null}
  curl -X PATCH "https://api.dabarai.com/v1/politics/69aa51d188c08a82d22fb2d8" \
    -H "api-token: YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "BP Rules v2",
      "addRules": [{ "name": "R5", "description": "New rule" }]
    }'
  ```

  ```bash Remove two rules theme={null}
  curl -X PATCH "https://api.dabarai.com/v1/politics/69aa51d188c08a82d22fb2d8" \
    -H "api-token: YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{ "removeRules": [0, 3] }'
  ```

  ```bash Update rule in place theme={null}
  curl -X PATCH "https://api.dabarai.com/v1/politics/69aa51d188c08a82d22fb2d8" \
    -H "api-token: YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{ "updateRule": { "index": 1, "description": "Updated" } }'
  ```
</RequestExample>
