> For the complete documentation index, see [llms.txt](https://portal-integracao.intelbras.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://portal-integracao.intelbras.com.br/linha-de-faciais/primeiros-passos/cadastro-de-faces.md).

# Cadastro de Faces

### Cadastrar Facial

**Para cadastrar a face de um usuário, siga as instruções a baixo:**

```mermaid
graph TD;
A[Cadastre um usuário e obtenha seu UserID];
B[Capture a foto do usuário, certifique-se que 
ela possua os requisitos mínimos de cadastro];
C[Inclua no corpo da requisição anterior um JSON  
com o UserID e os dados da foto em PhotoData]
D[Envie a requisição utilizando autenticação digest]
E[Retorno de confirmação 'OK']
A --> B;
B --> C;
C --> D;
D --> E;
```

* A foto capturada deve estar respeitando os **critérios**;
* Certifique-se de que a foto esteja convertida para o formato Base64;
* Crie um objeto JSON que contenha os dados necessários para o cadastro:

| param         | type   | description             |
| ------------- | ------ | ----------------------- |
| `UserID`\*    | String | Representa o ID do user |
| `PhotoData`\* | String | Base64 da foto          |

* Faça uma requisição do tipo POST para a URL: `http://{device_ip}/cgi-bin/AccessFace.cgi?action=insertMulti` fornecendo o objeto JSON no corpo da requisição.

#### Exemplo

```python
import requests
import json

# Defina o IP do dispositivo, o username e a senha
device_ip = '10.1.35.87'
username = 'admin'
password = 'acesso1234'

url = "http://{device_ip}/cgi-bin/AccessFace.cgi?action=insertMulti".format(device_ip)

digest_auth = requests.auth.HTTPDigestAuth(username, password)

payload = json.dumps({
    "FaceList": [
        {
            "UserID": "16",
            "PhotoData": [
                "Aqui vai a string Base64 da face a ser cadastrada..."
            ]
        }
    ]
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, auth=digest_auth, headers=headers, data=payload)

if response.text.strip() == "OK":
    print("Cadastro da face realizado com sucesso.")
else:
    print("Erro ao cadastrar: " + response.text)


```

Ao enviar a requisição, o servidor deve responder com 'OK' se o cadastro for bem-sucedido.

{% hint style="warning" %}
Caso retorne Bad Request, verifique os **critérios** novamente.
{% endhint %}

Por meio do cadastro, será possível gerenciar e controlar o acesso do usuário ao sistema. Dessa forma, é fundamental que todas as informações sejam precisas e atualizadas regularmente para garantir a segurança do sistema e do usuário.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://portal-integracao.intelbras.com.br/linha-de-faciais/primeiros-passos/cadastro-de-faces.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
