# Mail Api
### Api reference
#### Prepare request:
Setting headers is not required but it looks better.
- **Accept: application/json** as default each incoming request had forced this header
- **Content-Type: application/json** request body always should be passed as json
* **Accept-Language: en** currently supported is *pl* and *en*, any other will return flags instead of translated strings.
#### Body:
Each endpoint required these 2 parameters:
- **project** (string) project name
- **email** (string) user email
any other parameter will be saved as **payload**.
Additionally if project configuration allows to add a attachment it should be passed under key **attachment**.
#### Endpoints:
- **[POST /send]()**
- **[POST /subscribe]()**
- **[POST /unsubscribe]()**
#### ReCaptcha:
When project has set reCaptcha configuration, it will be with parameter additional **g-recaptcha-response** in body. __If this is first user request in last 60 seconds, recaptcha will not be validated!__
#### RateLimit:
The app allows to send the request on the same endpoint up to 5 per minute.
---
### Example:
```js
import axios from 'axios';
// Project name and api url are always the same
const baseUrl = 'https://mail-api.blockchainhouse.co';
const projectName = 'test';
// Now collect variables from
let userEmail = document.getElementById('email').value;
let message = document.getElementById('message').value;
// Send data to
axios.post(baseUrl + '/send', {
params: {
// Add required properties to body
project: projectName,
email: userEmail,
// and now some additional data
message: message,
}
})
.then(function () {
console.log('Message was sent successfully!')
})
.catch(function (error) {
console.log('Message was not sent!');
console.error(error.response.body);
});
```
---
### Projects configuration
We have 2 commands to this:
- `php artisan projects:add`
- `php artisan projects:dump`
use option `--help` to read more about them.