# Merge a user

`POST /admin/users/{id}/merge.json`

Merge a user into another user. Requires admin permissions. The
source user cannot be a staff member. The merge runs in the background and
deletes the source user when complete.

Authentication: no security requirement declared for this operation.

Parameters:

- `Api-Key` (header, string, required)
  Type: string

- `Api-Username` (header, string, required)
  Type: string

- `id` (path, integer, required) - ID of the user to merge
  Type: integer

Request body: application/json

Type: any

- `target_username` (required)
  Type: string
  
  Username of the user to merge into

Additional properties: false

Responses:

- 200: response

Content type: application/json

Type: any

- `success` (required)
  Type: string
  
  Example:
  
  ```json
  "OK"
  ```

Additional properties: false

## Examples

### cURL

```bash
curl -X POST 'https://discourse.example.com/admin/users/0/merge.json' \
  -H 'Api-Key: string' \
  -H 'Api-Username: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "target_username": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "target_username": "string"
}`;

const response = await fetch('https://discourse.example.com/admin/users/0/merge.json', {
  method: 'POST',
  headers: {
    'Api-Key': 'string',
    'Api-Username': 'string',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "target_username": "string"
}'''

response = requests.post(
    'https://discourse.example.com/admin/users/0/merge.json',
    data=body.encode('utf-8'),
    headers={
        'Api-Key': 'string',
        'Api-Username': 'string',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
