Buscar a margem consignável disponível de um trabalhador
Abre ou reutiliza a autorização do trabalhador e consulta a margem disponível. O adaptador combina autorizar-consulta-dados-trabalhador (Manual 002 v1.15 §3.1) e consultar-dados-trabalhador (Manual 002 v1.15 §3.3) em uma única operação. É POST, não GET, porque abre um consentimento e transporta a evidência mais o CPF no corpo, sem expô-los no caminho ou na query string. O token de autorização nunca é retornado. A operação também emite consignado.margin.fetched, como no caminho de comando do Lender.
Janela de consentimento (Manual 002 v1.15 §5.6): dataHoraAutorizacaoDigital inicia dois prazos em dias corridos a partir da assinatura. A autorização pode ser consultada por 30 dias e uma solicitação pode usá-la por 45 dias. Ambos os limites são inclusivos.
Fora das janelas, o gateway recusa localmente antes de chamar a rede: 422, código MYS-0006, com orientação para obter nova autorização. Essa recusa não deve ser repetida com a mesma evidência expirada. Um dataHoraAutorizacaoDigital com offset diferente de UTC ou no futuro também retorna 422, com detalhe específico para correção do timestamp.
Uma rejeição de consentimento emitida pela própria Dataprev para um token obsoleto retorna 503 e pode ser repetida: o gateway descarta o token em cache e a próxima tentativa abre um novo consentimento com a mesma evidência.
Autorizações
JWT bearer token issued by the identity provider.
Corpo
Employer inscription TYPE code: 1 = CNPJ, 2 = CPF.
1, 2 "1"
The worker's grupo-1 consent evidence. Relayed verbatim; never synthesized here.
Worker CPF, exactly 11 digits — a CPF is eleven digits by definition (Manual 002 v1.15 §3.1.1 p.8 types the request field Número, 11 algarismos). Body-only by design: a path or query CPF leaks into access logs and spans.
^[0-9]{11}$"12345678901"
Employment bond matrícula.
"M-1"
Employer inscription number, relayed verbatim as Texto. Required: Manual 002 v1.15 §3.3.1 marks it Obrigatório on the worker data read.
1"12345678000199"
Client-chosen correlation reference echoed onto the emitted consignado.margin.fetched fact.
"req-1"
Resposta
OK
Instant the gateway observed this margin (UTC).
"2026-07-30T12:00:00Z"
Available consignable margin (decimal string, BRL). Never a float.
"1234.56"
Disposable remuneration base (decimal string, BRL). Never a float.
"5000.00"
How many consignados already sit active or suspended on this bond. Manual 002 v1.15 §3.3.2 p.17 publishes the ceiling: 9 per employment bond, so a bond at 9 takes no tenth however much margin it shows. Absent when the rail said nothing; 0 is a live count.
2
The consignado block on this employment bond (Manual 002 v1.15 §3.3.2 table p.18: 0 no block, 1 blocked by the worker, 2 blocked by the MTE). A blocked bond can show a POSITIVE margin and still take no consignado, so this is not derivable from availableMargin. Code 0 is a live value.
The correlation reference the request supplied.
"req-1"
The rail's own eligibility verdict for this worker. ABSENT when the read carried no verdict — which is NOT the same statement as false. Decode into a nullable boolean: collapsing absence into false recreates a refusal the rail never made.
true
The worker's gross pay for the period the margin was computed against (decimal string, BRL). The denominator the margin is a slice of. Absent when the rail did not publish it — never "0".
"7000.00"
WHY the rail refused (Manual 002 v1.15 §3.3.2 code table p.16: 1 legacy loan in eSocial, 2 legacy loan reported by the institution, 3 zero remuneration, 4 bond has a termination date, 5 no remuneration in the last competência, 6 invalid labour regime, 7 invalid worker category, 8 bond whose previous loan closed on termination, 9 employer not in the programme). The codes are not one kind: 3 and 5 clear with the next payroll competência, 4 never clears.
The share of severance pay available as collateral on this bond (Manual 002 v1.15 §3.3.2 p.17, NÚMERO(3,2)) — a PERCENT PER the manual, as an exact decimal string relayed verbatim and never converted. 40.00 means forty percent, not 0.40.
"40.00"
The BOND's termination date (Manual 002 v1.15 §3.3.2 p.15). A bond with one has no future payroll for an instalment to be discounted from. Absent when the bond is not terminated.
"2026-06-30T00:00:00Z"
The eSocial termination-reason code, relayed VERBATIM and never interpreted. Manual 002 v1.15 §3.3.2 p.15 types it "Número, 2 algarismos" and points at the eSocial "Motivos de Desligamento" table rather than reproducing it; JSON has no leading-zero literal, so a code beginning with 0 arrives one digit short and travels that way. Zero-pad to the published width before looking it up.
"2"

