> For the complete documentation index, see [llms.txt](https://ajuda.pdvlegal.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajuda.pdvlegal.com.br/integracoes/acesso-a-api.md).

# Acesso à API

Libere o Acesso à API no OEM e use as credenciais da filial para consultar os dados da loja em api.pdvlegal.com.br.

> Cada filial tem credenciais próprias para consumir a API do PDV Legal em **<https://api.pdvlegal.com.br>**. O acesso é sempre limitado aos dados da filial.

## O que a filial pode acessar

* O **client\_id** é o código da filial e o **client\_secret** é o token exibido no Gestão Legal.
* Qualquer filial informada nas chamadas (rota, parâmetros ou corpo) é ignorada e substituída pela filial do token.
* O acesso é **somente leitura**: apenas consultas (GET). Inclusão, alteração e exclusão (POST/PUT/DELETE) não são permitidas.
* Cadastros do grupo econômico (produtos, grupos e classes de produtos, formas de pagamento, impostos) podem ser consultados. Os demais dados (vendas, clientes, fornecedores, estoque, tabela de preços etc.) são sempre só da filial.
* Recursos exclusivos do canal/revenda (licenciamento, por exemplo) não são acessíveis com este token.
* O token de acesso (JWT) vale por **8 horas**. Limite de **60** requisições por minuto para a filial.

***

## 1. Liberar o acesso no OEM

{% stepper %}
{% step %}
No **Cadastro de licenciamento**, abra o grupo **Integrações ERP / Gestão**.
{% endstep %}

{% step %}
Marque **Acesso à API (api.pdvlegal.com.br - somente leitura)**.
{% endstep %}

{% step %}
Clique em **Grava Licenciamento**.

![Acesso à API no Cadastro de licenciamento do OEM](https://1320237751-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLaIVEmahy7qwD0rmQzED%2Fuploads%2FZYkQX6IL4c8hocWcwdOm%2Fapi-oem.png?alt=media)
{% endstep %}
{% endstepper %}

***

## 2. Configurar no Gestão Legal

**Onde:** Gestão Legal → Administrativo → Filiais → aba **Integrações** → **Acesso API**

No quadro **Credenciais**:

* **client\_id:** código da filial.
* **client\_secret (token de acesso à API):** use **Copiar**.
* **Gerar novo token:** gera um novo client\_secret.

![Aba Acesso API com as credenciais da filial](https://1320237751-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLaIVEmahy7qwD0rmQzED%2Fuploads%2FiCokM6NcsYGBZovqiELr%2Fapi-retaguarda.png?alt=media)

***

## 3. Gerar o token de acesso

Envie um **POST** para **<https://api.pdvlegal.com.br/token>** com `Content-Type: application/x-www-form-urlencoded`. O quadro **Como gerar o token de acesso** traz o exemplo em cURL já com as credenciais da filial:

```bash
curl -X POST https://api.pdvlegal.com.br/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=SEU_CLIENT_ID" \
  -d "client_secret=SEU_CLIENT_SECRET"
```

Resposta:

```json
{ "access_token": "<jwt>", "expires_in": 28800 }
```

Nas demais chamadas, envie o cabeçalho `Authorization: Bearer <access_token>`.


---

# 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://ajuda.pdvlegal.com.br/integracoes/acesso-a-api.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.
