# Creates a user

`POST /users.json`

Authentication: no security requirement declared for this operation.

Parameters:

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

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

Request body: application/json

Type: any

- `name` (required)
  Type: string

- `email` (required)
  Type: string

- `password` (required)
  Type: string

- `username` (required)
  Type: string

- `active` (optional)
  Type: boolean
  
  This param requires an admin api key in the request
  header or it will be ignored

- `approved` (optional)
  Type: boolean

- `user_fields` (optional)
  Type: object
  
  - `1` (optional)
    Type: boolean
  
  Additional properties: true

- `external_ids` (optional)
  Type: object

Additional properties: false

Responses:

- 200: user created

Content type: application/json

Type: any

- `success` (required)
  Type: boolean

- `active` (required)
  Type: boolean

- `message` (required)
  Type: string

- `user_id` (optional)
  Type: integer

Additional properties: false

## Examples

### cURL

```bash
curl -X POST 'https://discourse.example.com/users.json' \
  -H 'Api-Key: string' \
  -H 'Api-Username: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "string",
  "email": "string",
  "password": "string",
  "username": "string",
  "active": true,
  "approved": true,
  "user_fields": {
    "1": true
  },
  "external_ids": {}
}'
```

### JavaScript

```javascript
const body = `{
  "name": "string",
  "email": "string",
  "password": "string",
  "username": "string",
  "active": true,
  "approved": true,
  "user_fields": {
    "1": true
  },
  "external_ids": {}
}`;

const response = await fetch('https://discourse.example.com/users.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 = '''{
  "name": "string",
  "email": "string",
  "password": "string",
  "username": "string",
  "active": true,
  "approved": true,
  "user_fields": {
    "1": true
  },
  "external_ids": {}
}'''

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