---
title: "Switch the active agency"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.nicer.travel/llms.txt
> Use this file to discover all available pages before exploring further.

# Switch the active agency

Path: Nicer API › identity

`POST /identity/company/{companyName}/switch`

URL: `https://api.nicer.travel/identity/company/{companyName}/switch`

Makes an agency the one the caller acts for: checks they are an active member with portal access (Nicer staff enter any agency, a suspended one included), writes it as their active company and role on their account and publishes the switch. The portal refreshes its token afterwards. Any signed-in person, for themself. Errors: 400 COMPANY_NOT_AVAILABLE for an agency there is not or one that is suspended, 400 ERROR_UNAUTHORIZED for an agency the caller is not an active member of or whose portal is closed to them.

## Authentication

- `bearerAuth`, http bearer, header `Authorization`, format `JWT`

## Path parameters

- `companyName` (`identity.company.switch.path.companyName`; string, required)

## Code samples

### JavaScript SDK

```javascript
import { createClient } from "@nicertravel/sdk";

const nicer = createClient({
  baseUrl: "https://api.nicer.travel",
  token: process.env.NICER_TOKEN,
});

await nicer.identity.company.switch({
  "companyName": "string"
});
```

### Nicer CLI

```bash
nicer identity company switch --company-name 'string'
```

### cURL

```bash
curl --request POST \
  --url 'https://api.nicer.travel/identity/company/<companyName>/switch' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/identity/company/<companyName>/switch';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.nicer.travel/identity/company/<companyName>/switch"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "companyName": "string",
  "message": "string"
}
```

- `companyName` (`identity.company.switch.response.200.companyName`; string, required)
- `message` (`identity.company.switch.response.200.message`; string, required)

### 400

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`identity.company.switch.response.400.errorCode`; string, required)
- `errorMessage` (`identity.company.switch.response.400.errorMessage`; string, required)

### 401

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`identity.company.switch.response.401.errorCode`; string, required)
- `errorMessage` (`identity.company.switch.response.401.errorMessage`; string, required)

### 403

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`identity.company.switch.response.403.errorCode`; string, required)
- `errorMessage` (`identity.company.switch.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/identity/identity.company.switch/index.md
