# OKF Index — full API reference > Generated from the catalog at https://okfindex.com · build `dev` > 1 endpoints · 2 structures · slice `/api/x402/legislation` > Short index: https://okfindex.com/llms.txt · Spec: https://okfindex.com/openapi.json · MCP: https://okfindex.com/mcp · Errors: https://okfindex.com/errors · Status: https://okfindex.com/status > Full reference. Public bundles and legislation are free to search and read on the site, API and MCP. Submission is free. Private bases require a personal account or API key from the global platform. - [Also available on PayAPI Market](https://payapi.market/api/okf-index) ## Free and paid services - [Free allowances and current prices](https://okfindex.com/api/pricing) - [Payment methods and conditions](https://okfindex.com/api/billing) - [First request and payment recovery](https://okfindex.com/skill.md) ## How to read - Every endpoint lists path, auth, parameters, body, response structure, errors and a call that runs. - `Pagina` is a reference: the fields are under **Structures**, at the end, once. - `(optional)` on a field means it may be absent; `(may be null)` means it comes with a null value. - 4xx/5xx errors under `/api/*` use RFC 9457 (`application/problem+json`) with `type`, `title`, `status`, `detail`, `instance` and `code` (catalog at `/errors` and `/errors.md`). - If any route or tool fails or returns an unexpected error, report it via `POST /api/contact` with `{"tipo":"problema","categoria":"erro_api","contexto":"METHOD /api/...","mensagem":"status and error received"}` (requires an account API key or OAuth token). - Slice what you need: `https://okfindex.com/llms-full.txt?prefix=/api/` returns only that branch. ## Authentication - `conta_ou_pagamento` — Account or payment. Without an account, only the fixed public samples open; the rest answers 402 with the price. With a free account (`Authorization: Bearer mmk_…`, `X-Api-Key`, the site session or OAuth sign-in in the MCP client), 5 lookups per day are free; after that, package or plan balance, prepaid credit (`Bearer cred_…`) or x402 per call. - `none` — Public. - `token` — Operator token `METRICS_TOKEN` as `Authorization: Bearer` (metrics). - `credito` — Credit token in `Authorization: Bearer cred_…` or `X-Credito`. For recovered x402 funds, use the wallet credential mmw_… in Bearer or X-Wallet-Token, issued through /api/auth/wallet/agent/start and /api/auth/wallet/agent/token. - `session` — Global session in the product's HttpOnly cookie; writes require exact Origin and X-CSRF-Token. ## Endpoints ## Brazilian legislation ### `GET /api/x402/legislation` Searches Brazilian federal laws for an agent, paid per call: up to 20 items, with no account. The search of `GET /api/legislation/search`, sold per call to agents with no account or prior free allowance. A request without payment receives HTTP 402 with the price; a paid request returns the items in the same response with the receipt in `cobranca`. Send at least one of `q`, `type`, `year` or `authority`. A refused search, a search with no matching law or an unavailable corpus is not charged. Full-text search covers title, description and body. Number/year uses an exact indexed lookup. Source metadata is not a verification of legal currency. No state or municipal laws in this collection. **Prepared results and when to use them** Downloading the covered corpus, building a text index and normalizing search results. Use GET /api/legislation/search first when its current access covers your task, and check source links and text versions. The x402 route sells this search per call through x402 or prepaid credit without an account, and a search with no matching law is not charged; it does not include legal review or a private-base subscription. Coverage is federal only. A source's revoked flag does not verify current legal force, and an unavailable corpus is not an empty result. - **URL:** `https://okfindex.com/api/x402/legislation` - **Auth:** `credito` — Credit token in `Authorization: Bearer cred_…` or `X-Credito`. For recovered x402 funds, use the wallet credential mmw_… in Bearer or X-Wallet-Token, issued through /api/auth/wallet/agent/start and /api/auth/wallet/agent/token. **Query** - `q` (string) — Number/year, such as 10406/2002, or words. At most 160 characters. LGPD, CDC and Código Civil aliases are supported. e.g.: `10406/2002`. - `type` (string) — constituicao, leis-ordinarias, leis-complementares, leis-delegadas or decretos-lei. - `year` (int) — Year, from 1800 to 2099. - `authority` (string) — Issuing body declared by the source: congresso-nacional, presidencia-da-republica or unknown. The provider is separate. - `after` (string) — Cursor from next. Do not generate a cursor. **Headers** - `authorization` (string) — `Bearer mmk_…` (API key) or `Bearer mmo_…` (OAuth): the paid call uses the account balance without another header. Without an account, use prepaid credit from `POST /api/credito` as `Bearer cred_…`. - `x-api-key` (string) — The mmk_… API key for this product. It identifies the account and authorizes its balance for the paid call. - `payment-signature` (string) — The signed x402 payment proof (base64): `PAYMENT-SIGNATURE` (v2) or `X-PAYMENT` (v1). - `x-wallet-token` (string) — To recover an x402 response within 24 hours, repeat the same request and payment proof. Send the payer wallet's `mmw_…` credential here, issued through `/api/auth/wallet/agent/start` and `/api/auth/wallet/agent/token`. There is no new charge. **Response `200`** Structure: `BuscaDeLeisAvulsa`. - `items` (object[]) — Up to 20 laws, as in `GET /api/legislation/search`: {id,title,description,type,year,number,authority,country,jurisdiction,uf,provider,source_url,lexml_url,downloaded_at,text_version,revoked,missing_text,sha256,api,url,okf_url}. - `next` (string, may be null) — URL of the next page on `GET /api/legislation/search` (with `after`); `null` at the end. - `cobranca` (CobrancaDaChamada) — How this call was paid. → see `CobrancaDaChamada` under **Structures**. **Errors** - `400` — Paid without a filter (`missing_input`, with `example`), or an invalid query. Not charged. - `401` — API key refused (`invalid_api_key`), OAuth token refused (`invalid_token`), credit refused (`credito_invalido`), test credit outside dev (`credito_simulado`), or recovery without wallet authentication (`wallet_proof_required`). The first x402 purchase needs no account. - `402` — No payment: `accepts` (x402, USDC on Base) with the price of this call, at least US$ 0.01; `credito.preco_desta_chamada`, the lower price with prepaid credit; and `pacotes` (the credit top-ups and how many calls each one pays). Credit without balance answers `saldo_insuficiente`. - `404` — No Brazilian federal law matched (`no_match`, with `message` on the format and an `example`): search by number/year or Portuguese words. Not charged. - `409` — Payment is in progress, the request differs from the original, or the amount was recovered as balance. Do not sign another authorization to retry the purchase. - `410` — The 24-hour response recovery period ended. The financial record remains; the same proof cannot cause another charge. - `429` — Reader busy. Retry after the stated delay. Not charged. - `503` — The corpus is unavailable. Do not treat this as no results. Not charged. **Example** ```sh curl -s -i 'https://okfindex.com/api/x402/legislation?q=10406/2002' ``` ## Structures ### `BuscaDeLeisAvulsa` The result of one paid legislation search. - `items` (object[]) — Up to 20 laws, as in `GET /api/legislation/search`: {id,title,description,type,year,number,authority,country,jurisdiction,uf,provider,source_url,lexml_url,downloaded_at,text_version,revoked,missing_text,sha256,api,url,okf_url}. - `next` (string, may be null) — URL of the next page on `GET /api/legislation/search` (with `after`); `null` at the end. - `cobranca` (CobrancaDaChamada) — How this call was paid. → see `CobrancaDaChamada` under **Structures**. ### `CobrancaDaChamada` The payment of a single call. - `via` (string) — `x402`, `credito` or the marketplace that already charged the call. - `preco_usd` (string) — The price charged for this call in US dollars, such as `0.01`: at least US$ 0.01 with single x402 payment; the unit price with credit. - `repetido` (bool) — `true` when the credit had already paid this request (the same `Idempotency-Key`): nothing was charged again. - `saldo_usd` (string, optional) — The credit balance after the call, such as `$0.99`; includes payment from the account balance.