
## Move a binding

`POST /v1/activities/:activityId/bindings/move`

Moves the activity's binding from one CRM entity to another of the same type: the old binding is removed and the new one is created in a single call.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `activityId` (path) | number | yes | Activity ID. List: `GET /v1/activities` |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| **`sourceEntityTypeId`** | number | yes | Numeric type code of the source entity:<br>1 — lead<br>2 — deal<br>3 — contact<br>4 — company<br>7 — quote<br>31 — invoice<br>≥128 — smart-process, its code — in [`GET /v1/smart-processes`](/docs/entities/smart-processes/list) |
| **`sourceEntityId`** | number | yes | ID of the source entity |
| **`targetEntityTypeId`** | number | yes | Numeric type code of the target entity. Must equal `sourceEntityTypeId` |
| **`targetEntityId`** | number | yes | ID of the target entity |

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/activities/3631/bindings/move \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "sourceEntityTypeId": 3, "sourceEntityId": 9, "targetEntityTypeId": 3, "targetEntityId": 17 }'
```

### curl — OAuth app

```bash
curl -X POST https://vibecode.bitrix24.com/v1/activities/3631/bindings/move \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "sourceEntityTypeId": 3, "sourceEntityId": 9, "targetEntityTypeId": 3, "targetEntityId": 17 }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/activities/3631/bindings/move', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    sourceEntityTypeId: 3,
    sourceEntityId: 9,
    targetEntityTypeId: 3,
    targetEntityId: 17,
  }),
})

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

### JavaScript — OAuth app

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/activities/3631/bindings/move', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    sourceEntityTypeId: 3,
    sourceEntityId: 9,
    targetEntityTypeId: 3,
    targetEntityId: 17,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.activityId` | number | Activity ID |
| `data.sourceEntityTypeId` | number | Numeric type code of the source entity |
| `data.sourceEntityId` | number | ID of the source entity |
| `data.targetEntityTypeId` | number | Numeric type code of the target entity |
| `data.targetEntityId` | number | ID of the target entity |
| `data.moved` | boolean | Always `true` — confirmation of the move |

## Response example

```json
{
  "success": true,
  "data": {
    "activityId": 3631,
    "sourceEntityTypeId": 3,
    "sourceEntityId": 9,
    "targetEntityTypeId": 3,
    "targetEntityId": 17,
    "moved": true
  }
}
```

## Error response example

422 — source and target entities are of different types:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Source and target entity types are not equal"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `activityId` or any of the `source*` / `target*` fields is not a positive integer |
| 404 | `ENTITY_NOT_FOUND` | No activity exists for the given `activityId` |
| 422 | `BITRIX_ERROR` | The source entity type does not match the target entity type |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

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

## Known specifics

**Move works only within one type.** To move an activity to an entity of a different type, `move` does not apply — do it in two steps:

1. Bind the activity to the second entity — [`POST /v1/activities/:activityId/bindings`](/docs/entities/activities/bindings/bind).
2. Remove the binding from the first — [`DELETE /v1/activities/:activityId/bindings`](/docs/entities/activities/bindings/unbind).

This order does not break the ban on removing the last binding — the activity stays bound to at least one entity the whole time.

## See also

- [Bind](/docs/entities/activities/bindings/bind)
- [Unbind](/docs/entities/activities/bindings/unbind)
- [List bindings](/docs/entities/activities/bindings/list)
