# Restricted Requests
---

!!!
The token used in this requests is of specific usage and can't be generated by our [Authentication](auth) request. To get access to such token, please get in contact with us via [chat](https://suporte.monuv.com.br/pt-BR/), [Whatsapp](https://monuv.cam/whatsapp) or [e-mail](suporte@monuv.com.br).

!!!

### Create Clients

- Path: https://app.monuv.com.br/api/v1/clients?token={token}
- Method: POST

#### Parameters:
Name | Type | Description | Required
:--- | :---: | :--- | :---:
token | String | user's Monuv token <b>(is a query string parameter)</b> | :icon-check:
name   | String | The name of the Client | :icon-check:
document_type | Integer | The document type of the Client <br> 1 = CPF <br> 2 = CNPJ | :icon-check:
document_number | String | The document number of the Client | :icon-check:
phone | String | The phone of the Client | :icon-check:
cep | String | CEP of the Client | :icon-check:
address | String | Address of the Client | :icon-check:
address_number | String | The address number of the Client | :icon-check:
address_comp | String | The address complement of the Client | :icon-x:
address_nh | String | The neighborhood of the Client | :icon-check:
city | String | The city of the Client | :icon-check:
state | String | The state of the Client | :icon-check:
users | List | After creating the client, a user will be created in the client <br> A list of objects ([Same rules of create user](#create-client-users)) | :icon-check:
#### Response:
Status code  | Description
:---   | :---
[!badge icon="check-circle-fill" text="201" variant="success"] | Client created successfully
[!badge icon="alert-fill" text="400" variant="warning"] | Bad Request
[!badge icon="alert-fill" text="422" variant="warning"] | Unprocessable Entity
[!badge icon="x-circle-fill" text="500" variant="danger"] | Internal Error

=== Success Response Body:
```json
[
    {
		"id": 1,
		"name": "Client name",
		"document_type": "2",
		"document_number": "99.999.999/9999-99",
		"phone": "(11) 99999-9999",
		"cep": "00000-000",
		"address": "Rua Teste",
		"address_number": "99",
		"address_nh": "Bairro",
		"city": "São Paulo",
		"state": "São Paulo",
		"create_url": "https://my.site.com",
		"create_ip": "127.0.0.1",
		"updated_at": "2023-01-01 12:00:00",
		"created_at": "2023-01-01 12:00:00",
		"users": [ // if passed information for user creation
			{
				"id": 2,
				"user_type_id": 6,
				"name": "My Name",
				"email": "my@email.com.br",
				"phone": "11999999999",
				"updated_at": "2023-01-01 12:00:00",
				"created_at": "2023-01-01 12:00:00",
				"update_user_id": 1,
				"api_token": "TOKEN"
			}
		]
	}
]
```
===
### Create Client Users

- Path: https://app.monuv.com.br/api/v1/clients/{client_id}/users?token={token}
- Method: POST 
#### Parameters:
Name | Type | Description | Required
:--- | :---: | :--- | :---:
token | String | user's Monuv token <b>(is a query string parameter)</b> | :icon-check:
name | String | The name of the User | :icon-check:
email | String | The e-mail of The User | :icon-check:
phone | String | The phone of the User | :icon-check:
user_type | Integer | 1 = COMUM <br> 2 = ADMIN | :icon-check:
password | String | The password of the User | :icon-check:
password_conf | String | Confirmation of the user's password, must be equal to the value of the password field | :icon-check:

#### Response:
Status code  | Description
:---   | :---
[!badge icon="check-circle-fill" text="201" variant="success"] | Client user created successfully
[!badge icon="alert-fill" text="400" variant="warning"] | Bad Request
[!badge icon="alert-fill" text="422" variant="warning"] | Unprocessable Entity
[!badge icon="x-circle-fill" text="500" variant="danger"] | Internal Error

=== Success Response Body:
```json
[
    {
		"id": 2,
		"user_type_id": 6, // 6 = Client
		"name": "user name",
		"email": "user@email.com.br",
		"phone": "(11) 99999-9999",
		"updated_at": "2023-01-01 12:00:00",
		"created_at": "2023-01-01 12:00:00",
		"update_user_id": 1
	}
]
```
===
### Block/Unblock partner's clients

Gives and revokes access to certain [partner's clients](https://app.monuv.com.br/client)

- Block Path: https://app.monuv.com.br/api/client/block/{token}/{document}
- Unblock Path: https://app.monuv.com.br/api/client/unblock/{token}/{document}
- Method: GET

#### Parameters:
Name   |  Type | Description | Required
:---   | :---: | :--- | :---:
token  | String  | partners token| :icon-check:
document | String | partner's clients document (CPF or CNPJ, numbers only) | :icon-check:

#### Response:
Name   |  Type | Description 
:---   | :---: | :--- 
CODE  | String  | return code
MSG  | String  | in case of error, related error message

```json
{
    "code": 0,
    "msg": ""
}
```
#### Code example
+++ cURL
```sh
curl --location 'https://app.monuv.com.br/api/client/block/{token}/{document}'
```

+++ node
```node
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();

let config = {
		method: 'get',
		maxBodyLength: Infinity,
		url: 'https://app.monuv.com.br/api/client/block/{token}/{document}',
};

axios.request(config)
.then((response) => {
		console.log(JSON.stringify(response.data));
})
.catch((error) => {
		console.log(error);
});
```
+++ python
```python
import requests

url = "https://app.monuv.com.br/api/client/block/{token}/{document}"

response = requests.request("GET", url)

print(response.text)
```
+++
---

### Block/Unblock Users

Gives and revokes access to certain users

- Block User Path: https://app.monuv.com.br/api/user/block/{token}/{id}
- Unblock User Path: https://app.monuv.com.br/api/user/unblock/{token}/{id}
- Method: GET

#### Parameters:
Name   |  Type | Description | Required
:---   | :---: | :--- | :---:
token  | String  | user token | :icon-check:
id | String | user id | :icon-check:

#### Response:
Name   |  Type | Description 
:---   | :---: | :--- 
CODE  | String  | return code
MSG  | String  | in case of error, related error message

```json
{
    "code": 0,
    "msg": ""
}
```
#### Code example
+++ cURL to block
```sh
curl --location 'https://app.monuv.com.br/api/user/block/{token}/{id}'
```

+++ cURL to unblock
```sh
curl --location 'https://app.monuv.com.br/api/user/unblock/{token}/{id}'
```

+++ node
```node
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();

let config = {
		method: 'get',
		maxBodyLength: Infinity,
		url: 'https://app.monuv.com.br/api/user/block/{token}/{id}',
};

axios.request(config)
.then((response) => {
		console.log(JSON.stringify(response.data));
})
.catch((error) => {
		console.log(error);
});
```
+++ python
```python
import requests

url = "https://app.monuv.com.br/api/user/block/{token}/{id}"

response = requests.request("GET", url)

print(response.text)
```
+++
---

### Information to Create/Update cameras

Retrieve informations necessary to create/update a camera

- Path: https://app.monuv.com.br/api/v1/cameras/create?token={token}
- Method: GET

#### Parameters:
Name | Type | Description | Required
:--- | :---: | :--- | :---:
token | String | user's Monuv token <b>(is a query string parameter)</b> | :icon-check:

#### Response:
Status code  | Description
:---   | :---
[!badge icon="check-circle-fill" text="200" variant="success"] | Success
[!badge icon="x-circle-fill" text="500" variant="danger"] | Internal Error

=== Success Response Body:
```json
{
	"manufacturer": [
		{
			"id": 5,
			"name": "Hikvision",
			"camera_model": [
				{
					"id": 6,
					"name": "Câmera IP",
					"manufacturer_id": 5
				},
				{
					"id": 25,
					"name": "DVR",
					"manufacturer_id": 5
				},
				...
			]
		},
		{
			"id": 22,
			"name": "Generico",
			"camera_model": [
				{
					"id": 39,
					"name": "Camera IP",
					"manufacturer_id": 22
				},
				{
					"id": 40,
					"name": "DVR",
					"manufacturer_id": 22
				}
			]
		},
		...
	],
	"plans": {
		"history_days": [
			1,
			3,
			7,
			...
		],
		"resolutions": [
			{
				"id": 1,
				"name": "VGA"
			},
			...
		]
	},
	"installation_info": {
		"installation_local": {
			"1": "Privado (dentro de dependências privadas)",
			"2": "Público (ruas, praças, etc)"
		},
		"installation_area": {
			"1": "Área interna",
			"2": "Área externa"
		},
		"equipment_state": {
			"1": "Câmera\/DVR novo",
			"2": "Câmera\/DVR pré-existente"
		}
	}
}
```
---

### Create Cameras
- Path: https://app.monuv.com.br/api/v1/cameras?token={token}
- Method: POST

#### Parameters:
Name | Type | Description | Required
:--- | :---: | :--- | :---:
token | String | user's Monuv token <b>(is a query string parameter)</b> | :icon-check:
description | String | The name of the Camera | :icon-check:
camera_address | String | The address of the Camera | :icon-check:
latitude | String | The latitude of the camera address | :icon-check:
longitude | String | The longitude of the camera address | :icon-check:
connection_type | Integer | The Camera connection type <br> 0 = RTSP <br> 1 = RTMP <br> 2 = P2P | :icon-check:
resolution_id | Integer | The Camera resolution ID <br> <i>To consult the list of available resolution, see: [Information to create cameras](/api/restricted_reqs/#information-to-createupdate-cameras) </i> | :icon-check:
history_days | Integer | Number of days that camera recordings will be stored <br> <i>To consult the available list, see: [Information to create cameras](/api/restricted_reqs/#information-to-createupdate-cameras) </i> | :icon-check:
client_id | Integer | The camera owner Client ID | :icon-check:
channel | Integer | DVR Channel number (Camera RTSP) | :icon-x:
model_id | Integer | Camera Model Identifier <br> <i>To consult the list of available models, see: [Information to create cameras](/api/restricted_reqs/#information-to-createupdate-cameras) </i> | Required when connection_type is <b>0 (RTSP)</b>
dns | String | DNS or IP to access camera video stream | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
port | String | Network port to access camera video stream | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
user | String | Camera RTSP user | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
pass | String | Camera RTSP password | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
typed_url | String | Full camera RTSP URL | :icon-x:
stream | String | Camera stream type <br> 0 = Main <br> 1 = Secondary | Required when connection_type is <b>0 (RTSP)</b> or <b>2 (P2P)</b>
p2p_serial_number | String | Camera P2P Serial Number | Required when connection_type is <b>2 (P2P)</b>
p2p_password | String | Camera P2P password | Required when connection_type is <b>2 (P2P)</b>
sound | Integer | Enable camera sound recording and reproduction (For RTMP and P2P only - Ensure camera is set o AAC Audio Codec) <br> 0 = Disabled <br> 1 = Enabled <br>| :icon-x:

!!!
`demo` is no longer supported on camera API v1. If sent, it will be treated as `0` (false). `client_id` is always required.
!!!

#### Response:
Status code  | Description
:---   | :---
[!badge icon="check-circle-fill" text="201" variant="success"] | Camera created successfully
[!badge icon="alert-fill" text="400" variant="warning"] | Bad Request
[!badge icon="alert-fill" text="422" variant="warning"] | Unprocessable Entity
[!badge icon="x-circle-fill" text="500" variant="danger"] | Internal Error

=== Success Response Body:
```json
[
    {
		"id": 1,
		"description": "My camera",
		"stream_status": 2,
		"status_description": "OFFLINE",
		"rtmp_url": "rtmp://rtmp.monuv.com.br/my.stream"
	}
]
```
---

### Update Cameras
- Path: https://app.monuv.com.br/api/v1/cameras/{id}?token={token}
- Method: PUT

#### Parameters:
Name | Type | Description | Required
:--- | :---: | :--- | :---:
token | String | user's Monuv token <b>(is a URL parameter)</b> | :icon-check:
id | String | Id camera <b>(is a query string parameter)</b> | :icon-check:
description | String | The name of the Camera | :icon-check:
camera_address | String | The address of the Camera | :icon-check:
latitude | String | The latitude of the camera address | :icon-check:
longitude | String | The longitude of the camera address | :icon-check:
connection_type | Integer | The Camera connection type <br> 0 = RTSP <br> 1 = RTMP <br> 2 = P2P | :icon-check:
resolution_id | Integer | The Camera resolution ID <br> <i>To consult the list of available resolution, see: [Information to update cameras](/api/restricted_reqs/#information-to-createupdate-cameras) </i> | :icon-check:
history_days | Integer | Number of days that camera recordings will be stored <br> <i>To consult the available list, see: [Information to update cameras](/api/restricted_reqs/#information-to-createupdate-cameras) </i> | :icon-check:
client_id | Integer | The camera owner Client ID | :icon-check:
channel | Integer | DVR Channel number (Camera RTSP) | :icon-x:
model_id | Integer | Camera Model Identifier <br> <i>To consult the list of available models, see: [Information to update cameras](/api/restricted_reqs/#information-to-createupdate-cameras) </i> | Required when connection_type is <b>0 (RTSP)</b>
dns | String | DNS or IP to access camera video stream | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
port | String | Network port to access camera video stream | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
user | String | Camera RTSP user | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
pass | String | Camera RTSP password | Required when connection_type is <b>0 (RTSP)</b> or <b>typed_url</b> is not defined
typed_url | String | Full camera RTSP URL | :icon-x:
stream | String | Camera stream type <br> 0 = Main <br> 1 = Secondary | Required when connection_type is <b>0 (RTSP)</b> or <b>2 (P2P)</b>
p2p_serial_number | String | Camera P2P Serial Number | Required when connection_type is <b>2 (P2P)</b>
p2p_password | String | Camera P2P password | Required when connection_type is <b>2 (P2P)</b>
sound | Integer | Enable camera sound recording and reproduction (For RTMP and P2P only - Ensure camera is set o AAC Audio Codec) <br> 0 = Disabled <br> 1 = Enabled <br>| :icon-x:

!!!
`demo` is no longer supported on camera API v1. If sent, it will be treated as `0` (false). `client_id` is always required.
!!!

#### Response:
Status code  | Description
:---   | :---
[!badge icon="check-circle-fill" text="201" variant="success"] | Camera updated successfully
[!badge icon="alert-fill" text="400" variant="warning"] | Bad Request
[!badge icon="alert-fill" text="422" variant="warning"] | Unprocessable Entity
[!badge icon="x-circle-fill" text="500" variant="danger"] | Internal Error

=== Success Response Body:
```json
[
    {
		"id": 1,
		"description": "My camera",
		"stream_status": 2,
		"status_description": "OFFLINE",
		"rtmp_url": "rtmp://rtmp.monuv.com.br/my.stream"
	}
]
```
### List Events

Return a paginated list of events

- Path: https://app.monuv.com.br/api/v1/events?token={token}
- Method: GET

#### Parameters:
Name | Type | Description | Required
:--- | :---: | :--- | :---:
token | String | user's Monuv token <b>(is a query string parameter)</b> | :icon-check:
event_types | String | List of event type IDs (The ids must be separated by a comma, e.g.: 1,4) <br> 1 = Alerta Câmera  <br> 2 = Pânico <br> 4 = Detecção Presença/Ausência <br> 5 = Detecção Movimento <br> 7 = LPR <br> 13 = Anomalia | :icon-x:
camera | int | Camera ID | :icon-x:
start_at | string | filter events by start date (Y-m-d) | :icon-check:
end_at | string | filter events by end date (Y-m-d) | :icon-check:
page | int | Pagination page number | :icon-x: <br> (Default 1)

#### Response:
Status code  | Description
:---   | :---
[!badge icon="check-circle-fill" text="200" variant="success"] | OK
[!badge icon="x-circle-fill" text="500" variant="danger"] | Internal Error

=== Success Response Body:
```json
[
    {
		"total": 100, // total events
		"per_page": 30, // Event per page
		"current_page": 1,
		"last_page": 4,
		"data": [
			{
				"id": 1,
				"event_at": "01/01/2023 12:00:00",
				"event_type": 4,
				"event_description": "Detecção Presença/Ausência",
				"event_url": "https://detection.monuv.com.br/IMAGE_PATH.jpg",
				"camera_id": 1001,
				"camera_description": "My Camera"
			},
			...
		]
	}
]
```
===
#### Code example:
+++ cURL
```sh
curl --request GET \
  --url 'https://app.monuv.com.br/api/v1/events?camera=1001&event_types=1%2C4&start_at=2023-01-01&end_at=2023-01-02&page=2&token={TOKEN}'
```

+++ node
```node
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();

axios.get('https://app.monuv.com.br/api/v1/events', {
	'camera': 1001,
	'event_types': '1,4',
	'start_at': '2023-01-01',
	'end_at': '2023-01-02',
	'page': 2
})
.then((response) => {
		console.log(JSON.stringify(response.data));
})
.catch((error) => {
		console.log(error);
});
```
+++ python
```python
import requests

url = "https://app.monuv.com.br/api/v1/events"

params = {
	'camera': 1001,
	'event_types': '1,4',
	'start_at': '2023-01-01',
	'end_at': '2023-01-02',
	'page': 2
}

response = requests.get(url, params)

print(response.json())
```
+++
---
