# Create new record

`POST /api/smtp`

Authentication (security requirement alternatives):

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

- bearer: http (bearer), header JWT. Enter JWT token

Request body: application/json (required)

Type: object

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

- `fromAddress` (required)
  Type: string
  
  Examples:
  
  ```json
  [
    "noreply@domain.com"
  ]
  ```

- `host` (required)
  Type: string
  
  Examples:
  
  ```json
  [
    "smtp.postmarkapp.com",
    "smtp.gmail.com"
  ]
  ```

- `port` (required)
  Type: number
  
  Examples:
  
  ```json
  [
    587,
    465
  ]
  ```

- `secure` (required)
  Type: boolean
  
  Examples:
  
  ```json
  [
    true,
    false
  ]
  ```

- `isValidate` (optional)
  Type: boolean
  
  default: false

- `organizationId` (optional)
  Type: string

- `username` (required)
  Type: string

- `password` (required)
  Type: string

Responses:

- 201: The record has been successfully created.

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

- 401: Unauthorized

- 403: Forbidden

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/smtp' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "fromAddress": "noreply@domain.com",
  "host": "smtp.postmarkapp.com",
  "port": 587,
  "secure": true,
  "isValidate": false,
  "organizationId": "string",
  "username": "string",
  "password": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "fromAddress": "noreply@domain.com",
  "host": "smtp.postmarkapp.com",
  "port": 587,
  "secure": true,
  "isValidate": false,
  "organizationId": "string",
  "username": "string",
  "password": "string"
}`;

const response = await fetch('http://localhost:3000/api/smtp', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "fromAddress": "noreply@domain.com",
  "host": "smtp.postmarkapp.com",
  "port": 587,
  "secure": true,
  "isValidate": false,
  "organizationId": "string",
  "username": "string",
  "password": "string"
}'''

response = requests.post(
    'http://localhost:3000/api/smtp',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
