
## Update a command

`PATCH /v1/bots/:botId/commands/:commandId`

Updates the parameters of an existing command. Vibecode accepts a flat format and automatically wraps it into `fields` for Bitrix24.

## Request fields (body)

| Parameter | Type | Description |
|----------|-----|---------|
| `command` | string | New command text without `/` |
| `title` | string/object | New title. A string or `{ "ru": "...", "en": "..." }`. Passing `null` for a key removes the translation: `{ "en": null }` |
| `params` | string/object | New parameters description. A string or an object |
| `common` | string | `"Y"` / `"N"` |
| `hidden` | string | `"Y"` / `"N"` |
| `extranetSupport` | string | `"Y"` / `"N"` |

## Examples

### curl — personal key

```bash
curl -X PATCH https://vibecode.bitrix24.com/v1/bots/42/commands/7 \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": { "en": "Updated help", "de": "Aktualisierte Hilfe" },
    "common": "Y"
  }'
```

### curl — OAuth application

```bash
curl -X PATCH https://vibecode.bitrix24.com/v1/bots/42/commands/7 \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": { "en": "Updated help", "de": "Aktualisierte Hilfe" },
    "common": "Y"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/commands/7', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: { en: 'Updated help', de: 'Aktualisierte Hilfe' },
    common: 'Y',
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/commands/7', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: { en: 'Updated help', de: 'Aktualisierte Hilfe' },
    common: 'Y',
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `data.command.id` | number | Command ID |
| `data.command.botId` | number | Bot ID |
| `data.command.command` | string | Command name with the `/` prefix |
| `data.command.common` | boolean | Available in all chats, not only in the dialog with the bot |
| `data.command.hidden` | boolean | Hidden from the autocomplete hint |
| `data.command.extranetSupport` | boolean | Available to extranet users |

## Response example

```json
{
  "success": true,
  "data": {
    "command": {
      "id": 189,
      "botId": 42,
      "command": "/help",
      "common": true,
      "hidden": false,
      "extranetSupport": false
    }
  }
}
```

## Error response example

404 — bot not found:

```json
{
  "success": false,
  "error": {
    "code": "BOT_NOT_FOUND",
    "message": "Bot 999 not found. Register it first via POST /v1/bots."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_BOT_ID` | `botId` is not a number |
| 404 | `BOT_NOT_FOUND` | No bot found with this ID |
| 403 | `BOT_ACCESS_DENIED` | The bot belongs to a different API key |
| 502 | `BITRIX_ERROR` | Bitrix24 error (error text in `message`) |
| 403 | `SCOPE_DENIED` | API key lacks the `imbot` scope |
| 401 | `TOKEN_MISSING` | API key has no configured tokens |

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

## Known specifics

**Removing a translation:** pass `null` for a language key: `{ "title": { "en": null } }` — removes the English translation while keeping the rest.

**String flags:** `common`, `hidden`, `extranetSupport` accept the strings `"Y"` / `"N"` (not boolean).

## See also

- [Register a command](/docs/bots/commands/register)
- [Delete a command](/docs/bots/commands/delete)
- [Bot platform](/docs/bots)
- [Limits and optimization](/docs/optimization)
