# Registration

## Face Registration Flow in the Container

To perform a face registration in the Container, the client will send a POST route to the endpoint `/api/v1/cadastro` in JSON format, containing: face for registration in base64, client ID (accessible in the portal), ID of the user to be registered, Liveness Parameter enabled ("ativarLiveness": true) or Liveness Parameter disabled ("ativarLiveness": false) and the token. The data will be sent to the Facesign API endpoint in JSON format:

```json
{
"face":"/9j/4DAWLFK...",
"clientid":"658cc36e-XXXX-XXXX-XXXX-29711f9566aa",
"id":"cli0001",
"ativarLiveness":true/false,
"token":"0002221"
}

```

This JSON will be sent to the Facesign API, where the ID will be checked to see if it already exists in the system.

* In case the ID is already registered, the return will be:

```json
{
"clientid":"658cc36e-XXXX-XXXX-XXXX-29711f9566aa",
"id":"cli0001",
"status":"user already registered"
}

```

* If the ID is not registered, the user's face will go through the Liveness and registration process.

### Registration with Liveness Parameter disabled

With the Liveness Parameter disabled, the registration (positive or negative) will be returned regardless of the Liveness result, and may have the following returns:

* Face already registered in the Container

*Code 400 - Error*

```json
{
    "type":"Error",
    "content":{
        "ClientId":"9eec5efd-XXXX-XXXX-XXXX-1f689615d3be",
        "Id":"id001",
        "Status":"Face already exists with another Id",
        "Liveness":true/false,
        "TransactionId":"9992ac53-XXXX-XXXX-XXXX-e1ac621521d7"
    }
}
```

* Registration completed

*Code 200 - Success*

```json
{
    "type":"Success",
    "content":{
        "ClientId":"9eec5efd-XXXX-XXXX-XXXX-1f689615d3be",
        "Id":"id010",
        "Status":"User successfully registered",
        "Liveness":true/false,
        "TransactionId":"f02c924a-XXXX-XXXX-XXXX-ed2ba3c35821",
 "Face": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQF..."
    }
}
```

### Registration with Liveness Parameter enabled

With the Liveness Parameter enabled, the face will be registered in the Container with a positive Liveness return, and may have the following returns:

* Liveness *true* and face already registered

*Code 400 - Error*

```json
{
    "type":"Error",
    "content":{
        "ClientId":"9eec5efd-XXXX-XXXX-XXXX-1f689615d3be",
        "Id":"id001",
        "Status":"Face already exists with another Id",
        "Liveness":true,
        "TransactionId":"9992ac53-XXXX-XXXX-XXXX-e1ac621521d7"
    }
}
```

* Liveness *true and* registration completed

*Code 200 - Success*

<pre class="language-json"><code class="lang-json">{
    "type":"Success",
    "content":{
        "ClientId":"9eec5efd-XXXX-XXXX-XXXX-1f689615d3be",
        "Id":"id010",
        "Status":"User successfully registered",
        "Liveness":true,
        "TransactionId":"f02c924a-XXXX-XXXX-XXXX-ed2ba3c35821",
 "Face":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQF..."
<strong>    }
</strong>}
</code></pre>

* Liveness *false*

*Code 400 - Error*

```json
{
    "type":"Error",
    "content":{
        "ClientId":"9eec5efd-XXXX-XXXX-XXXX-1f689615d3be",
        "Id":"id010",
        "Status":"Registration not completed",
        "Liveness":false,
        "TransactionId":"0fcb3937-XXXX-XXXX-XXXX-488edf3b3b08"
    }
}
```
