Motor CENPROT (novo módulo) v0.1.0
Motor CENPROT (novo módulo) v0.1.0#
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
Microserviço à parte, fora do AgRisk-Backend. Tudo aqui está a desenvolver (cards MOTOR-01 a MOTOR-07).O Motor não é chamado pelo front. Ele:1.
recebe a tarefa da query CENPROT pela Cloud Function de criação de consultas (tag Motor — Entrada);
2.
autentica e consulta o fornecedor por mTLS (tag Fornecedor CENPROT — Saída);
3.
normaliza, grava em cenprot (upsert por queryId), atualiza o item cenprot de
Queries.status[].services[] e, em falha, estorna créditos em Refund.
Erros do Motor seguem RFC 9457 (application/problem+json) com traceparent — contrato do Motor, não do AgRisk.Entrada: o payload abaixo segue o formato que o AgRisk já envia à Cloud Function
(DispatchVehicularQueryUseCase). Confirmar com o time do dispatcher como a função repassa ao worker.
Fornecedor: a spec oficial mascara paths e servers; base URL, token URL, scope, mTLS e credenciais só
chegam na homologação. Os paths abaixo são placeholders.
motorHost - Default: motor-cenprot.a-definir
HTTP Authentication, scheme: bearer Placeholder — o fornecedor exige mTLS com certificado da AgRisk (OpenAPI 3.0 não modela mTLS)
HTTP Authentication, scheme: bearer Token obtido em getAutenticacao
processCenprotTask#
Processar consulta CENPROT de uma queryAutenticação serviço-a-serviço (IAM do GCP / token interno) a definir com o time do dispatcher.Chamado pela Cloud Function de criação de consultas para o target com service_code = cenprot.
Idempotente por query_id: reexecutar sobrescreve o documento em cenprot e não estorna duas vezes.Cards: MOTOR-02 (consulta), MOTOR-03 (normalização), MOTOR-04 (persistência),
MOTOR-05 (desfecho em services[]), MOTOR-06 (estorno){
"query_id": "6fa29c22-6bab-424a-859e-a13a5c607e72",
"client_id": "string",
"company_id": "string",
"targets": [
{
"product_code": "string",
"service_code": "cenprot",
"max_attempts": 0,
"payload": {
"tax_id": "string"
}
}
]
}
| Name | In | Type | Required | Description |
|---|
| traceparent | header | string | false | Propagado quando recebido, gerado quando ausente (MOTOR-07) |
| body | body | CenprotTask | true | none |
{
"type": "http://example.com",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"code": "string",
"traceparent": "string"
}
Fornecedor CENPROT — Saída#
getAutenticacao#
getAutenticacao — obter token do fornecedor (mTLS)Chamada do Motor para o fornecedor, com o certificado da AgRisk por mTLS.
Token reutilizado enquanto válido; em 401 na consulta, renova uma vez e repete (MOTOR-01).
Path real a definir na homologação.| Status | Meaning | Description | Schema |
|---|
| 200 | OK | Token emitido | None |
| 401 | Unauthorized | Token ou certificado inválido | None |
| 403 | Forbidden | Permissões insuficientes | None |
getProtestosSacado#
getProtestosSacado — consultar Fator Protesto do documentoChamada do Motor para o fornecedor. Sempre um único documento em dados (RN-02).
Pacote contratado: Regional. Path real a definir na homologação.Tratamento (MOTOR-02 / MOTOR-05):429, 500 → retry com backoff; esgotado → ERRO com errorCode de indisponibilidade
400, 422 → ERRO documento rejeitado, sem retry
401, 403 → ERRO credencial, sem retry (após uma renovação de token no 401)
402 → ERRO pagamento/limite do fornecedor, sem retry
{
"dados": [
"string"
]
}
| Name | In | Type | Required | Description |
|---|
| body | body | object | true | none |
| » dados | body | [string] | false | none |
[
{
"identificacao": {
"uuid": "string",
"data_consulta": "2019-08-24T14:15:22Z",
"documento": "string",
"status": "consta",
"vlr_total_protestado": 0.1,
"qtd_total_protesto": 0,
"cnae_devedor": "string",
"qtd_cartorios_distintos": 0,
"qtd_cidades_distintas": 0
},
"cartorios": [
{
"codigo_uf": "string",
"codigo_cidade": "string",
"codigo_cartorio": "01",
"nome_cartorio": "string",
"telefone_cartorio": "string",
"endereco_cartorio": "string",
"qtd_total_protesto": 0,
"vlr_total_protestado": 0.1,
"titulos": [
{
"data": "15/01/2026",
"valor": 0.1
}
]
}
]
}
]
| Name | Type | Required | Restrictions | Description |
|---|
| anonymous | [ProviderRegionalPackage] | false | none | none |
| » identificacao | object | false | none | none |
| »» uuid | string | false | none | none |
| »» data_consulta | string(date-time) | false | none | none |
| »» documento | string | false | none | none |
| »» status | string | false | none | none |
| »» vlr_total_protestado | number(double) | false | none | none |
| »» qtd_total_protesto | integer | false | none | none |
| »» cnae_devedor | string¦null | false | none | none |
| »» qtd_cartorios_distintos | integer | false | none | none |
| »» qtd_cidades_distintas | integer | false | none | none |
| » cartorios | [object] | false | none | none |
| »» codigo_uf | string | false | none | IBGE — o Motor resolve para sigla |
| »» codigo_cidade | string | false | none | IBGE — o Motor resolve para nome do município |
| »» codigo_cartorio | string | false | none | none |
| »» nome_cartorio | string | false | none | none |
| »» telefone_cartorio | string¦null | false | none | none |
| »» endereco_cartorio | string¦null | false | none | none |
| »» qtd_total_protesto | integer | false | none | none |
| »» vlr_total_protestado | number(double) | false | none | none |
| »» titulos | [object] | false | none | none |
| »»» data | string | false | none | dd/mm/yyyy |
| »»» valor | number(double) | false | none | none |
Enumerated Values#
| Property | Value |
|---|
| status | consta |
| status | nada_consta |
Schemas#
{
"type": "http://example.com",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"code": "string",
"traceparent": "string"
}
Properties#
| Name | Type | Required | Restrictions | Description |
|---|
| type | string(uri) | false | none | none |
| title | string | false | none | none |
| status | integer | false | none | none |
| detail | string | false | none | none |
| instance | string | false | none | none |
| code | string | false | none | Código estável para ramificar |
| traceparent | string | false | none | none |
{
"query_id": "6fa29c22-6bab-424a-859e-a13a5c607e72",
"client_id": "string",
"company_id": "string",
"targets": [
{
"product_code": "string",
"service_code": "cenprot",
"max_attempts": 0,
"payload": {
"tax_id": "string"
}
}
]
}
Properties#
| Name | Type | Required | Restrictions | Description |
|---|
| query_id | string(uuid) | true | none | none |
| client_id | string | true | none | none |
| company_id | string | true | none | none |
| targets | [object] | true | none | none |
| » product_code | string | false | none | none |
| » service_code | string | false | none | none |
| » max_attempts | integer | false | none | none |
| » payload | object | false | none | none |
| »» tax_id | string | false | none | CPF/CNPJ só dígitos (CNPJ alfanumérico aceito) |
Enumerated Values#
| Property | Value |
|---|
| service_code | cenprot |
{
"identificacao": {
"uuid": "string",
"data_consulta": "2019-08-24T14:15:22Z",
"documento": "string",
"status": "consta",
"vlr_total_protestado": 0.1,
"qtd_total_protesto": 0,
"cnae_devedor": "string",
"qtd_cartorios_distintos": 0,
"qtd_cidades_distintas": 0
},
"cartorios": [
{
"codigo_uf": "string",
"codigo_cidade": "string",
"codigo_cartorio": "01",
"nome_cartorio": "string",
"telefone_cartorio": "string",
"endereco_cartorio": "string",
"qtd_total_protesto": 0,
"vlr_total_protestado": 0.1,
"titulos": [
{
"data": "15/01/2026",
"valor": 0.1
}
]
}
]
}
Properties#
| Name | Type | Required | Restrictions | Description |
|---|
| identificacao | object | false | none | none |
| » uuid | string | false | none | none |
| » data_consulta | string(date-time) | false | none | none |
| » documento | string | false | none | none |
| » status | string | false | none | none |
| » vlr_total_protestado | number(double) | false | none | none |
| » qtd_total_protesto | integer | false | none | none |
| » cnae_devedor | string¦null | false | none | none |
| » qtd_cartorios_distintos | integer | false | none | none |
| » qtd_cidades_distintas | integer | false | none | none |
| cartorios | [object] | false | none | none |
| » codigo_uf | string | false | none | IBGE — o Motor resolve para sigla |
| » codigo_cidade | string | false | none | IBGE — o Motor resolve para nome do município |
| » codigo_cartorio | string | false | none | none |
| » nome_cartorio | string | false | none | none |
| » telefone_cartorio | string¦null | false | none | none |
| » endereco_cartorio | string¦null | false | none | none |
| » qtd_total_protesto | integer | false | none | none |
| » vlr_total_protestado | number(double) | false | none | none |
| » titulos | [object] | false | none | none |
| »» data | string | false | none | dd/mm/yyyy |
| »» valor | number(double) | false | none | none |
Enumerated Values#
| Property | Value |
|---|
| status | consta |
| status | nada_consta |
Modificado em 2026-09-23 20:18:30