# Register a new user

`POST /api/auth/register`

Authentication: no security requirement declared for this operation.

Parameters:

- `origin` (header, string, required)
  Type: string

Request body: application/json (required)

Type: object

Schema: [RegisterUserDTO](https://sourcey-gauzy.pages.dev/api-reference/models/registeruserdto/index.md)

- `password` (required)
  Type: string

- `confirmPassword` (required)
  Type: string

- `user` (required)
  Reference: [CreateUserDTO](https://sourcey-gauzy.pages.dev/api-reference/models/createuserdto/index.md); Type: object

- `organizationId` (optional)
  Type: string

- `createdByUserId` (optional)
  Type: string

- `featureAsEmployee` (optional)
  Type: boolean

- `terms` (optional)
  Type: array
  
  Items:
    Reference: [TermsAcceptanceClaimDTO](https://sourcey-gauzy.pages.dev/api-reference/models/termsacceptanceclaimdto/index.md); Type: object

- `stripeCheckoutSessionId` (optional)
  Type: string
  
  Stripe Checkout Session id (cs_live_... / cs_test_...)

Responses:

- 201: The record has been successfully created.

- 400: Invalid input, the response body may contain clues as to what went wrong

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/auth/register' \
  -H 'origin: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "password": "string",
  "confirmPassword": "string",
  "user": {
    "email": "string",
    "roleId": "string",
    "role": {},
    "firstName": "string",
    "lastName": "string",
    "imageUrl": "string",
    "preferredLanguage": "en"
  },
  "organizationId": "string",
  "createdByUserId": "string",
  "featureAsEmployee": true,
  "terms": [
    {
      "documentId": "tos:gauzy",
      "version": "1.0.0",
      "sha256": "string",
      "locale": "en"
    }
  ],
  "stripeCheckoutSessionId": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "password": "string",
  "confirmPassword": "string",
  "user": {
    "email": "string",
    "roleId": "string",
    "role": {},
    "firstName": "string",
    "lastName": "string",
    "imageUrl": "string",
    "preferredLanguage": "en"
  },
  "organizationId": "string",
  "createdByUserId": "string",
  "featureAsEmployee": true,
  "terms": [
    {
      "documentId": "tos:gauzy",
      "version": "1.0.0",
      "sha256": "string",
      "locale": "en"
    }
  ],
  "stripeCheckoutSessionId": "string"
}`;

const response = await fetch('http://localhost:3000/api/auth/register', {
  method: 'POST',
  headers: {
    'origin': 'string',
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "password": "string",
  "confirmPassword": "string",
  "user": {
    "email": "string",
    "roleId": "string",
    "role": {},
    "firstName": "string",
    "lastName": "string",
    "imageUrl": "string",
    "preferredLanguage": "en"
  },
  "organizationId": "string",
  "createdByUserId": "string",
  "featureAsEmployee": true,
  "terms": [
    {
      "documentId": "tos:gauzy",
      "version": "1.0.0",
      "sha256": "string",
      "locale": "en"
    }
  ],
  "stripeCheckoutSessionId": "string"
}'''

response = requests.post(
    'http://localhost:3000/api/auth/register',
    data=body.encode('utf-8'),
    headers={
        'origin': 'string',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
