2019-08-14 16:42:15 +02:00
# API DOCUMENTATION
## General
### Automation key
2019-09-02 16:06:46 +02:00
The authentication of the automation is performed via a secure key available in the D4 UI interface. Make sure you keep that key secret. It gives access to the entire database! The API key is available in the ``Settings`` menu under ``My Profile``.
2019-08-14 16:42:15 +02:00
The authorization is performed by using the following header:
~~~~
Authorization: YOUR_API_KEY
~~~~
### Accept and Content-Type headers
When submitting data in a POST, PUT or DELETE operation you need to specify in what content-type you encoded the payload. This is done by setting the below Content-Type headers:
~~~~
Content-Type: application/json
~~~~
Example:
~~~~
2019-09-02 16:06:46 +02:00
curl --header "Authorization: YOUR_API_KEY" --header "Content-Type: application/json" https://D4_URL/
2019-08-14 16:42:15 +02:00
~~~~
2019-09-02 16:06:46 +02:00
## Sensor Registration
2019-08-14 16:42:15 +02:00
2019-09-02 16:06:46 +02:00
### Register a sensor: `api/v1/add/sensor/register`<a name="add_sensor_register"></a>
2019-08-14 16:42:15 +02:00
#### Description
2019-09-02 16:06:46 +02:00
Register a sensor.
2019-08-14 16:42:15 +02:00
**Method** : `POST`
#### Parameters
- `uuid`
- sensor uuid
- *uuid4*
- mandatory
- `hmac_key`
- sensor secret key
- *binary*
- mandatory
- `description`
- sensor description
- *str*
2019-09-02 16:06:46 +02:00
- `mail`
- user mail
- *str*
2019-08-14 16:42:15 +02:00
#### JSON response
- `uuid`
- sensor uuid
- *uuid4*
#### Example
```
curl https://127.0.0.1:7000/api/v1/add/sensor/register --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input .json -X POST
```
#### input.json Example
```json
{
2019-09-02 16:06:46 +02:00
"uuid": "ff7ba400-e76c-4053-982d-feec42bdef38",
"hmac_key": "...HMAC_KEY..."
2019-08-14 16:42:15 +02:00
}
```
#### Expected Success Response
**HTTP Status Code** : `200`
```json
{
2019-09-02 16:06:46 +02:00
"uuid": "ff7ba400-e76c-4053-982d-feec42bdef38",
2019-08-14 16:42:15 +02:00
}
```
#### Expected Fail Response
**HTTP Status Code** : `400`
```json
{"status": "error", "reason": "Mandatory parameter(s) not provided"}
2019-09-02 16:06:46 +02:00
{"status": "error", "reason": "Invalid uuid"}
```
**HTTP Status Code** : `409`
```json
{"status": "error", "reason": "Sensor already registred"}
2019-08-14 16:42:15 +02:00
```