
## Search addresses

`POST /v1/addresses/search`

Search addresses with filters and auto-pagination. Equivalent to `GET /v1/addresses`, but parameters are passed in the request body — suitable for complex filters with many conditions and for programmatic query building.

## Request fields (body)

| Parameter | Type | Default | Description |
|----------|-----|-----------|---------|
| `filter` | object | — | Filtering by the fields of `GET /v1/addresses/fields`.<br>[Filtering syntax](/docs/filtering). Example: `{ "entityTypeId": 8, "entityId": 42 }` |
| `limit` | number | `50` | Number of records (up to 5000) |
| `offset` | number | `0` | Skip N records |
| `sort` | object | — | Sorting: `{ "typeId": "asc" }` |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/addresses/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "entityTypeId": 1, "city": "Springfield" },
    "limit": 20
  }'
```

### curl — OAuth app

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/addresses/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "entityTypeId": 1, "city": "Springfield" },
    "limit": 20
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/addresses/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { entityTypeId: 1, city: 'Springfield' },
    limit: 20,
  }),
})

const { success, data } = await res.json()
console.log('Found:', data.length)
```

### JavaScript — OAuth app

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/addresses/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { entityTypeId: 1, city: 'Springfield' },
    limit: 20,
  }),
})

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

### Other scenarios

All addresses of a single requisite:

```json
{
  "filter": { "entityTypeId": 8, "entityId": 42 }
}
```

Addresses of a specific type for a lead:

```json
{
  "filter": { "entityTypeId": 1, "entityId": 1000755, "typeId": 1 }
}
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of addresses (all fields — see [Address fields](/docs/entities/addresses/fields)) |
| `meta.total` | number | Total number of records matching the filter |
| `meta.hasMore` | boolean | Whether there are more records beyond `limit` |

The `meta` fields sit next to `data`, not inside it. Pages must be walked by `meta.hasMore`: a `data` length equal to `limit` does not rule out the last page.

## Response example

```json
{
  "success": true,
  "data": [
    {
      "typeId": 1,
      "entityTypeId": 1,
      "entityId": 1000755,
      "address1": "123 Main St",
      "address2": "Suite 5",
      "city": "Springfield",
      "postalCode": "62701",
      "region": "Sangamon County",
      "province": "Illinois",
      "country": "United States",
      "countryCode": null,
      "locAddrId": 483,
      "anchorTypeId": 1,
      "anchorId": 1000755
    },
    {
      "typeId": 1,
      "entityTypeId": 1,
      "entityId": 1000759,
      "address1": "97 Oak Ave",
      "address2": "office 5",
      "city": "Springfield",
      "postalCode": "62704",
      "region": "Sangamon County",
      "province": "Illinois",
      "country": "United States",
      "countryCode": null,
      "locAddrId": 491,
      "anchorTypeId": 1,
      "anchorId": 1000759
    }
  ],
  "meta": {
    "total": 107,
    "hasMore": true
  }
}
```

## Error response example

403 — no scope:

```json
{
  "success": false,
  "error": {
    "code": "SCOPE_DENIED",
    "message": "This endpoint requires 'crm' scope"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 403 | `SCOPE_DENIED` | The API key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 400 | `INVALID_FILTER` | Error in the filter syntax |

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

## Known specifics

**Field names in the filter are camelCase.** Pass `typeId`, `entityTypeId`, `entityId`, `city`, `postalCode`, `countryCode` — the same names the `GET /v1/addresses/fields` schema returns.

## See also

- [List addresses](/docs/entities/addresses/list)
- [Address fields](/docs/entities/addresses/fields)
- [Filtering syntax](/docs/filtering)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
