# API - Antes de avançar

# Boas Práticas

Para garantir uma integração estável e eficiente com a API da Oystr, tanto em Lotes ou Itens, recomendamos observar as seguintes boas práticas:

- **Frequência de envio de requisições**  
    Evite o envio excessivo de chamadas em curtos períodos de tempo. Altas taxas de requisição podem gerar sobrecarga, aumento de filas internas e impactar o tempo de processamento dos robôs. Isso também poderá acarretar em problemas de bloqueios externos e autenticação/identidade com os sistemas envolvidos.
- **Frequência de consulta de resultados (polling)**  
    As consultas de resultados devem respeitar os intervalos recomendados. Polling muito frequente pode causar consumo desnecessário de recursos e degradação de performance. Para consulta de resultados recomendamos intervalos entre 30 e 120 segundos.
- **Consulta de dados antigos**  
    Resultados de execuções ficam disponíveis para consulta por um período limitado. Atualmente, a Oystr mantém os dados disponíveis por até 7 dias. Após esse período, os dados podem não estar mais acessíveis.
- **Validação de credenciais antes da execução**  
    Evite executar robôs com credenciais potencialmente inválidas ou expiradas. Esse tipo de execução consome recursos desnecessários (como captcha, proxy e processamento) e pode impactar negativamente o desempenho geral da operação.
- **Evitar execuções duplicadas em curto intervalo**  
    Não execute o mesmo robô com os mesmos parâmetros repetidamente em um curto espaço de tempo. Isso pode gerar consumo desnecessário de recursos e aumentar o risco de bloqueios externos (ex: sistemas de terceiros). Sempre que possível, utilize mecanismos de controle como `cid` para evitar duplicidade.
- **Registro de requisições e respostas (logging)**  
    Recomendamos armazenar as requisições enviadas e as respostas recebidas (incluindo IDs de execução) em logs ou arquivos persistentes. Isso é fundamental para rastreabilidade, auditoria e investigação de possíveis problemas em ambiente de produção.

# Autenticação na API

#### **Autenticação na API**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Todas as requisições http feitas aos servidores da Oystr devem conter, no header da requisição, o parâmetro </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">***<span data-slate-string="true">X-Oystr-Auth</span>***</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, com o seu </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">***<span data-slate-string="true">token</span>***</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> de autenticação.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Todas as requisições para nossa API demandam o uso do </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">header</span>**</span></span> <span data-slate-node="text"><span data-slate-leaf="true">***<span data-slate-string="true">X-Oystr-Auth</span>***</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, ele é obrigatório. Caso o token não seja informado no header da requisição ou caso o token seja inválido, o retorno do servidor, nas demais requisições, será </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">HTTP/1.1 403 Forbidden</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, indicando a ausência de permissões para efetuar a requisição.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">O método /ping é utilizado apenas para realização de autenticação na API. Para saber como obter a o seu token, acesse o link abaixo e siga as instruções ali definidas.</span></span></span>

#### **<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Como obter a chave de API</span></span></span>**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Antes de mais nada, a primeira coisa que você precisa fazer é obter a sua </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">chave de API (API Key)</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. Sem ela, você não conseguirá se autenticar na API e, consequentemente, não conseguirá consumir seus métodos.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Abaixo, segue um passo a passo de como obter a sua chave de API:</span></span></span>

