# POST /api/v1/brex/cards/mapping/bulk

> Preview or apply many Brex card mappings at once

- **Tag:** brex
- **Operation ID:** `bulk_map_brex_cards`

## Description

Map several cards, or every card of a cardholder, to credit lines.

**Request Body:**
- `items`: each names the card (`brex_card_id`, `last_four`, or
  `card_holder_name` for all of that holder's cards) and the line
  (`credit_line_id`, or `line_ref` matched exactly)
- `apply`: `false` previews; `true` maps, and only when every row resolves

**Note:** same access rule as mapping one card: on a live business a
signed-in operator, or an API token minted with the `credit:mapping`
scope.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `BrexBulkMapRequest`

- `items` (array · BrexBulkMapItem · required) → `BrexBulkMapItem`
  - `row` (integer) — The row number to report back (file row for CSV).
  - `brex_card_id` (string)
  - `last_four` (string) — The card's last 4; must identify exactly one card.
  - `card_holder_name` (string) — Alone: every card this cardholder owns. With last_four: narrows it.
  - `credit_line_id` (string)
  - `line_ref` (string) — The line's external line id, external merchant id or merchant name, matched exactly (case aside); it must name exactly one line.
- `apply` (boolean) — false previews; true maps, only when every row resolves.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_BrexBulkMapResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (BrexBulkMapResponse)

### 400 — Bad Request - Invalid input

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/brex/cards/mapping/bulk' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "items": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/brex/cards/mapping/bulk', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "items": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {'items': []}

response = httpx.post("https://api.ondayzero.com/api/v1/brex/cards/mapping/bulk", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/brex/bulk-map-brex-cards
- OpenAPI slice: https://www.ondayzero.com/docs/reference/brex/bulk-map-brex-cards/openapi.json
- Other endpoints in **brex**: https://www.ondayzero.com/docs/reference/brex (markdown bundle: https://www.ondayzero.com/docs/reference/brex.md, OpenAPI: https://www.ondayzero.com/docs/reference/brex/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
