
## Update an automation rule

`PATCH /v1/bizproc-robots/:code`

Updates the fields of a registered automation rule. Fields are passed flat at the JSON root — without a `fields` wrapper.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `code` (path) | string | yes | The automation rule code set at registration |

## Request fields (body)

| Field | Type | Description |
|------|-----|---------|
| `name` | string \| object | Automation rule name. A string or a localized object like `{"en": "...", "de": "..."}` |
| `handler` | string | Handler URL. The domain must match the application domain |
| `documentType` | array | Document type `[module, object, type]`. Values:<br>`["crm", "CCrmDocumentLead", "LEAD"]` — leads<br>`["crm", "CCrmDocumentDeal", "DEAL"]` — deals<br>`["crm", "Bitrix\\Crm\\Integration\\BizProc\\Document\\Quote", "QUOTE"]` — quotes<br>`["crm", "Bitrix\\Crm\\Integration\\BizProc\\Document\\SmartInvoice", "SMART_INVOICE"]` — invoices<br>`["crm", "Bitrix\\Crm\\Integration\\BizProc\\Document\\Dynamic", "DYNAMIC_<entityTypeId>"]` — smart processes, `<entityTypeId>` from the `entityTypeId` field in [GET /v1/smart-processes](/docs/entities/smart-processes/list) |
| `description` | string \| object | Automation rule description. A string or a localized object |
| `authUserId` | number | The user whose token is passed to the application when the automation rule is invoked. List: `GET /v1/users` |
| `useSubscription` | string | Whether to wait for a response from the application before continuing the rule: `Y` or `N` |
| `properties` | object | Automation rule input parameters |
| `returnProperties` | object | Automation rule output parameters |
| `filter` | object | Limits which documents the automation rule is available for. An empty object `{}` removes the restriction.<br>`INCLUDE` lists the conditions under which the automation rule is available, `EXCLUDE` those under which it is not. A condition is a document type prefix, for example `["crm", "CCrmDocumentDeal"]`, or a Bitrix24 edition: `"b24"` for cloud, `"box"` for on-premise.<br>Example: `{"INCLUDE": [["crm", "CCrmDocumentDeal"], ["crm", "CCrmDocumentLead"]]}`.<br>Write the keys in uppercase: with lowercase keys the field is accepted but restricts nothing. A value that is not an object returns `422 BITRIX_ERROR` |
| `usePlacement` | string | Whether to open the automation rule settings in a slider panel: `Y` or `N` |
| `placementHandler` | string | URL of the settings slider panel. Required when `usePlacement: "Y"` |

## Examples

Only an OAuth application key can update an automation rule — both examples send an OAuth application key and the `Authorization: Bearer` header. The session token is issued by OAuth authorization, is valid for 24 hours, and cannot be renewed — [Passing the key](/docs/keys-auth#passing-the-key).

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/bizproc-robots/deal_notify" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": { "en": "Deal notification v2", "de": "Deal-Benachrichtigung v2" },
    "handler": "https://app.example.com/robots/deal-notify-v2"
  }'
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bizproc-robots/deal_notify', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: { en: 'Deal notification v2', de: 'Deal-Benachrichtigung v2' },
    handler: 'https://app.example.com/robots/deal-notify-v2',
  }),
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | string | The code of the updated automation rule — matches the `code` from the path |

## Response example

```json
{
  "success": true,
  "data": {
    "id": "deal_notify"
  }
}
```

## Error response example

422 — an automation rule with the given code was not found:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Activity or Robot not found!",
    "b24Code": "ERROR_ACTIVITY_NOT_FOUND"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 403 | `OAUTH_REQUIRED` | The request was sent with an API key. Only an authorization key can update automation rules |
| 401 | `TOKEN_MISSING` | The authorization key was sent without the `Authorization: Bearer` header |
| 401 | `WRONG_AUTH_SCHEME` | The authorization key was sent in the `Authorization: Bearer` header. The key goes in `X-Api-Key`, while `Authorization: Bearer` carries the session token |
| 401 | `INVALID_SESSION` | The session token has expired or is invalid — authorize again |
| 403 | `SCOPE_DENIED` | The key lacks the `bizproc` scope |
| 400 | `SERVER_APP_MISMATCH` | The new `handler` points to a Black Hole subdomain that has no server of this app behind it — the subdomain does not exist, or the server belongs to another app |
| 409 | `BIZPROC_MODULE_NOT_ENABLED` | Business Processes are not available on the account: the module is not included in the plan, or it is switched off in account settings. Ask an account administrator to enable Business Processes — until then the method answers the same way for any number of retries |
| 503 | `BIZPROC_CALLBACK_RESOLVE_FAILED` | The platform could not match the handler to a server. The automation rule was not updated — retry the request |
| 422 | `BITRIX_ERROR` | Bitrix24 did not find an automation rule with the given code or rejected the update — the reason is in `error.message` |

The full list of common API errors — [Errors](/docs/errors).

## Known specifics

**Moving the handler to a Black Hole subdomain switches the automation rule to reliable delivery.** Moving back to an address on your own domain restores direct calls without retries, and a request without the `handler` field leaves the binding unchanged. A switch to a subdomain must be sent as a single request — [Activity and automation rule callback delivery](/docs/infra/bizproc-callbacks).

## See also

- [Register an automation rule](/docs/entities/bizproc-robots/create)
- [Delete an automation rule](/docs/entities/bizproc-robots/delete)
- [Activity and automation rule callback delivery](/docs/infra/bizproc-callbacks)
- [Keys and authorization](/docs/keys-auth)
