# POST /api/v1/xero/switch-tenant

> Switch active Xero tenant

- **Tag:** xero
- **Operation ID:** `switch_tenant_api_v1_xero_switch_tenant_post`

## Description

Re-pick which Xero organization is bound to this business without disconnecting/reconnecting.

## Authentication

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

## Request body

Schema: `XeroSwitchTenantRequest`

- `tenant_id` (string · required) — Xero tenantId to switch to

## Responses

### 201 — Successful Response

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/xero/switch-tenant' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "tenant_id": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/xero/switch-tenant', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "tenant_id": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "tenant_id": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/xero/switch-tenant", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/xero/switch-tenant
- OpenAPI slice: https://www.ondayzero.com/docs/reference/xero/switch-tenant/openapi.json
- Other endpoints in **xero**: https://www.ondayzero.com/docs/reference/xero
