# Registration

Operations related to tenant & user registration with PromptEasy.eu API.

## Get a list of countries

`GET /v1/countries`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key

Responses:

- 200: A list of countries

Content type: application/json

Type: array

Items:
  Reference: [Country](https://api.prompteasy.eu/docs/api/models/country/index.md); Type: object

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/countries' \
  -H 'X-Api-Key: YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/countries', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
  },
});

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

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/countries',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
    },
)
print(response.text)
```


## Verify if an email domain is academic

`GET /v1/academic/verify`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key

Parameters:

- `email` (query, string, email, required)
  Type: string, email

Responses:

- 200: Verification result

Content type: application/json

Type: object

- `is_academic` (optional)
  Type: boolean

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/academic/verify?email=user%40example.com' \
  -H 'X-Api-Key: YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/academic/verify?email=user%40example.com', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
  },
});

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

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/academic/verify?email=user%40example.com',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
    },
)
print(response.text)
```


## Register a new user and tenant

`POST /v1/register`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key

Request body: application/json (required)

Type: object

Schema: [RegisterRequest](https://api.prompteasy.eu/docs/api/models/registerrequest/index.md)

- `name` (required)
  Type: string
  
  Example:
  
  ```json
  "John Doe"
  ```

- `email` (required)
  Type: string
  
  Example:
  
  ```json
  "foo@bar.invalid"
  ```

- `tenant_name` (optional)
  Type: string
  
  Example:
  
  ```json
  "Acme Inc."
  ```

- `tenant_email` (optional)
  Type: string
  
  Example:
  
  ```json
  "foo@bar.invalid"
  ```

- `country_code` (required)
  Type: string
  
  Example:
  
  ```json
  "BE"
  ```

- `is_individual` (required)
  Type: boolean
  
  Example:
  
  ```json
  false
  ```

- `postal_code` (optional)
  Type: string
  
  Example:
  
  ```json
  12345
  ```

- `vat_id` (optional)
  Type: string
  
  Example:
  
  ```json
  "BE1234567890"
  ```

- `plan_type` (required)
  Type: string
  
  Example:
  
  ```json
  "premium"
  ```

- `promotion_code` (optional)
  Type: string; nullable
  
  Example:
  
  ```json
  "PROMO50"
  ```

- `terms_accepted` (required)
  Type: boolean
  
  Example:
  
  ```json
  true
  ```

Responses:

- 200: Registration completed successfully

Content type: application/json

Type: object

- `message` (optional)
  Type: string
  
  Example:
  
  ```json
  "Registration completed."
  ```

- 422: Unprocessable Entity

Content type: application/json

Type: object

Schema: [ValidationError](https://api.prompteasy.eu/docs/api/models/validationerror/index.md)

- `message` (optional)
  Type: string
  
  Example:
  
  ```json
  "Validation failed"
  ```

- `errors` (optional)
  Reference: [ValidationErrorErrors](https://api.prompteasy.eu/docs/api/models/validationerrorerrors/index.md); Type: object

## Examples

### cURL

```bash
curl -X POST 'https://api.prompteasy.eu/v1/register' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "John Doe",
  "email": "foo@bar.invalid",
  "tenant_name": "Acme Inc.",
  "tenant_email": "foo@bar.invalid",
  "country_code": "BE",
  "is_individual": false,
  "postal_code": 12345,
  "vat_id": "BE1234567890",
  "plan_type": "premium",
  "promotion_code": "PROMO50",
  "terms_accepted": true
}'
```

### JavaScript

```javascript
const body = `{
  "name": "John Doe",
  "email": "foo@bar.invalid",
  "tenant_name": "Acme Inc.",
  "tenant_email": "foo@bar.invalid",
  "country_code": "BE",
  "is_individual": false,
  "postal_code": 12345,
  "vat_id": "BE1234567890",
  "plan_type": "premium",
  "promotion_code": "PROMO50",
  "terms_accepted": true
}`;

const response = await fetch('https://api.prompteasy.eu/v1/register', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "name": "John Doe",
  "email": "foo@bar.invalid",
  "tenant_name": "Acme Inc.",
  "tenant_email": "foo@bar.invalid",
  "country_code": "BE",
  "is_individual": false,
  "postal_code": 12345,
  "vat_id": "BE1234567890",
  "plan_type": "premium",
  "promotion_code": "PROMO50",
  "terms_accepted": true
}'''

response = requests.post(
    'https://api.prompteasy.eu/v1/register',
    data=body.encode('utf-8'),
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