- Acesse o Console/Painel da Oystr (https://console4.oystr.com.br);

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Sua chave será criada e exibida no console. Para consumir a API, basta copiar a chave criada e passar no </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">***<span data-slate-string="true">HEADER</span>***</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, conforme indicado no método de </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">***<span data-slate-string="true">Autenticação na API</span>***</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">.</span></span></span>

<div class="ResponsiveContainer__StyledResponsiveContainerColumn-sc-1y2ta6q-0 ibCncS eight-wide-column mobile-twelve-wide-column sc-qYhdC hSfsBF entity-description-container" data-click="" data-testid="aether-responsive-container" id="bkmrk-" overflow="unset"><div class="sc-kMYVKZ hgLdXH mimir" data-testid="test-mimir-main" id="bkmrk--1"></div></div>

# API de Itens -1:1

#### **Conceitos**

Todos os robôs da Oystr que são utilizados através da API 1:1 possuem um nome e versão. Diferente do modelo em lote, onde existe o conceito de filas e execuções com múltiplos itens, na API 1:1 cada requisição representa a execução de um único item de forma isolada. **Não há o conceito de fila ou execução agrupada neste modelo**.

Cada chamada realizada na API 1:1 dispara uma execução individual de robô, responsável por processar os dados enviados e retornar um resultado específico para aquele item. Essas execuções são independentes entre si e não compartilham estado ou fila.

De maneira geral, para executar um robô utilizando a API 1:1, temos o seguinte fluxo:

<table border="1" id="bkmrk-ordem-tipo-descri%C3%A7%C3%A3o" style="border-collapse: collapse; border-style: solid; width: 100%; height: 219.859px;"><thead><tr style="height: 29.7969px;"><th style="width: 9.14607%; height: 29.7969px;">Ordem</th><th style="width: 13.9655%; height: 29.7969px;">Tipo</th><th style="width: 76.8772%; height: 29.7969px;">Descrição</th></tr></thead><tbody><tr style="height: 60.125px;"><td class="align-center" style="width: 9.14607%; height: 60.125px;">*0.1*</td><td class="align-center" style="width: 13.9655%; height: 60.125px;">*Opcional*</td><td style="width: 76.8772%; height: 60.125px; text-align: justify;">*Validar as credenciais que serão utilizadas pelos robôs para acessar um sistema (tribunal, gestão jurídico, etc)*</td></tr><tr style="height: 43.3125px;"><td class="align-center" style="width: 9.14607%; height: 43.3125px;">1</td><td class="align-center" style="width: 13.9655%; height: 43.3125px;">**Obrigatório**</td><td style="width: 76.8772%; height: 43.3125px; text-align: justify;">Criar execução do item e receber o identificador da execução (id assíncrono)</td></tr><tr style="height: 43.3125px;"><td class="align-center" style="width: 9.14607%; height: 43.3125px;">2</td><td class="align-center" style="width: 13.9655%; height: 43.3125px;">**Obrigatório**</td><td style="width: 76.8772%; height: 43.3125px; text-align: justify;">Consultar o retorno/status da execução</td></tr><tr style="height: 43.3125px;"><td class="align-center" style="width: 9.14607%; height: 43.3125px;">3</td><td class="align-center" style="width: 13.9655%; height: 43.3125px;">**Obrigatório**</td><td style="width: 76.8772%; height: 43.3125px; text-align: justify;">Obter o resultado final da execução</td></tr></tbody></table>

#### **Respostas Assíncronas da API**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Antes de continuar, é importante entender o conceito de que muitas das chamadas na </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">API da Oystr</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> retornam respostas de maneira </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">assíncrona</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. </span></span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Isso quer dizer que a resposta da chamada </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">não estará pronta de imediato</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> e você receberá um id para consultar o resultado da chamada posteriormente. </span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">O design da API leva em consideração </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">o tempo que os robôs demoram para executar uma determinada tarefa</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. Lembre-se, algumas tarefas podem demorar horas para finalizar. Isso significa que seu código de integração precisa estar preparado para lidar com essas respostas assíncronas. </span></span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">A seguir, veja um exemplo de chamada que recebe um id de consulta assíncrona:</span></span></span>

```json
http POST https://api4.oystr.com.br/v1/[método de retorno assíncrono] X-Oystr-Auth:[token]

HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": "[id]"
}

```

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">O retorno de um método assíncrono é um </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">json</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> com um único campo: </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">id</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. Precisamos fazer uma segunda chamada na API, usando o </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">id retornado na chamada anterior</span>**</span></span><span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnAlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMnRleHQlMjIlM0ElMjJPJTIwcmV0b3JubyUyMGRlJTIwdW0lMjBtJUMzJUE5dG9kbyUyMGFzcyVDMyVBRG5jcm9ubyUyMCVDMyVBOSUyMHVtJTIwJTIyJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMmpzb24lMjIlMkMlMjJib2xkJTIyJTNBdHJ1ZSU3RCUyQyU3QiUyMnRleHQlMjIlM0ElMjIlMjBjb20lMjB1bSUyMCVDMyVCQW5pY28lMjBjYW1wbyUzQSUyMCUyMiU3RCUyQyU3QiUyMnRleHQlMjIlM0ElMjJpZCUyMiUyQyUyMmJvbGQlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMi4lMjBQcmVjaXNhbW9zJTIwZmF6ZXIlMjB1bWElMjBzZWd1bmRhJTIwY2hhbWFkYSUyMG5hJTIwQVBJJTJDJTIwdXNhbmRvJTIwbyUyMCUyMiU3RCUyQyU3QiUyMnRleHQlMjIlM0ElMjJpZCUyMHJldG9ybmFkbyUyMG5hJTIwY2hhbWFkYSUyMGFudGVyaW9yJTIyJTJDJTIyYm9sZCUyMiUzQXRydWUlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyJTIwcGFyYSUyMGNvbnN1bHRhciUyMHNlJTIwbyUyMHJlc3VsdGFkbyUyMGolQzMlQTElMjBlc3QlQzMlQTElMjBwcm9udG8uJTIwQ29uc2lkZXJlJTIwdW1hJTIwY2hhbWFkYSUyMHBhcmElMjB2YWxpZGElQzMlQTclQzMlQTNvJTIwZGUlMjBjcmVkZW5jaWFsJTIwbm8lMjByb2IlQzMlQjQlMjBkZSUyMHRlc3RlcyUyMCVFMiU4MCU5Q3NhbXBsZSVFMiU4MCU5RCUyQyUyMHVzYW5kbyUyMG8lMjB1c3UlQzMlQTFyaW8lMjAlRTIlODAlOUN6enolRTIlODAlOUQlMjBlJTIwYSUyMHNlbmhhJTIwJUUyJTgwJTlDenp6JUUyJTgwJTlELiUyMFNlZ3VlJTIwZXhlbXBsbyUzQSUyMiU3RCU1RCU3RCU1RA==" data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> para consultar se o resultado já está pronto. Considere uma chamada para validação de credencial no robô de testes “sample”, usando o usuário “zzz” e a senha “zzz”. Segue exemplo:</span></span></span>

```json
http POST https://api4.oystr.com.br/v1/credentials/validate/sample/v1.0 X-Oystr-Auth:[token] username=zzz password=zzz

HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": "zqwG3hcEGxYl457T8A1d6qS77PCky71HgWdBDj4Z1sTmV6mqlp5VCcCs1ZutIEue"
}


```

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Após esta chamada, agora temos em mãos o </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">id de consulta do resultado da nossa chamada assíncrona</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. O recomendado é que se consulte no </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">mínimo a cada 10 segundos e no máximo a cada 120 segundos</span>**</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. </span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">A partir de agora, precisamos consultar continuamente a API, até que tenhamos a confirmação de conclusão da execução.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Neste momento, podemos ter 3 tipos de código de resposta: 200, 404 ou 500. Abaixo, segue descrição de cada tipo de resposta.</span></span></span>

<table border="1" id="bkmrk-c%C3%B3digo-tipo-descri%C3%A7%C3%A3" style="border-collapse: collapse; border-style: solid; width: 100%;"><thead><tr><th style="width: 9.51436%;">Código</th><th style="width: 30.2834%;">Tipo</th><th style="width: 60.191%;">Descrição</th></tr></thead><tbody><tr><td class="align-center" style="width: 9.51436%;">200</td><td style="width: 30.2834%;">OK - Resultado pronto</td><td style="width: 60.191%;">Com o payload da resposta, você receberá os dados relacionados ao seu resultado.</td></tr><tr><td class="align-center" style="width: 9.51436%;">404 | 204</td><td style="width: 30.2834%;">Resultado não disponível ainda</td><td style="width: 60.191%;">Neste caso indica-se que os dados ainda não estão prontos.</td></tr><tr><td class="align-center" style="width: 9.51436%;">500</td><td style="width: 30.2834%;">Erro interno</td><td style="width: 60.191%;">Neste caso entrar em contato conosco e informar o ID da chamada.</td></tr></tbody></table>

Segue um exemplo de consulta, com resposta:

```json
http GET https://api4.oystr.com.br/v1/cached/[id] X-Oystr-Auth:[token]
HTTP/1.1 404 NOT FOUND // indica que o resultado não está pronto
// 3 segundos depois
http GET https://api4.oystr.com.br/v1/cached/[id] X-Oystr-Auth:[token]
HTTP/1.1 200 OK
Content-Type: application/json
{
    "Message"     : null,
    "notAllowed"  : null,
    "notAvailable": null,
    "Valid"       : true
}

```

#### **0.1 - Validar Credenciais**

```yaml
POST: https://api4.oystr.com.br/credentials/validate/:botId/v3.0.0-dev
```

##### **Usuário/Senha - UP**

objeto ***“credentials”***, com par **usuário e senha**, será utilizado pelo robô para conseguir acesso ao sistema no qual ele irá executar as tarefas. Por exemplo, em um robô de tribunal onde a tarefa é obter a última movimentação processual, esse usuário/senha será utilizado para entrar no sistema do tribunal.

Quando informado na requisição (via arquivo ***payload*** ou especificado no ***body*** da requisição), é necessário seguir o formato abaixo:

```json
{
   "username": "...",
   "password": "...",
   "credentialsOption": "..."
}
```

##### **Parâmetros**

<table border="1" id="bkmrk-par%C3%A2metro-tipo-descr" style="width: 100%; border-collapse: collapse; border-style: solid;"><thead><tr><th style="width: 19.4045%;">Parâmetro</th><th style="width: 20.0183%;">Tipo</th><th style="width: 60.566%;">Descrição</th></tr></thead><tbody><tr><td style="width: 19.4045%;">**username**</td><td style="width: 20.0183%;">*String (obrigatório)*</td><td style="width: 60.566%;">Usuário utilizado para acessar o sistema em que o robô irá executar a tarefa.</td></tr><tr><td style="width: 19.4045%;">**password**</td><td style="width: 20.0183%;">*String (obrigatório)*</td><td style="width: 60.566%;">Senha correspondente ao usuário informado.</td></tr><tr><td style="width: 19.4045%;">**credentialsOption**</td><td style="width: 20.0183%;">*String (opcional)*</td><td style="width: 60.566%;">Valor opcional que será informado indicando particularidades das opções informadas. Quando necessário, a documentação do robô irá apontar.</td></tr></tbody></table>

##### **Certificado Digital A1 - CP**

O objeto *“credentials”* com certificado A1 será utilizado pelo robô para conseguir acesso ao sistema no qual ele irá executar as tarefas. Por exemplo, em um robô unificado intimações onde a tarefa é obter a todas as intimações disponíveis para o advogado em diversos tribunais do Brasil, esse certificado A1 será utilizado para entrar no sistema de cada tribunal especificado.

Quando informado na requisição (via arquivo ***payload*** ou especificado no ***body*** da requisição), é necessário seguir o formato abaixo:

```
{
   "username": "...",
   "base64Cert": "...",
   "pin": "...",
   "credentialsOption": "..."
}
```

##### **Parâmetros**

<table border="1" id="bkmrk-par%C3%A2metro-tipo-descr-1" style="width: 100%; border-collapse: collapse; border-style: solid;"><thead><tr><th style="width: 12.7303%;">Parâmetro</th><th style="width: 20.1461%;">Tipo</th><th style="width: 67.1124%;">Descrição</th></tr></thead><tbody><tr><td style="width: 12.7303%;">**username**</td><td style="width: 20.1461%;">*String (obrigatório)*</td><td style="width: 67.1124%;">Usuário utilizado para acessar o sistema em que o robô irá executar a tarefa.</td></tr><tr><td style="width: 12.7303%;">**base64Cert**</td><td style="width: 20.1461%;">*String (obrigatório)*</td><td style="width: 67.1124%;">Conteúdo do certificado A1 codificado em [Base64](https://pt.wikipedia.org/wiki/Base64)</td></tr><tr><td style="width: 12.7303%;">**pin**</td><td style="width: 20.1461%;">*String (obrigatório)*</td><td style="width: 67.1124%;">PIN ou senha utilizada para utilizar o certificado.</td></tr><tr><td style="width: 12.7303%;">**pin**</td><td style="width: 20.1461%;">*String (opcional)*</td><td style="width: 67.1124%;">Valor opcional que será informado indicando particularidades das opções informadas. Quando necessário, a documentação do robô irá apontar.</td></tr></tbody></table>

#### **1 - Criar Execução do Item 1:1**

```yaml
POST: https://api4.oystr.com.br/v1/execute/single
```

**Código de retorno**

<table border="1" id="bkmrk-retorno-descri%C3%A7%C3%A3o-20" style="width: 99.6296%; height: 173.125px; border-collapse: collapse; border-style: solid;"><thead><tr style="height: 29.7017px;"><th style="width: 21.6788%; height: 29.7017px;">**Retorno**</th><th style="width: 78.5538%; height: 29.7017px;">**Descrição**</th></tr></thead><tbody><tr style="height: 46.5057px;"><td style="width: 21.6788%; height: 46.5057px;">202</td><td style="width: 78.5538%; height: 46.5057px;">inicia a execução de um ítem. Retona o id para   
consulta futur</td></tr><tr style="height: 96.9176px;"><td style="width: 21.6788%; height: 96.9176px;">5xx ou 4xx</td><td style="width: 78.5538%; height: 96.9176px;">Falha ao iniciar a execução do ítem. Nestes   
casos é necessário utilizar (manualmente via   
suporte) o header X-Oystr-TraceId retornado   
para verificar se o ítem foi recebido pela API e   
está em execução ou não.</td></tr></tbody></table>

**Formato da Requisição (via HTTP)**

```json
{
    "dry": false,
    "bot": "",
    "version": "",
    "cid": "",
    "timeout": "",
    "deadline": "",
    "credentials": {
        "username": "",
        "password": ""
    },
    "data": {},
    "files": [{
        "bound": true,
        "property": "",
        "description": "",
        "name": "",
        "data": ""
    }]
}
```

<table border="1" id="bkmrk-campo-obrigat%C3%B3rio-fo" style="width: 100%; border-collapse: collapse; border-style: solid;"><thead><tr><th style="width: 13.4719%;">**Campo**</th><th style="width: 13.1011%;">**Obrigatório**</th><th style="width: 16.0638%;">**Formato**</th><th style="width: 13.4755%;">**Default**</th><th style="width: 43.8764%;">**Descrição**</th></tr></thead><tbody><tr><td style="width: 13.4719%;">dry</td><td style="width: 13.1011%;">Não</td><td style="width: 16.0638%;">Boolean</td><td style="width: 13.4755%;">false</td><td style="width: 43.8764%;">Indica se é uma execução de teste</td></tr><tr><td style="width: 13.4719%;">bot</td><td style="width: 13.1011%;">Sim</td><td style="width: 16.0638%;">String</td><td style="width: 13.4755%;"> </td><td style="width: 43.8764%;">Id do robô</td></tr><tr><td style="width: 13.4719%;">version</td><td style="width: 13.1011%;">Sim</td><td style="width: 16.0638%;">String</td><td style="width: 13.4755%;"> </td><td style="width: 43.8764%;">Versão do robô</td></tr><tr><td style="width: 13.4719%;">cid</td><td style="width: 13.1011%;">Não</td><td style="width: 16.0638%;">String</td><td style="width: 13.4755%;">vazio</td><td style="width: 43.8764%;">Identificador único da requisição¹</td></tr><tr><td style="width: 13.4719%;">force</td><td style="width: 13.1011%;">Não</td><td style="width: 16.0638%;">Boolean</td><td style="width: 13.4755%;">vazio</td><td style="width: 43.8764%;">Indica se um item único, discriminado pelo cid deve ser reexecutado ou não</td></tr><tr><td style="width: 13.4719%;">timeout</td><td style="width: 13.1011%;">Não</td><td style="width: 16.0638%;">Duration</td><td style="width: 13.4755%;">5 minutos</td><td style="width: 43.8764%;">Tempo máximo aguardando o retorno de um item desde o início da execução². Exemplo: 30s</td></tr><tr><td style="width: 13.4719%;">deadline</td><td style="width: 13.1011%;">Não</td><td style="width: 16.0638%;">ZonedDateTime</td><td style="width: 13.4755%;">vazio</td><td style="width: 43.8764%;">Data máxima para o início da execução do item³ no formato ISO 8601. Exemplo 2022-01-01T00:00:00.0-03:00</td></tr><tr><td style="width: 13.4719%;">credentials</td><td style="width: 13.1011%;">Robô</td><td style="width: 16.0638%;">json</td><td style="width: 13.4755%;"> </td><td style="width: 43.8764%;">Credenciais usadas na requisição</td></tr><tr><td style="width: 13.4719%;">data</td><td style="width: 13.1011%;">Sim</td><td style="width: 16.0638%;">json</td><td style="width: 13.4755%;"> </td><td style="width: 43.8764%;">Dados passados diretamente para o robô. Cada robô possuí um formato específico.</td></tr><tr><td style="width: 13.4719%;">file</td><td style="width: 13.1011%;">Robô</td><td style="width: 16.0638%;">json</td><td style="width: 13.4755%;"> </td><td style="width: 43.8764%;">Arquivos passados para o robô</td></tr></tbody></table>

1. ID usado para evitar requisições duplicadas. Caso o cid não seja único a resposta será do tipo Duplicate . Caso o cid seja inválido a requisição será rejeitada
2. . Após este período a resposta será do tipo Timeout
3. Caso a execução do ítem não tenha iniciado até esta data a resposta será do tipo Overdue.

#### **2 - Consultar o retorno da execução - (assíncrono)**

```yaml
GET: https://api.oystr.com.br/v1/execute/single/:bot/:cached?format=latest
```

**Código de retorno**

<table id="bkmrk-retorno-descri%C3%A7%C3%A3o-40"><thead><tr><th>**Retorno**</th><th>**Descrição**</th></tr></thead><tbody><tr><td>404</td><td>id inválido ou ítem rejeitado. Nunca haverá uma resposta para este item.</td></tr><tr><td>202</td><td>Reposta indisponível, aguarde</td></tr><tr><td>200</td><td>Resposta disponível</td></tr></tbody></table>

#### **3 - Interpretar e obter o resultado final da execução**

Após uma resposta 200, teremos como payload da resposta o resultado final da execução. Os resultados ficam disponíveis no modelo do endereço abaixo de acordo com o header **X-Oystr-ReturnPath**:

```yaml
GET: https://api.oystr.com.br/v1/execute/single/:bot/:cached?format=latest
```

O payload recebido depende do valor da variável forma:

**Formato Legado** - format=legacy

```yaml
GET: https://api.oystr.com.br/v1/execute/single/:bot/:cached?format=latest
```

```json
{
    "type": "",
    "payload": {}
}
```

**Formato Recomendado** - format=latest

O payload em json obtido quando a resposta está disponível segue o seguinte modelo:

```json
{
    "account": 0,
    "user": 0,
    "bot": "",
    "version": "",
    "cid": "",
    "request": "",
    "started": "",
    "ended": "",
    "taskTime": "",
    "timeout": "",
    "finishedAs": "",
    "retry": "",
    "dry": false,
    "result": {}
}
```

Descrição dos campos:

<table border="1" id="bkmrk-campo-formato-descri" style="width: 99.3827%; height: 445.526px; border-collapse: collapse; border-style: solid;"><thead><tr style="height: 29.7017px;"><th style="width: 21.0768%; height: 29.7017px;">**Campo**</th><th style="width: 26.1283%; height: 29.7017px;">**Formato**</th><th style="width: 52.7791%; height: 29.7017px;">**Descrição**</th></tr></thead><tbody><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">account</td><td style="width: 26.1283%; height: 29.7017px;">Long</td><td style="width: 52.7791%; height: 29.7017px;">Conta que realizou a requisição</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">user</td><td style="width: 26.1283%; height: 29.7017px;">Long</td><td style="width: 52.7791%; height: 29.7017px;">Usuário que realizou a requisição</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">bot</td><td style="width: 26.1283%; height: 29.7017px;">String</td><td style="width: 52.7791%; height: 29.7017px;">Robô</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">version</td><td style="width: 26.1283%; height: 29.7017px;">String</td><td style="width: 52.7791%; height: 29.7017px;">Versão do robô</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">cid</td><td style="width: 26.1283%; height: 29.7017px;">String</td><td style="width: 52.7791%; height: 29.7017px;">id de integração</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">request</td><td style="width: 26.1283%; height: 29.7017px;">String</td><td style="width: 52.7791%; height: 29.7017px;">Id da requisição</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">started</td><td style="width: 26.1283%; height: 29.7017px;">ZonedDateTime</td><td style="width: 52.7791%; height: 29.7017px;">Data de início da execução do item no formato ISO-8601</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">ended</td><td style="width: 26.1283%; height: 29.7017px;">ZonedDateTime</td><td style="width: 52.7791%; height: 29.7017px;">Data de início da execução do item no formato ISO-8601</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">taskTime</td><td style="width: 26.1283%; height: 29.7017px;">Duration</td><td style="width: 52.7791%; height: 29.7017px;">Tempo de execução do item</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">timeout</td><td style="width: 26.1283%; height: 29.7017px;">Duration</td><td style="width: 52.7791%; height: 29.7017px;">Timeout efetivamente usado</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">retry</td><td style="width: 26.1283%; height: 29.7017px;">Enum</td><td style="width: 52.7791%; height: 29.7017px;">indica se é possível re-executar o item</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">dry</td><td style="width: 26.1283%; height: 29.7017px;">Json</td><td style="width: 52.7791%; height: 29.7017px;">Indica se é uma execução DE TESTE</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">finishedAs</td><td style="width: 26.1283%; height: 29.7017px;">Enum</td><td style="width: 52.7791%; height: 29.7017px;">Tipo de resultado (tabela abaixo)</td></tr><tr style="height: 29.7017px;"><td style="width: 21.0768%; height: 29.7017px;">result</td><td style="width: 26.1283%; height: 29.7017px;">Json</td><td style="width: 52.7791%; height: 29.7017px;">Payload com o resultado</td></tr></tbody></table>

#### **Tipos de retorno**

Os tipos de resultados possíveis:

<table border="1" id="bkmrk-resposta-permite-ree" style="width: 100%; border-collapse: collapse; border-style: solid; height: 663.126px;"><thead><tr style="height: 29.7969px;"><th style="width: 22%; height: 29.7969px;">**Resposta**</th><th style="width: 19.2809%; height: 29.7969px;">**Reexecução Recomendada?**</th><th style="width: 12.2393%; height: 29.7969px;">**Origem**</th><th style="width: 46.4686%; height: 29.7969px;">**Descrição**</th></tr></thead><tbody><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">Response</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Resposta válida</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">PartialResponse</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;"> </td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">NotAllowed</td><td style="width: 19.2809%; height: 29.7969px;">Sim</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Não é permitida a execução do item</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">NotFound</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Item não encontrado</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">NotConsistent</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Dados inconsistentes</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">NotAvailable</td><td style="width: 19.2809%; height: 29.7969px;">Sim</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Item não disponivel</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">ProxyError</td><td style="width: 19.2809%; height: 29.7969px;">Sim</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Erro de proxy</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">CaptchaError</td><td style="width: 19.2809%; height: 29.7969px;">Sim</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Erro de captcha</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">Forbidden</td><td style="width: 19.2809%; height: 29.7969px;">Sim</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Execução do item não é permitida</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">BotError</td><td style="width: 19.2809%; height: 29.7969px;">Sim</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Erro no robô</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">Other</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">Bot</td><td style="width: 46.4686%; height: 29.7969px;">Outros</td></tr><tr style="height: 46.5938px;"><td style="width: 22%; height: 46.5938px;">RequestHasViolations</td><td style="width: 19.2809%; height: 46.5938px;">Não</td><td style="width: 12.2393%; height: 46.5938px;">API</td><td style="width: 46.4686%; height: 46.5938px;">Pedido contém informações inválidas. O item não foi executado.</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">NotAndApiRequest</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">API</td><td style="width: 46.4686%; height: 29.7969px;">Formato inválido de requisição. O item não foi executado</td></tr><tr style="height: 46.5938px;"><td style="width: 22%; height: 46.5938px;">NotAccepted</td><td style="width: 19.2809%; height: 46.5938px;">Não</td><td style="width: 12.2393%; height: 46.5938px;">API</td><td style="width: 46.4686%; height: 46.5938px;">Execução do item nõa foi aceita. O item pode ou não ter sido executado</td></tr><tr style="height: 46.5938px;"><td style="width: 22%; height: 46.5938px;">Timeout</td><td style="width: 19.2809%; height: 46.5938px;">Não</td><td style="width: 12.2393%; height: 46.5938px;">API</td><td style="width: 46.4686%; height: 46.5938px;">Timeout durante a execução do item. O item pode ou não ter sido executado</td></tr><tr style="height: 46.5938px;"><td style="width: 22%; height: 46.5938px;">Overdue</td><td style="width: 19.2809%; height: 46.5938px;">Não</td><td style="width: 12.2393%; height: 46.5938px;">API</td><td style="width: 46.4686%; height: 46.5938px;">Execução do item ocorreria apís o deadline. Item não foi executado</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">Duplicate</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">API</td><td style="width: 46.4686%; height: 29.7969px;">Item duplicado baseado no cid. Item não foi executado</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">UnexpectedError</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">API</td><td style="width: 46.4686%; height: 29.7969px;">Erro inesperado. O item pode ou não ter sido executado</td></tr><tr style="height: 29.7969px;"><td style="width: 22%; height: 29.7969px;">Unknown</td><td style="width: 19.2809%; height: 29.7969px;">Não</td><td style="width: 12.2393%; height: 29.7969px;">API</td><td style="width: 46.4686%; height: 29.7969px;">Desconhecido. O item pode ou nõa ter sido executado</td></tr></tbody></table>

#### **Requisições Duplicadas**

A Oystr não testa os dados enviados para a execução com a exceção dos atributos cid e force . Caso o cid esteja presente na requisição, a Oystr fará a verificação se este cid foi executado nos últimos 15 dias para esta conta e robô. Caso o cid seja "duplicado", o ítem será executado apenas se o parâmetro force estiver presente com o valor true , caso contrário a resposta do ítem será do tipo Duplicate .

A Oystr emprega uma estratégia estatística para verifica ser o ítem já foi executado. Esta estratégia permite falsos positivos, ou seja:

1. ítem não foi executado (com certeza) para esta conta e robô nos últimos 15 dias, ou2
2. . ítem possivelmente já foi executado antes (false positivo)

Um cid , se presente, deve ter entre 1 e 50 carateres alphanuméricos ou '-' de acordo com a seguinte expressão regular: \[0-9a-zA-Z\\\\-\]{1,50} . Caso o cid seja inválido o ítem não será executado, a requisição será ignorada e ficará sem resposta, retornando 404 em consultas futuras.

#### **Reexecução**

Em alguns casos é possível que um ítem seja reexecutado em caso de erro, mesmo que um cid tenha sido utilizado. Os critérios que definem se um ítem pode ou não ser reexecutado ficam a cargo do cliente da API que deve observar os seguintes critérios:

1. Se houve uma execução anterior "do mesmo" íten, esta deve ter retornado como insucesso, com o parâmetro retry = SAFE . Caso contrário não é seguro reexecutar o ítem.
2. . Caso um cid seja utilizado, ele deve ser único ou o parâmetro force = true deve ser utilziado para ignorar o teste de duplicidade.

A Oystr não verifica se a requisição anterior retornou com retry = SAFE durante a nova execução, mesmo que o cid seja o mesmo. Esta verificação fica a cargo do cliente/usuário da api.

# API de Lotes - 1:N

#### **Conceitos**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Todos os robôs da Oystr que são utilizados através da API de lotes tem um nome e versão. Os robôs da Oystr trabalham e operam em execuções. Uma execução contém itens que fazem parte de uma fila. Cada item da fila é consumida por uma execução de robô. As execuções podem ter vários robôs trabalhando ao mesmo tempo. Após a execução é possível você ter acesso aos dados de relatório e saída do robô.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">De maneira geral, para se criar uma execução e rodar um robô, temos que realizar as seguintes tarefas na ordem descrita:</span></span></span>

<table border="1" id="bkmrk-ordem-tipo-descri%C3%A7%C3%A3o" style="border-collapse: collapse; border-style: solid; width: 100%; height: 395.639px;"><thead><tr style="height: 29.7017px;"><th style="width: 9.14607%; height: 29.7017px;">Ordem</th><th style="width: 13.9655%; height: 29.7017px;">Tipo</th><th style="width: 76.8772%; height: 29.7017px;">Descrição</th></tr></thead><tbody><tr style="height: 60.142px;"><td style="width: 9.14607%; height: 60.142px; text-align: justify;">\*0.1\*</td><td style="width: 13.9655%; height: 60.142px; text-align: justify;">\*\*Opcional\*\*</td><td style="width: 76.8772%; height: 60.142px; text-align: justify;">\*Validar as credenciais que serão utilizadas pelos robôs para acessar um sistema (tribunal, gestão jurídico, etc)\*</td></tr><tr style="height: 43.3381px;"><td style="width: 9.14607%; height: 43.3381px; text-align: justify;">\*0.2\*</td><td style="width: 13.9655%; height: 43.3381px; text-align: justify;">\*\*Opcional\*\*</td><td style="width: 76.8772%; height: 43.3381px; text-align: justify;">\*Executar uma proto fila para obter itens\*</td></tr><tr style="height: 43.3381px;"><td style="width: 9.14607%; height: 43.3381px; text-align: justify;">1</td><td style="width: 13.9655%; height: 43.3381px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 43.3381px; text-align: justify;">Criar uma fila de itens</td></tr><tr style="height: 43.3381px;"><td style="width: 9.14607%; height: 43.3381px; text-align: justify;">2</td><td style="width: 13.9655%; height: 43.3381px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 43.3381px; text-align: justify;">Anexar arquivos a fila de itens (apenas para os robôs que fazem upload de arquivos)</td></tr><tr style="height: 43.3381px;"><td style="width: 9.14607%; height: 43.3381px; text-align: justify;">3</td><td style="width: 13.9655%; height: 43.3381px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 43.3381px; text-align: justify;">Iniciar a execução</td></tr><tr style="height: 43.3381px;"><td style="width: 9.14607%; height: 43.3381px; text-align: justify;">4</td><td style="width: 13.9655%; height: 43.3381px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 43.3381px; text-align: justify;">Consultar o status da execução</td></tr><tr style="height: 29.7017px;"><td style="width: 9.14607%; height: 29.7017px; text-align: justify;">5</td><td style="width: 13.9655%; height: 29.7017px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 29.7017px; text-align: justify;">Consultar o informações da execução</td></tr><tr style="height: 29.7017px;"><td style="width: 9.14607%; height: 29.7017px; text-align: justify;">6</td><td style="width: 13.9655%; height: 29.7017px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 29.7017px; text-align: justify;">Validar as respostas/dados/journal da execução</td></tr><tr style="height: 29.7017px;"><td style="width: 9.14607%; height: 29.7017px; text-align: justify;">7</td><td style="width: 13.9655%; height: 29.7017px; text-align: justify;">\*\*Obrigatório\*\*</td><td style="width: 76.8772%; height: 29.7017px; text-align: justify;">Obter o relatório/resultado da execução</td></tr></tbody></table>

**Para utilizar nossa API de lotes, entre em contato conosco para solicitar a autorização e documentação.**

# Robôs

### [API - 1:1](https://wiki.oystr.com.br/search?term=%5Bapi%3D1%3A1%5D)

#### 1 - [TRIBUNAIS](https://wiki.oystr.com.br/search?term=%5Bcategoria%3Dtribunais%5D)

##### 1.1 - [PROTOCOLO](https://wiki.oystr.com.br/search?term=%5Btipo%3Dprotocolo%5D)

<table border="1" id="bkmrk-id-rob%C3%94-sistema-pje-" style="border-collapse: collapse; width: 100%; height: 325px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**SISTEMA**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-tj-protocolo](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-tj-protocolo)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-tj-protocolo-habilitacao](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-tj-protocolo-habilitacao)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-trt-protocolo](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-trt-protocolo)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-trt-protocolo-habilitacao](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-trt-protocolo-habilitacao)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[eproc-protocolo](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-eproc-protocolo)</td><td style="height: 35.2983px;">EPROC</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[esaj-protocolo](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-esaj-protocolo)</td><td style="height: 29.7017px;">ESAJ</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[tj-rj-protocolo](https://wiki.oystr.com.br/books/api-antes-de-avancar/page/11-)</td><td style="height: 29.7017px;">PROPRIO</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[projudi-protocolo](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-protocolo)</td><td style="height: 29.7017px;">PROJUDI</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[tj-se-protocolo](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-tj-se-protocolo)</td><td style="height: 29.7017px;">PROPRIO</td></tr></tbody></table>

##### 1.2 - [AJUIZAMENTO](https://wiki.oystr.com.br/search?term=%5Btipo%3Dajuizamento%5D)

<table border="1" id="bkmrk-id-rob%C3%94-sistema-esaj" style="border-collapse: collapse; width: 100%; height: 241.491px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**SISTEMA**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[esaj-ajuizamento](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-esaj-ajuizamento)</td><td style="height: 35.2983px;">ESAJ</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-tj-ajuizamento](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-tj-ajuizamento)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-pr-ajuizamento](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-pr-ajuizamento)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[eproc-ajuizamento](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-eproc-ajuizamento)</td><td style="height: 35.2983px;">EPROC</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-go-ajuizamento](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-go-ajuizamento)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[tj-se-ajuizamento](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-tj-se-ajuizamento)</td><td style="height: 35.2983px;">PROPRIO</td></tr></tbody></table>

##### 1.3 - [CÓPIA INTEGRAL](https://wiki.oystr.com.br/search?term=%5Btipo%3Dcopia-integral%5D)

<table border="1" id="bkmrk-id-rob%C3%94-sistema-epro" style="border-collapse: collapse; width: 100%; height: 336.193px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**SISTEMA**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[eproc-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-eproc-copia-integral)</td><td style="height: 35.2983px;">EPROC</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[esaj-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-esaj-copia-integral)</td><td style="height: 35.2983px;">ESAJ</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-trt-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-trt-copia-integral)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-copia-integral)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[pje-trf5-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-trf5-copia-integral)</td><td style="height: 35.2983px;">PJE</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-go-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-go-copia-integral)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-pr-copia-integral](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-pr-copia-integral)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[stj-jus-copia-integral](https://wiki.oystr.com.br/books/api-antes-de-avancar/page/11-stj-jus-copia-integral)</td><td style="height: 29.7017px;">PROPRIO</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[tj-rj-copia-integral](https://wiki.oystr.com.br/books/api-antes-de-avancar/page/11-tj-rj-copia-integral)</td><td style="height: 29.7017px;">PROPRIO</td></tr></tbody></table>

##### 1.3 - [INFO](https://wiki.oystr.com.br/search?term=%5Btipo%3Dinfo%5D)

<table border="1" id="bkmrk-id-rob%C3%94-sistema-esaj-1" style="border-collapse: collapse; width: 100%; height: 300.895px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**SISTEMA**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[esaj-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-esaj-info)</td><td style="height: 35.2983px;">ESAJ</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[eproc-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-eproc-info)</td><td style="height: 35.2983px;">EPROC</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-go-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-go-info)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-ba-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-ba-info)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-mt-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-mt-info)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[projudi-pr-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-projudi-pr-info)</td><td style="height: 35.2983px;">PROJUDI</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[pje-info](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-info)</td><td style="height: 29.7017px;">PJE</td></tr><tr style="height: 29.7017px;"><td style="height: 29.7017px;">[pje-tj-rj-publico-informacoes](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-pje-tj-rj-publico-informacoes)</td><td style="height: 29.7017px;">PJE</td></tr></tbody></table>

#### 2 - [SISTEMAS](https://wiki.oystr.com.br/search?term=%5Bcategoria%3Dsistemas%5D)

##### 2.1 - [BBJUR](https://wiki.oystr.com.br/search?term=%5Bsistema%3Dbbjur%5D)

<table border="1" id="bkmrk-id-rob%C3%94-fun%C3%87%C3%83o-bbjur" style="border-collapse: collapse; width: 100%; height: 135.597px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**FUNÇÃO**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[bbjur-distribution-search](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-bbjur-distribution-search)</td><td style="height: 35.2983px;">  
</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[bbjur-event-update-api](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-bbjur-event-update-api)</td><td style="height: 35.2983px;">  
</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[bbjur-distribuicao](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-bbjur-distribuicao)</td><td style="height: 35.2983px;">  
</td></tr></tbody></table>

##### 2.2 - [LEGALONE](https://wiki.oystr.com.br/search?term=%5Bsistema%3Dlegalone%5D)

<table border="1" id="bkmrk-id-rob%C3%94-fun%C3%87%C3%83o-legal" style="border-collapse: collapse; width: 100%; height: 65px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**FUNÇÃO**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[legalone-tarefa](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-legalone-tarefa)</td><td style="height: 35.2983px;">CADASTRO DE TAREFAS</td></tr></tbody></table>

##### 2.2 - [SISJUR](https://wiki.oystr.com.br/search?term=%5Bsistema%3Dsisjur%5D)

<table border="1" id="bkmrk-id-rob%C3%94-fun%C3%87%C3%83o-sisju" style="border-collapse: collapse; width: 100%; height: 300.895px;"><colgroup><col style="width: 50.0562%;"></col><col style="width: 50.0562%;"></col></colgroup><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">**ID ROBÔ**</td><td style="height: 29.7017px;">**FUNÇÃO**</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[sisjur-pex-andamentos-documentos](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-sisjur-pex-andamentos-documentos)</td><td style="height: 35.2983px;">INSERE ANDMENTOS E DOCUMENTOS - PEX</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[sisjur-andamentos-inserir-cc](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-sisjur-andamentos-inserir-cc)</td><td style="height: 35.2983px;">INSERE ANDMENTOS E DOCUMENTOS - CC</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">[sisjur-andamentos-inserir-jec](https://wiki.oystr.com.br/books/dados-dos-robos-api-11/page/11-sisjur-andamentos-inserir-jec)</td><td style="height: 35.2983px;">INSERE ANDMENTOS E DOCUMENTOS - JEC</td></tr></tbody></table>

# Intimações

### **App de Intimações**

*Referência da API intimações, para automação com acionamento de hooks por API para notificação de eventos.*

O APP de intimações é um serviço de agendamento para execução recorrente dos robôs de intimação da Oystr. Ele executa os robôs de intimação nos dias e horários agendados com as configurações definidas e, ao fim da execução, pode disparar um **webhook** contendo o endpoint para obtenção dos resultados para uma url definida.

#### **O que são Webhooks e o seu papel no App de intimações?**

Os Webhooks são uma forma de um software avisar outro software através de gatilhos e disparos. A melhor maneira de entender isso é pensar nos webhooks como notificações de eventos. Na nossa aplicação de intimações, sempre que um perfil configurado terminar de carregar ou abrir as intimações no tribunal, um disparo de evento será feito através da nossa API para o webhook configurado no software integrado. É desta maneira que as integrações serão feitas no App de Intimações Oystr.

![](https://storage.googleapis.com/oystr-archive-test-sa/static/intimation-app-manual/hook-scheme.png)

#### **Perfis de Abertura de Intimações**

O App de Intimações opera a partir de perfis. Um perfil representa uma configuração de credenciais, opções, filtros, etc. usada para agendar e iniciar os robôs de intimação. Quando dia e horário especificados no perfil forem cumpridos, o App de intimações executará as seguintes ações:

1. `Listagem`: acionará o robô com as credenciais e opções definidas para obter uma lista das intimações disponíveis. Erros nessa etapa são marcados como `Erro ao listar` na interface do App e uma nova tentativa será realizada no próximo ciclo de 30 minutos contanto que o horário limite configurado não tenha sido atingido. Caso não tenha sido concluída em até 3 horas, será interrompida automaticamente. Para cada cliente são listados até 2 perfis simultâneos no momento.
2. `Filtragem`: aplicará os filtros automáticos definidos sobre a lista de intimações recebida para decidir quais deve abrir
3. `Disparo do webhook opcional`: se definido, enviará um webhook contendo a lista das intimações que serão abertas pelo robô e a lista das intimações que *não* serão abertas pelo robô. Caso ocorra erro ou seja recebido qualquer status de retorno fora da lista `200, 201, 202, 203, 204`, uma nova tentativa será feita 30 minutos depois com um limite de 10 tentativas. O estado atual de envio e consulta fica disponível na aba `Auditoria` seção `Integração` da interface do App.
4. `Abertura`: acionará o robô com as credenciais e opções definidas para realizar a captura das intimações escolhidas na `Filtragem`. As execuções criadas são disponibilizadas na tela inicial do console para a conta que tiver criado a chave de API cadastrada no App de intimações (a chave de API da integradora não influencia esse comportamento). **Somente as execuções criadas pelo App de intimações são passíveis de integração**. Não há limite de execuções simultâneas por parte do App de intimações. A conclusão das execuções é verificada a cada 5 minutos
5. `Obtenção do registro`: recebe o registro de execução do robô e realiza o download dos anexos para integração
6. `Processamento`: se definido, aplicará processamentos extras no registro de execução do robô. Se não especificado, aplicará a padronização dos campos de data com a máscara `DD/MM/YYYY`. A padronização é aplicada apenas aos campos que puderem ser identificados, caso contrário o conteúdo é deixado intacto
7. `Disparo do webhook principal`: enviará um webhook contendo o endpoint de consulta do registro. Caso ocorra erro ou seja recebido qualquer status de retorno fora da lista `200, 201, 202, 203, 204`, uma nova tentativa será feita 30 minutos depois com um limite de 10 tentativas. O estado atual de envio e consulta fica disponível na aba `Auditoria` da interface do App.

###  

###  

### **Configurações Gerais**

#### **IMPORTANTE: Antes de Definir o Primeiro Perfil**

Antes de começar, é necessário realizar duas configurações/ajustes pela primeira (e única) vez:

\* Será necessário criar uma chave de API, caso ainda não tenha sido feito. Veja [neste link](https://documenter.getpostman.com/view/14325749/TW74hQRQ#b152871c-194d-4674-a63e-44f0b0a5d6a9) como fazer.  
\* Será necessário realizar uma configuração padrão que servirá como modelo base para novos perfis. A configuração padrão deve ser definida em **Perfis**-&gt;**Configurações**.

#### **Configurações Gerais**

*Link para cadastrar perfis no painel de Intimações.*

*Link das configurações gerais.*

*Formulário das configurações gerais da conta.*

<table id="bkmrk-campo-descri%C3%87%C3%83o-webh"><thead><tr><th>CAMPO</th><th>DESCRIÇÃO</th></tr></thead><tbody><tr><td>**Webhook**</td><td>Endpoint de envio do hook principal. Se essa configuração ficar em branco, não haverá disparo no webhook.</td></tr><tr><td>**JSON Header Webhook**</td><td>Headers adicionais a ser incluídos na requisição do hook principal em formato JSON. Isso é usado normalmente para realizar autenticações e garantir a segurança da sua aplicação.</td></tr><tr><td>**WebhookProto**</td><td>Endpoint de envio do hook opcional com a listagem dos itens que serão abertos. Se essa configuração ficar em branco, não haverá disparo no webhook.</td></tr><tr><td>**JSON Header WebhookProto**</td><td>Headers adicionais a ser incluídos na requisição do hook opcional em formato JSON.</td></tr><tr><td>**Enviar Protohook**</td><td>Habilita/desabilita o envio do hook opcional.</td></tr><tr><td>**Agendado para**</td><td>Horário de agendamento geral, quando os perfis irão iniciar suas execuções.</td></tr></tbody></table>

### **Criando um Perfil**

#### **Criando um Perfil de Execução de Intimações**

Após realizar as configurações acima, os perfis podem ser criados em **Perfis**-&gt;**Criar novo perfil**

[![image.png](https://wiki.oystr.com.br/uploads/images/gallery/2024-03/scaled-1680-/XBeimage.png)](https://wiki.oystr.com.br/uploads/images/gallery/2024-03/XBeimage.png)

*Formulário de novo perfil.*

<table id="bkmrk-campo-descri%C3%87%C3%83o-nome" style="width: 100%;"><thead><tr><th style="width: 18.038%;">CAMPO</th><th style="width: 81.9508%;">DESCRIÇÃO</th></tr></thead><tbody><tr><td style="width: 18.038%;">**Nome da execução**</td><td style="width: 81.9508%;">Prefixo que será atribuído as execuções que forem criadas a partir desse perfil. **ATENÇÃO:** Evite usar espaços, caracteres especiais e símbolos.</td></tr><tr><td style="width: 18.038%;">**Nome da automação**</td><td style="width: 81.9508%;">Nome que será atribuído ao perfil/automação que está sendo criado. **ATENÇÃO:** Evite usar espaços, caracteres especiais e símbolos.</td></tr><tr><td style="width: 18.038%;">**Executar nos dias**</td><td style="width: 81.9508%;">Dias da semana onde o perfil deve ser executado.</td></tr><tr><td style="width: 18.038%;">**Selecione o tribunal**</td><td style="width: 81.9508%;">Configurações do robô e credenciais.</td></tr><tr><td style="width: 18.038%;">**Rotina**</td><td style="width: 81.9508%;">Filtro de data que será aplicado às intimações listadas. **Veja na tabela a baixo** como estes valores se aplicam.</td></tr><tr><td style="width: 18.038%;">**Horário limite**</td><td style="width: 81.9508%;">Com essa configuração, o App não iniciará perfis após o horário determinado. O valor padrão é 21h00 do horário de Brasília.</td></tr><tr><td style="width: 18.038%;">**Formatação dos campos de data**</td><td style="width: 81.9508%;">Com essa configuração, o App aplicará um processamento no registro do robô para definir um formato padronizado. A formatação é aplicada aos campos `postDate`, `date`, `assignment`, `periodStart` e `periodEnd`. Caso não especificado, será aplicada a máscara `DD/MM/YYYY` por padrão nos campos que puderem ser identificados.</td></tr></tbody></table>

<table id="bkmrk-rotina-descri%C3%87%C3%83o-%C3%9Alt" style="width: 100%;"><thead><tr><th style="width: 18.4118%;">ROTINA</th><th style="width: 81.5769%;">DESCRIÇÃO</th></tr></thead><tbody><tr><td style="width: 18.4118%;">**Últimos 3 dias**</td><td style="width: 81.5769%;">Apenas as intimações postadas nos últimos 3 dias serão filtradas (selecionadas). Por exemplo, no dia 10/11/2021, apenas as intimações postadas no dia 09/11/2021, 08/11/2021 e 07/11/2021 serão filtradas.</td></tr><tr><td style="width: 18.4118%;">**Ontem**</td><td style="width: 81.5769%;">Apenas as intimações postadas no dia anterior (ontem) serão filtradas. Por exemplo, no dia 10/11/2021, apenas as intimações postadas no dia 09/11/2021 serão filtradas.</td></tr><tr><td style="width: 18.4118%;">**Ontem e antes**</td><td style="width: 81.5769%;">Apenas as intimações postadas nos dias posteriores (ontem para trás) serão filtradas. Por exemplo, no dia 10/11/2021, as intimações postadas no dia 09/11/2021 para trás serão filtradas.</td></tr><tr><td style="width: 18.4118%;">**Últimos X dias**</td><td style="width: 81.5769%;">Apenas as intimações postadas nos últimos X dias serão selecionadas. Por exemplo, no dia 10/11/2021 com X = 2, apenas as intimações postadas nos dias 09/11/2021 e 08/11/2021 serão filtradas.</td></tr><tr><td style="width: 18.4118%;">**X dias e antes**</td><td style="width: 81.5769%;">Apenas as intimações postadas há X dias ou mais serão selecionadas. Por exemplo, no dia 10/11/2021 com X = 2, apenas as intimações postadas antes do dia 08/11/2021 serão filtradas.</td></tr><tr><td style="width: 18.4118%;">**Todos**</td><td style="width: 81.5769%;">O filtro irá pegar tudo, não levando em consideração a data da postagem.</td></tr></tbody></table>

**A inicialização do robô pode atrasar em relação ao horário agendado em situações onde uma grande quantidade de perfis está agendada para o mesmo horário ou perfis iniciados anteriormente ainda não tenham finalizado a execução. O disparo dos perfis ocorre num modelo de fila por cliente, sendo executados no máximo 2 perfis por vez.**

### **Webhooks**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Um webhook é uma requisição </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">HTTP</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> enviada automaticamente quando um evento acontece. Isso permite que o próprio servidor notifique o cliente do evento em vez de o cliente perguntar repetidamente. No App de intimações, webhooks são usados para notificar o cliente em dois momentos: após a filtragem da lista de intimações e após o término do processamento dos resultados.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">Para receber webhooks do App de intimações é necessário disponibilizar um endpoint para receber os disparos, que são requisições</span>**</span></span> <span data-slate-node="text"><span data-slate-leaf="true">`<strong class="StyledLeaf___StyledSpan-sc-129cvv1-0 hSAwv slate-bold" data-slate-leaf="true"><span data-slate-string="true">POST</span></strong>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">.</span></span></span>

#### **Webhook Principal (conteúdo das intimações)**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Para o hook principal (retorno das intimações), o </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">body</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> terá o seguinte formato:</span></span></span>

```json
{
    "configName": "nome-perfil",
    "executionId": "id-execucao",
    "bot": "pje-tj-intimation",
    "credentials": {
        "username": "username",
        "credentialType": "password"
    },
    "resultEndpoint": "/results/id-execucao"
}

```

<div class="slate-table-wrapper" data-slate-node="element" id="bkmrk-campo-descri%C3%87%C3%83o-conf"><table border="1" style="border-collapse: collapse; border-style: solid; height: 169px; width: 99.6296%;"><tbody><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><th class="StyledElement___StyledDiv-sc-2e063k-0 iwrqJg slate-th" data-slate-node="element" style="width: 49.943%;"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">CAMPO</span></span></span></th><th class="StyledElement___StyledDiv-sc-2e063k-0 iwrqJg slate-th" data-slate-node="element" style="width: 49.943%;"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">DESCRIÇÃO</span></span></span></th></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">configName</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Nome da configuração.</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">executionId</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">ID da execução.</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">bot</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">ID do robô para conferência no painel da Oystr.</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">credentials</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Resumo das credenciais utilizadas.</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">resultEndpoint</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 49.943%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Endpoint para consulta dos resultados.</span></span></span></div></td></tr></tbody></table>

</div><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">O endpoint deve responder com um dos status da lista </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">200</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">201</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">202</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">203</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">204</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> em caso de sucesso. Em caso de falha, por qualquer razão, serão realizadas mais 9 tentativas com 30 minutos de espera entre elas. Caso seja preciso reenviar algum webhook basta entrar em contato com o suporte.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">É importante verificar se o endpoint é acessível pelo servidor do App, é comum que requisições partindo de faixas de IP de datacenter sejam bloqueadas.</span>**</span></span>

#### **Webhook Opcional (listagem das intimações)**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Já para o opcional (listagem das intimações), o **body** </span></span></span><span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnAlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMnRleHQlMjIlM0ElMjJKJUMzJUExJTIwcGFyYSUyMG8lMjBvcGNpb25hbCUyMChsaXN0YWdlbSUyMGRhcyUyMGludGltYSVDMyVBNyVDMyVCNWVzKSUyQyUyMG8lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyYm9keSUyMiUyQyUyMmNvZGUlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyMHRlciVDMyVBMSUyMG8lMjBmb3JtYXRvJTNBJTIyJTdEJTVEJTdEJTVE" data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">terá o formato:</span></span></span>

```json
{
    "configName": "nome-perfil",
    "bot": "projudi-intimacao",
    "credentials": {
        "username": "username",
        "credentialType": "password"
    },
    "total": 1,
    "filtered": 1,
    "remaining": 0,
    "filteredItems": [{
        "valid": true,
        "data": [...],
        "files": null
    }],
    "remainingItems": [{
        "valid": true,
        "data": [...],
        "files": null
    }]
}

```

<div class="slate-table-wrapper" data-slate-node="element" id="bkmrk-campo-descri%C3%87%C3%83o-conf-1"><table border="1" style="border-collapse: collapse; border-style: solid; width: 100%;"><tbody><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><th class="StyledElement___StyledDiv-sc-2e063k-0 iwrqJg slate-th" data-slate-node="element" style="width: 16.1871%;">**<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">CAMPO</span></span></span>**</th><th class="StyledElement___StyledDiv-sc-2e063k-0 iwrqJg slate-th" data-slate-node="element" style="width: 83.8016%;">**<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">DESCRIÇÃO</span></span></span>**</th></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 16.1871%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">configName</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 83.8016%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Nome da configuração</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 16.1871%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">bot</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 83.8016%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">ID do robô para conferência no painel da Oystr</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 16.1871%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">credentials</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 83.8016%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Resumo das credenciais utilizadas</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 16.1871%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">filteredItems</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 83.8016%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Itens filtrados de acordo com o filtro selecionado na configuração do perfil. Esses são os itens que serão executados pela automação</span></span></span></div></td></tr><tr class="TableRowElement___StyledTr-sc-718caz-0 fnTgiE slate-tr" data-slate-node="element"><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 16.1871%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">remainingItems</span></span></span></div></td><td class="TableCellElement___StyledTd-sc-r69en2-0 ojsWl slate-td" data-slate-node="element" style="width: 83.8016%;"><div class="TableCellElement___StyledDiv-sc-r69en2-1 kcNcvY slate-TableCellElement-content"><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Itens remanescentes após o filtro ser aplicado. Esses itens não serão executados pela automação</span></span></span></div></td></tr></tbody></table>

</div><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">O endpoint deve responder com um dos status da lista </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">200</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">201</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">202</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">203</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">204</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> em caso de sucesso. Em caso de falha, por qualquer razão, serão realizadas mais 9 tentativas com 30 minutos de espera entre elas. Caso seja preciso reenviar algum webhook basta entrar em contato com o suporte.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">É importante verificar se o endpoint é acessível pelo servidor do App, é comum que requisições partindo de faixas de IP de datacenter sejam bloqueadas.</span>**</span></span>

### **Consulta dos resultados**

```yaml
GET: https://console4.oystr.com.br/api/v1/service/intimacoes/results/id-execucao
```

\* **Lembrando que é necessário fazer essa requisição autenticada com o header X-Oystr-Auth**, veja [neste link](https://documenter.getpostman.com/view/14325749/TW74hQRQ#b152871c-194d-4674-a63e-44f0b0a5d6a9) como fazer.

Ao consultar os resultados através do endpoint enviado no webhook, o retorno esperado é o seguinte:

```
{
    credentialsOption: "UF",
    data: {
        entries: [
            [{
                "offset": [posicao do item],
                "sent": [indicador de o item foi processado],
                "received": [indicador se o item teve resposta],
                "type": [TIPO DA RESPOSTA],
                "start": [data em millis],
                "duration": [timestamp],
                "request": {
                    /** DADOS DE ENTRADA DO ROBÔ **/
                },
                "response": {
                    /** DADOS DE SAÍDA DO ROBÔ **/
                }
            } /** ... N entradas **/ ]
        ],
    }
}


```

#### **"type": "RES"**

Abaixo o modelo dos dados contendo uma intimação:

```
{
    credentialsOption: "UF",
    data:
    {
        entries:
        [
            [{
                "offset": 0,
                "sent": true,
                "received": true,
                "type": "RES",
                "start": 1613484436618,
                "duration": 19831,
                "request":
                {
                    "id": "[string]",
                    "integration": "[string]",
                    "process": "[número do processo]",
                    "type": "[string]",
                    "withText": "1",
                    "removeDigitalCopy": "1",
                    "grau": "[string]",
                    "url": "[string]",
                    "date": "[data da intimação]",
                    "readerDate": "[string]",
                    "tribunal": "[string]",
                    "party": "[parte intimada]",
                    "event": "[evento/tipo do movimento]",
                    "postDate": "[string]",
                    "lastDate": "[string]",
                    "typeReader": "01-1",
                    "owner": "[id]",
                    "codAdv": "[advogado]",
                    "autor": "[string]",
                    "reu": "[string]",
                    "idPendencia": "[string]",
                    "codigoPendencia": "[string]",
                    "abrirIntimacao": "[string]",
                    "dataHora": "[string]",
                    "erroComarca": "[string]",
                    "meioComunicacao": "[string]",
                    "leitor": "[string]"
                },
                "response":
                {
                    "notices":
                    [{
                        "id":"",                         // Identificação única no site do tribunal, se houver
                        "processNumber":"[string]",      // Número do processo
                        "origin":"[string]",              // Diário Eletronico de origem
                        "author":"[string]",             // Autor
                        "defendant":"[string]",         // Réu
                        "postDate":"[string]",             // Data de postagem
                        "automatic":"[string]",         // Data de leitura automatica
                        "date":"[string]",              // Data da intimação
                        "period":"[string]",             // prazo
                        "processType":"[string]",         // Classe processual
                        "periodStart":"[string]",          // Primeiro dia de prazo
                        "periodEnd":"[string]",          // Último dia de prazo
                        "type":"[string]",              // Tipo do diário
                        "assignment":"[string]",        // Data da distribuição
                        "personal":[boolean],           // Pessoal
                        "juizo":"[string]",             // Juízo
                        "fulfillmentDate":"[string]",   // Data de cumprimento
                        "reader":""[string],              // Leitor
                        "status":"[string]",            // Situação/Status
                        "document":"[string]",            // Título documento da publicação
                        "update":"[string]",            // Movimento/Publicação
                        "lawyer":"[string]",            // Advogado
                        "link":"[string]",                // Link
                        "attachments":                    // Array de anexos,
                        [{
                            "error":false,           // Indicação de erro
                            "name":"file-vWz.pdf",  // Nome do arquivo
                            "data":"[string]",        // Conteúdo do arquivo em base64
                            "text":"[string]",        // Texto extraído do arquivo
                            "description":null        // Descrição do arquivo
                        }],
                        "singleFile":null      // Uso interno, ignorar
                    }],
                    "total": 1,
                    "withText": "1",
                    "notFound": false,
                    "error": false,
                    "errorMessage": null,
                    "exp": null
                }
            }]
        ],
    }
}


```

<table id="bkmrk-campo-descri%C3%87%C3%83o-data"><thead><tr><th>CAMPO</th><th>DESCRIÇÃO</th></tr></thead><tbody><tr><td>data-&gt;entries\[\]\[\]</td><td>Array contendo todos os itens de intimação que o robô tentou capturar, com todas as informações para recuperar a entrada (intimação a capturar) e saída do robô (resultado)</td></tr><tr><td>data-&gt;entries\[x\]\[x\]-&gt;type</td><td>Tipo da resposta que estará contido no objeto response deste item. Para cada tipo, campos diferentes serão trazidos:   
  
  
  
  
- RES - Resposta padrão com os dados de uma intimaçao. **Todos os outros tipos de resposta representam erros (e subsequente ausência do objeto** **`response`\*\*\*\*, sendo os mais comuns ERR e REQ**\*  
- ERR - Resposta com erro, onde o robô não conseguiu capturar a intimação. Neste caso o "response" será nulo. Existirá um objeto "error" com as informações tecnicas sobre o erro.  
- REQ - Item sem resposta por parte do robô, neste caso o objeto `response` será nulo.</td></tr></tbody></table>

#### **Modelo de objeto resposta com erros/exceções**

**IMPORTANTE**: Estes cenários onde a resposta não é **RES** podem, ou não, representar problemas para o cliente dependendo do erro e da configuração dos seus perfis (se houve ciência dada na intimação, qual configuração de filtro e agendamento o perfil possui, se mais perfis podem vir a abrir a intimação, etc.), **sendo recomendada a verificação com o suporte para determinar se a situação representa algum risco de perda de prazo**. Dentro do objeto *request* você sempre irá encontrar as informações preliminares da intimação, sendo possível assim saber qual foi o processo, evento e data da intimação com erro no robô.

#### **"type": "ERR"**

Quando o type for "**ERR**", o robô encontrou um erro ao tentar ler/abrir a intimação indicada. **Veja que o retorno não terá o objeto** **`response`** **mas sim terá um objeto** **`error`**.

```
    {
      "offset": 10,
      "sent": true,
      "received": true,
      "type": "ERR",
      "start": 1626715329826,
      "duration": 25537,
      "request": {
        "id": null,
        "integration": null,
        "process": "[número do processo]",
        "type": "novas",
        "withText": "1",
        "removeDigitalCopy": "1",
        "grau": "primeiro-grau",
        "url": null,
        "date": "[data da intimação]",
        "readerDate": null,
        "tribunal": "JFRS",
        "party": "[parte intimada]",
        "event": "Expedida/certificada a intimação eletrônica",
        "postDate": "Abrir Prazo",
        "lastDate": "",
        "typeReader": "01-1",
        "owner": "[id]",
        "codAdv": "[advogado]",
        "autor": null,
        "reu": null,
        "idPendencia": null,
        "codigoPendencia": null,
        "abrirIntimacao": null,
        "dataHora": null,
        "erroComarca": null,
        "meioComunicacao": null,
        "leitor": null
      },
      "error": {
        "message": "curl error: 16",
        "stackTrace": "xingu.http.client.HttpException: curl error: 16\n\tat xingu.http.client.impl.SimpleHttpRequest.exec(SimpleHttpRequest.java:63)\n\tat xingu.http.client.impl.StatefullRequest.exec(StatefullRequest.java:35)\n\tat oystr.eproc.intimacao.controllers.EprocController.pesquisarProcesso(EprocController.java:283)\n\tat oystr.eproc.intimacao.controllers.EprocPendentesWithoutReaderController.execute(EprocPendentesWithoutReaderController.java:57)\n\tat oystr.eproc.intimacao.EprocIntimacaoBot.execute(EprocIntimacaoBot.java:152)\n\tat oystr.eproc.intimacao.EprocIntimacaoBot.execute(EprocIntimacaoBot.java:37)\n\tat oystr.broker.client.MessageHandler.onRequest(MessageHandler.java:233)\n\tat oystr.broker.client.MessageHandler.processAsync(MessageHandler.java:139)\n\tat oystr.broker.client.MessageHandler.access$000(MessageHandler.java:50)\n\tat oystr.broker.client.MessageHandler$1.run(MessageHandler.java:95)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"
      }
    }


```

#### **"type": "REQ"**

Quando o type for "**REQ**", o robô não executou o item em questão. Estes casos server para apontar problemas de configuração ou comunicação com o tribunal. Caso esse problema seja recorrente, indica-se que seja verificado a situação da configuração/perfil no App para evitar perda de prazos. **Veja que o retorno não terá o objeto** **`response`** **e que o valor de** **`received`** **é** **`false`**.

```
    {
      "offset": 8,
      "sent": true,
      "received": false,
      "type": "REQ",
      "start": 1626775895441,
      "request": {
        "id": null,
        "integration": null,
        "process": "[número do processo]",
        "type": "novas",
        "withText": "1",
        "removeDigitalCopy": "1",
        "grau": "primeiro-grau",
        "url": "[url...]",
        "date": "[data da intimação]",
        "readerDate": null,
        "tribunal": "PR",
        "party": "[parte intimada]",
        "event": "JUNTADA DE ATO ORDINATÓRIO (10 dias úteis)",
        "postDate": "-",
        "lastDate": "-",
        "typeReader": "novas",
        "owner": null,
        "codAdv": null,
        "autor": null,
        "reu": null,
        "idPendencia": null,
        "codigoPendencia": null,
        "abrirIntimacao": null,
        "dataHora": null,
        "erroComarca": null,
        "meioComunicacao": null,
        "leitor": null
      }
    }


```

### **Outras observações**


- Dependendo das configurações dos perfis do cliente pode haver a abertura da mesma intimação múltiplas vezes. O cliente pode acionar o suporte para fazer a identificação da(s) causa(s) e as mudanças necessárias mas, caso seja necessária a implementação de um mecanismo de controle por parte da integradora, recomendamos que a intimação seja identificada através do hash de certas informações do elemento do array `notices`.
- O registro da execução do robô é sempre disponibilizado para integração, incluindo o envio do webhook, ainda que a execução tenha 100% de erro. A integradora pode notificar o cliente das ocorrências de erro (recomendamos a inclusão do id de execução na notificação, caso ocorra) mas o ideal é que o cliente acompanhe o painel da Oystr com frequência para o acompanhamento desses casos e acionamento do suporte caso necessário.
- Os registros das execuções ficam disponíveis mesmo após a consulta. O App de intimações armazena o status de envio e consulta dos registros mas **não** impede o acesso após o registro da consulta. Caso um registro esteja indisponível ele pode ter sido movido para armazenamento frio e podemos recuperar esses registros caso necessário.

###  

### **Novo formato de anexos (beta)**

Devido à inclusão de anexos inteiros em base64 no documento de integração o tamanho do arquivo pode atingir valores exorbitantes. Para contornar esse problema, um novo formato de anexos foi implementado em que são fornecidos endpoints para download posterior dos documentos, permitindo separar o processamento desses itens para um momento oportuno.

Todos os documentos seguem tendo o mesmo formato mas com pequenas mudanças. O conteúdo do webhook passará a ter as seguintes informações:

```json
{
    "configName": "nome-perfil",
    "executionId": "id-execucao",
    "bot": "pje-tj-intimation",
    "credentials": {
        "username": "username",
        "credentialType": "password"
    },
    "resultEndpoint": "/results/id-execucao", // Ainda contém o arquivo no modelo anterior sem nenhuma mudança
    "testingResultEndpoint": "/results/testing-id-execucao" // Campo temporário com o journal no novo modelo, mais adiante passaremos a disponibilizar em resultEndpoint
}
```

A integradora pode então realizar a requisição do documento no endpoint em `testingResultEndpoint`. Caso haja qualquer problema, o arquivo no modelo anterior estará disponível no endpoint em `resultEndpoint`. Já os anexos em `attachments` passarão a ter o seguinte modelo:

```json
[{
    "type": "link|raw",      // será "raw" caso o arquivo esteja presente em base64 no campo "data"; ou "link" caso o endpoint de download esteja presente no campo "link"
    "error":false,           // Indicação de erro
    "name":"file-vWz.pdf",   // Nome final do arquivo (pode ser diferente da extensão indicada no link pois, caso sejam arquivos html, convertidos para pdf antes do download)
    "data":"[string]|null",  // Conteúdo do arquivo em base64, somente presente caso "type" seja "raw", do contrário será null
    "text":"[string]",       // Texto extraído do arquivo
    "link": "/document/id-execucao/0/file-vWz.html|null", // Endpoint de download, somente presente caso "type" seja "link", do contrário será null
    "description":null       // Descrição do arquivo
}],
```

Caso o campo `type` seja `raw`, o anexo é compatível com o formato anterior e o documento completo estará em `data` em base64. Caso seja `link`, `data` será `null` e o documento em si deverá ser obtido posteriormente no endpoint em `link`.

# Autenticação 2 Fatores

### **Cadastro de uma nova chave A2F**

```yaml
POST: https://api4.oystr.com.br/v1/service/vault/totp
```

```json
{
    "bot": "sample",
    "name": "chavedeexemplo",
    "url": "otpauth://totp/chavedeexemplo?algorithm=SHA1&digits=6&period=30&secret=GQ7FWN3CIM4D6OKRF53TKTZFMI7HGSSQ",
    "username": "12312312312"
}
```

Este endpoint irá cadastrar uma chave de autenticação 2 fatores para um usuário.

- **Tipo requisição:** POST;
- **Tipo resposta:** SÍNCRONA;
- **Body:** json

<table id="bkmrk-par%C3%A2metro-tipo-descr"><thead><tr><th>Parâmetro</th><th>Tipo</th><th>Descrição</th></tr></thead><tbody><tr><td>**bot**</td><td>*String (obrigatório)*</td><td>Identificador interno do bot. Para cadastro de A2F do Projudi, utilize `projudi-intimacao`</td></tr><tr><td>**name**</td><td>*String (obrigatório)*</td><td>Nome que será atribuído a chave. **Campo restringido a apenas** caractéres de `a - z` (em minúsculo) e com tamanho máximo de 24 caractéres.</td></tr><tr><td>**url**</td><td>*String (obrigatório)*</td><td>URL no padrão otpauth para registro da chave secreta. A composição desta chave irá contemplar o nome da chave informada no campo `name` e também a chave secreta no padrão (**todos os caractéres em maiúsculo e sem espaçamento**, por exemplo: `GQ7FWN3CIM4D6OKRF53TKTZFMI7HGSSQ`)</td></tr><tr><td>**username**</td><td>*String (obrigatório)*</td><td>Identificador do usuário na plataforma que irá utilizar esse cadastro A2F. **Em caso de tribunal como Projudi**, normalmente é o CPF contendo apenas digitos, sem espaçamento e `. -`.</td></tr></tbody></table>

### **Listando todas as chaves A2F**

```yaml
GET: https://console4.oystr.com.br/api/v1/service/vault/totp
```

Este endpoint irá listar todas as chaves de autenticação 2 fatores para uma conta.

- **Tipo requisição:** GET;
- **Tipo resposta:** SÍNCRONA;
- **Resposta:** json

# Distribuição

#### **Webhook**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Um webhook é uma requisição </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">HTTP</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> enviada automaticamente quando um evento acontece. Isso permite que o próprio servidor notifique o cliente do evento em vez de o cliente perguntar repetidamente. No App de distribuição, webhooks são usados para notificar o cliente quando os mesmos recebem novas distribuições.</span></span></span>

<span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">Para receber webhooks do App de distribuição é necessário disponibilizar um endpoint para receber os disparos, que são requisições</span>**</span></span> <span data-slate-node="text"><span data-slate-leaf="true">`<strong class="StyledLeaf___StyledSpan-sc-129cvv1-0 hSAwv slate-bold" data-slate-leaf="true"><span data-slate-string="true">POST</span></strong>`</span></span>

<span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">Todas requisições internas precisam ter a propriedade</span>**</span></span> <span data-slate-node="text"><span data-slate-leaf="true">`<strong class="StyledLeaf___StyledSpan-sc-129cvv1-0 hSAwv slate-bold" data-slate-leaf="true"><span data-slate-string="true">X-Oystr-Auth</span></strong>`</span></span> <span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">no</span>**</span></span> <span data-slate-node="text"><span data-slate-leaf="true">`<strong class="StyledLeaf___StyledSpan-sc-129cvv1-0 hSAwv slate-bold" data-slate-leaf="true"><span data-slate-string="true">headers</span></strong>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">, </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">recebendo o token que pode ser adquirido nas configurações do painel do Console como chave de API.</span>**</span></span>

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Ao receber novas distribuições, os webhooks notificarão a url cadastrada com o seguinte corpo.</span></span></span>

```json
{
  "webhookId": "id",
  "entity": {
    "type": "user",
    "id": "id",
    "username": "username"
  },
  "lastUpdateAt": null,
  "lastViewedAt": null,
  "endpoints": {
    "result": "/webhook/:id/results",
    "callback": "/webhook/:id/callback"
  }
}




```

<table border="1" id="bkmrk-campo-descri%C3%87%C3%83o-webh" style="width: 100.123%; border-collapse: collapse; border-style: solid;"><thead><tr><th style="width: 22.4625%;">CAMPO</th><th style="width: 77.5175%;">DESCRIÇÃO</th></tr></thead><tbody><tr><td style="width: 22.4625%;">webhookId</td><td style="width: 77.5175%;">Id do webhook</td></tr><tr><td style="width: 22.4625%;">entity</td><td style="width: 77.5175%;">Dados internos</td></tr><tr><td style="width: 22.4625%;">lastUpdateAt</td><td style="width: 77.5175%;">Última notificação realizada</td></tr><tr><td style="width: 22.4625%;">lastViewedAt</td><td style="width: 77.5175%;">Última visualização de novas distribuições</td></tr><tr><td style="width: 22.4625%;">endpoints</td><td style="width: 77.5175%;">Endpoints de auxílio para visualização dos resultados</td></tr></tbody></table>

##### **Ajuda**

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Para ter acesso às rotas da integração, é possível fazer uma requisição </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">GET</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> com final </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">/help</span>`</span></span>

```yaml
GET: https://console4.oystr.com.br/api/v1/service/disthook/webhook/help



```

**RESPOSTA**

```json
[
    {
        "method": "GET",
        "endpoint": "/webhook/help",
        "description": "Descrição de cada rota"
    },
    {
        "method": "GET",
        "endpoint": "/webhook/:id",
        "description": "Informações do webhook"
    },
    {
        "method": "POST",
        "endpoint": "/webhook/:id/results",
        "description": "Resultado do webhook e confirmação de visualização"
    },
    {
        "method": "GET",
        "endpoint": "/webhook/:id/callback",
        "description": "Verificação do webhook"
    },
    {
        "method": "GET",
        "endpoint": "/webhook",
        "description": "Busca de webhooks"
    },
    {
        "method": "POST",
        "endpoint": "/webhook",
        "description": "Criação de webhook"
    },
    {
        "method": "PUT",
        "endpoint": "/webhook/:id",
        "description": "Modificação de webhook"
    },
    {
        "method": "DELETE",
        "endpoint": "/webhook/:id",
        "description": "Remoção de webhook"
    }
]



```

##### **Informações**

```
GET: https://console4.oystr.com.br/api/v1/service/disthook/webhook/:id


```

Para ter acesso às informações de um webhook já cadastrado, é possível fazer uma requisição GET com final /:id. O retorno trará as seguintes informações:

```json
{
  "id": "id",
  "carteiraId": null,
  "userId": "id",
  "needView": false,
  "needNotify": false,
  "lastStatusCode": null,
  "lastResponse": null,
  "lastUpdateAt": null,
  "lastViewedAt": null,
  "url": "url",
  "headers": "{}",
  "createdAt": "2024-01-04T19:06:40.870Z",
  "updatedAt": "2024-01-04T19:06:40.870Z",
  "deletedAt": null,
  "entity": {
    "type": "user",
    "id": "id",
    "username": "username"
  }
}



```

<table border="1" id="bkmrk-campo-descri%C3%87%C3%83o-id-i" style="width: 99.7531%; border-collapse: collapse; border-style: solid;"><thead><tr><th style="width: 20.8072%;">CAMPO</th><th style="width: 79.1777%;">DESCRIÇÃO</th></tr></thead><tbody><tr><td style="width: 20.8072%;">id</td><td style="width: 79.1777%;">Id do webhook</td></tr><tr><td style="width: 20.8072%;">carteiraId</td><td style="width: 79.1777%;">Id da carteira vinculada</td></tr><tr><td style="width: 20.8072%;">userId</td><td style="width: 79.1777%;">Id do usuário vinculado</td></tr><tr><td style="width: 20.8072%;">needView</td><td style="width: 79.1777%;">Booleano para a necessidade de visualização de novos dados</td></tr><tr><td style="width: 20.8072%;">needNotify</td><td style="width: 79.1777%;">Booleano para a necessidade de notificação no endpoint definido</td></tr><tr><td style="width: 20.8072%;">lastStatusCode</td><td style="width: 79.1777%;">Último statusCode da requisição de notificação feita</td></tr><tr><td style="width: 20.8072%;">lastResponse</td><td style="width: 79.1777%;">Última resposta da requisição de notificação feita</td></tr><tr><td style="width: 20.8072%;">lastUpdateAt</td><td style="width: 79.1777%;">Última notificação realizada</td></tr><tr><td style="width: 20.8072%;">lastViewedAt</td><td style="width: 79.1777%;">Última visualização de novas distribuições</td></tr><tr><td style="width: 20.8072%;">url</td><td style="width: 79.1777%;">Url `POST` de disparo de notificação</td></tr><tr><td style="width: 20.8072%;">headers</td><td style="width: 79.1777%;">Parâmetros para a url de disparo de notificação</td></tr><tr><td style="width: 20.8072%;">createdAt</td><td style="width: 79.1777%;">Data de criação do webhook</td></tr><tr><td style="width: 20.8072%;">updatedAt</td><td style="width: 79.1777%;">Data de atualização do webhook</td></tr><tr><td style="width: 20.8072%;">deletedAt</td><td style="width: 79.1777%;">Data de deleção do webhook</td></tr><tr><td style="width: 20.8072%;">entity</td><td style="width: 79.1777%;">Dados internos</td></tr></tbody></table>

#####  

##### **Resultados (novas distribuições)**

```yaml
POST: https://console4.oystr.com.br/api/v1/service/disthook/webhook/:id/results


```

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Para ter acesso às novas distribuições que foi notificado por um webhook, é possível fazer uma requisição </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">POST</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> com final </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">/:id/results</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">**<span data-slate-string="true">Apenas serão mostradas distribuições recebidas após a última notificação, distribuições notificadas anteriormente e que não foram vistas não aparecerão.</span>**</span></span><span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnAlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMnRleHQlMjIlM0ElMjJQYXJhJTIwdGVyJTIwYWNlc3NvJTIwJUMzJUEwcyUyMG5vdmFzJTIwZGlzdHJpYnVpJUMzJUE3JUMzJUI1ZXMlMjBxdWUlMjBmb2klMjBub3RpZmljYWRvJTIwcG9yJTIwdW0lMjB3ZWJob29rJTJDJTIwJUMzJUE5JTIwcG9zcyVDMyVBRHZlbCUyMGZhemVyJTIwdW1hJTIwcmVxdWlzaSVDMyVBNyVDMyVBM28lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyUE9TVCUyMiUyQyUyMmNvZGUlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyMGNvbSUyMGZpbmFsJTIwJTIyJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyRiUzQWlkJTJGcmVzdWx0cyUyMiUyQyUyMmNvZGUlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMi4lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyQXBlbmFzJTIwc2VyJUMzJUEzbyUyMG1vc3RyYWRhcyUyMGRpc3RyaWJ1aSVDMyVBNyVDMyVCNWVzJTIwcmVjZWJpZGFzJTIwYXAlQzMlQjNzJTIwYSUyMCVDMyVCQWx0aW1hJTIwbm90aWZpY2ElQzMlQTclQzMlQTNvJTJDJTIwZGlzdHJpYnVpJUMzJUE3JUMzJUI1ZXMlMjBub3RpZmljYWRhcyUyMGFudGVyaW9ybWVudGUlMjBlJTIwcXVlJTIwbiVDMyVBM28lMjBmb3JhbSUyMHZpc3RhcyUyMG4lQzMlQTNvJTIwYXBhcmVjZXIlQzMlQTNvLiUyMiUyQyUyMmJvbGQlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyME8lMjByZXRvcm5vJTIwdHJhciVDMyVBMSUyMGFzJTIwc2VndWludGVzJTIwaW5mb3JtYSVDMyVBNyVDMyVCNWVzJTNBJTIyJTdEJTVEJTdEJTVE" data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> O retorno trará as seguintes informações:</span></span></span>

```json
{
    "id": "id",
    "dataDistribuicao": "2024-01-10T11:23:24-03:00",
    "termo": "Lorem",
    "tribunal": "LI",
    "numeroProcesso": "0000000-00.0000.0.00.0000",
    "tipoOcorrencia": "Lorem",
    "reu": "Lorem Ipsum",
    "autor": "Lorem Ipsum",
    "forum": "LI-4",
    "vara": "2ª Lorem Ipsum",
    "cidade": "LOREM",
    "uf": "LI",
    "valorOcorrencia": "20000.000",
    "advogadoautor": "Lorem Ipsum",
    "publicacao": null,
    "linkDocumentosIniciais": "https://loremipsum.com.br/lorem.pdf",
    "processoEletronico": "0000000-00.0000.0.00.0000",
    "tipoProcesso": "Lorem Ipsum",
    "instancia": "1",
    "assunto": "Lorem Ipsum",
    "juiz": null,
    "createdAt": "2024-01-11T13:35:21.420Z"
}


```

<span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnAlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMnRleHQlMjIlM0ElMjJQYXJhJTIwdGVyJTIwYWNlc3NvJTIwJUMzJUEwcyUyMG5vdmFzJTIwZGlzdHJpYnVpJUMzJUE3JUMzJUI1ZXMlMjBxdWUlMjBmb2klMjBub3RpZmljYWRvJTIwcG9yJTIwdW0lMjB3ZWJob29rJTJDJTIwJUMzJUE5JTIwcG9zcyVDMyVBRHZlbCUyMGZhemVyJTIwdW1hJTIwcmVxdWlzaSVDMyVBNyVDMyVBM28lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyUE9TVCUyMiUyQyUyMmNvZGUlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyMGNvbSUyMGZpbmFsJTIwJTIyJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyRiUzQWlkJTJGcmVzdWx0cyUyMiUyQyUyMmNvZGUlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMi4lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyQXBlbmFzJTIwc2VyJUMzJUEzbyUyMG1vc3RyYWRhcyUyMGRpc3RyaWJ1aSVDMyVBNyVDMyVCNWVzJTIwcmVjZWJpZGFzJTIwYXAlQzMlQjNzJTIwYSUyMCVDMyVCQWx0aW1hJTIwbm90aWZpY2ElQzMlQTclQzMlQTNvJTJDJTIwZGlzdHJpYnVpJUMzJUE3JUMzJUI1ZXMlMjBub3RpZmljYWRhcyUyMGFudGVyaW9ybWVudGUlMjBlJTIwcXVlJTIwbiVDMyVBM28lMjBmb3JhbSUyMHZpc3RhcyUyMG4lQzMlQTNvJTIwYXBhcmVjZXIlQzMlQTNvLiUyMiUyQyUyMmJvbGQlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyME8lMjByZXRvcm5vJTIwdHJhciVDMyVBMSUyMGFzJTIwc2VndWludGVzJTIwaW5mb3JtYSVDMyVBNyVDMyVCNWVzJTNBJTIyJTdEJTVEJTdEJTVE" data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"><span data-slate-node="text">Sem o parâmetro </span><span data-slate-node="text">`all`</span><span data-slate-node="text"> passado via query, direto pela url, esse endpoint apenas retornará as distribuições novas. Passando o parâmetro citado, o endpoint passará a retornar todas as distribuições do usuário ou da carteira, dependendo do tipo de vínculo do webhook, dessa forma, é possível filtrar elas com os seguintes parâmetros, esses passados pelo </span><span data-slate-node="text">`body`</span><span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnAlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMnRleHQlMjIlM0ElMjJTZW0lMjBvJTIwcGFyJUMzJUEybWV0cm8lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyYWxsJTIyJTJDJTIyY29kZSUyMiUzQXRydWUlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyJTIwcGFzc2FkbyUyMHZpYSUyMHF1ZXJ5JTJDJTIwZGlyZXRvJTIwcGVsYSUyMHVybCUyQyUyMGVzc2UlMjBlbmRwb2ludCUyMGFwZW5hcyUyMHJldG9ybmFyJUMzJUExJTIwYXMlMjBkaXN0cmlidWklQzMlQTclQzMlQjVlcyUyMG5vdmFzLiUyMFBhc3NhbmRvJTIwbyUyMHBhciVDMyVBMm1ldHJvJTIwY2l0YWRvJTJDJTIwbyUyMGVuZHBvaW50JTIwcGFzc2FyJUMzJUExJTIwYSUyMHJldG9ybmFyJTIwdG9kYXMlMjBhcyUyMGRpc3RyaWJ1aSVDMyVBNyVDMyVCNWVzJTIwZG8lMjB1c3UlQzMlQTFyaW8lMjBvdSUyMGRhJTIwY2FydGVpcmElMkMlMjBkZXBlbmRlbmRvJTIwZG8lMjB0aXBvJTIwZGUlMjB2JUMzJUFEbmN1bG8lMjBkbyUyMHdlYmhvb2slMkMlMjBkZXNzYSUyMGZvcm1hJTJDJTIwJUMzJUE5JTIwcG9zcyVDMyVBRHZlbCUyMGZpbHRyYXIlMjBlbGFzJTIwY29tJTIwb3MlMjBzZWd1aW50ZXMlMjBwYXIlQzMlQTJtZXRyb3MlMkMlMjBlc3NlcyUyMHBhc3NhZG9zJTIwcGVsbyUyMCUyMiU3RCUyQyU3QiUyMnRleHQlMjIlM0ElMjJib2R5JTIyJTJDJTIyY29kZSUyMiUzQXRydWUlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyLiUyMiU3RCU1RCU3RCU1RA==" data-slate-node="text">.</span></span></span></span>

```json
{
    "from": "0",
    "size": "20",
    "calendarInterval": "day",
    "year": "2024",
    "month": "1",
    "day": "1"
}


```

<table border="1" id="bkmrk-campo-descri%C3%87%C3%83o-%2A%2Ava" style="width: 99.6296%; border-collapse: collapse; border-style: solid;"><thead><tr><th style="width: 18.6601%;">CAMPO</th><th style="width: 65.3105%;">DESCRIÇÃO</th><th style="width: 16.0166%;">\*\*Valor padrão\*\*</th></tr></thead><tbody><tr><td style="width: 18.6601%;">from</td><td style="width: 65.3105%;">Índice inicial de corte para retorno das distribuições (paginador)</td><td style="width: 16.0166%;">0</td></tr><tr><td style="width: 18.6601%;">size</td><td style="width: 65.3105%;">Índice final de corte para retorno das distribuições (paginador)</td><td style="width: 16.0166%;">20</td></tr><tr><td style="width: 18.6601%;">calendarInterval</td><td style="width: 65.3105%;">Tipo de data de filtro das distribuições (year, month, day)</td><td style="width: 16.0166%;">year</td></tr><tr><td style="width: 18.6601%;">year</td><td style="width: 65.3105%;">Ano da distribuição</td><td style="width: 16.0166%;">null</td></tr><tr><td style="width: 18.6601%;">month</td><td style="width: 65.3105%;">Mês da distribuição</td><td style="width: 16.0166%;">null</td></tr><tr><td style="width: 18.6601%;">day</td><td style="width: 65.3105%;">Dia da distribuição</td><td style="width: 16.0166%;">null</td></tr></tbody></table>

##### **Verificação**

```yaml
GET: https://console4.oystr.com.br/api/v1/service/disthook/webhook/:id/callback

```

Para saber se há novas distribuições a serem visualizadas, é possível fazer uma requisição GET com final /:id/callback. O retorno trará a seguinte informação:

```json
{
  "needView": false
}

```

##### **Busca**

```yaml
GET: https://console4.oystr.com.br/api/v1/service/disthook/webhook

```

Para buscar por webhooks já cadastrados na conta, é possível fazer uma requisição GET com final /.

#####  

##### **Criação**

```yaml
POST: https://console4.oystr.com.br/api/v1/service/disthook/webhook
```

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Para criar um webhook, é possível fazer uma requisição </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">POST</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> com final </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">/</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">. O </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">body</span>`</span></span><span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnAlMjIlMkMlMjJjaGlsZHJlbiUyMiUzQSU1QiU3QiUyMnRleHQlMjIlM0ElMjJQYXJhJTIwY3JpYXIlMjB1bSUyMHdlYmhvb2slMkMlMjAlQzMlQTklMjBwb3NzJUMzJUFEdmVsJTIwZmF6ZXIlMjB1bWElMjByZXF1aXNpJUMzJUE3JUMzJUEzbyUyMCUyMiU3RCUyQyU3QiUyMnRleHQlMjIlM0ElMjJQT1NUJTIyJTJDJTIyY29kZSUyMiUzQXRydWUlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyJTIwY29tJTIwZmluYWwlMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyJTJGJTIyJTJDJTIyY29kZSUyMiUzQXRydWUlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyLiUyME8lMjAlMjIlN0QlMkMlN0IlMjJ0ZXh0JTIyJTNBJTIyYm9keSUyMiUyQyUyMmNvZGUlMjIlM0F0cnVlJTdEJTJDJTdCJTIydGV4dCUyMiUzQSUyMiUyMHRlciVDMyVBMSUyMG8lMjBzZWd1aW50ZSUyMGZvcm1hdG8lM0ElMjIlN0QlNUQlN0QlNUQ=" data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> terá o seguinte formato:</span></span></span>

```json
{
  "url": "url",
  "headers": {},
  "carteiraId": "id"
}

```

<table border="1" id="bkmrk-campo-descri%C3%87%C3%83o-url-" style="width: 99.3827%; height: 152.415px; border-collapse: collapse; border-style: solid;"><thead><tr style="height: 29.7017px;"><th style="width: 16.9901%; height: 29.7017px;">CAMPO</th><th style="width: 83.2079%; height: 29.7017px;">DESCRIÇÃO</th></tr></thead><tbody><tr style="height: 29.7017px;"><td style="width: 16.9901%; height: 29.7017px;">url</td><td style="width: 83.2079%; height: 29.7017px;">Url `POST` de disparo de notificação (obrigatório)</td></tr><tr style="height: 46.5057px;"><td style="width: 16.9901%; height: 46.5057px;">headers</td><td style="width: 83.2079%; height: 46.5057px;">Parâmetros para a url de disparo de notificação (opcional)</td></tr><tr style="height: 46.5057px;"><td style="width: 16.9901%; height: 46.5057px;">carteiraId</td><td style="width: 83.2079%; height: 46.5057px;">ID interno da carteira que deseja notificação</td></tr></tbody></table>

##### **Atualização**

```yaml
PUT: https://console4.oystr.com.br/api/v1/service/disthook/webhook/:id
```

Para atualizar um webhook, é possível fazer uma requisição PUT com final /:id. O body terá o seguinte formato:

```json
{
  "url": "url",
  "headers": {}
}
```

##### **Deleção**

```yaml
DELETE: https://console4.oystr.com.br/api/v1/service/disthook/webhook/:id
```

<span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true">Para deletar um webhook, é possível fazer uma requisição </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">DELETE</span>`</span></span><span data-slate-node="text"><span data-slate-leaf="true"><span data-slate-string="true"> com final </span></span></span><span data-slate-node="text"><span data-slate-leaf="true">`<span data-slate-string="true">/:id</span>`</span></span>