Skip to main content
Why this route existsThe Synchronous Datalake Query is recommended for searches by CPF, CNPJ, OAB or Name — that is, to discover which lawsuits are linked to a person or company. For queries by lawsuit number (CNJ), the datalake data may be stale (or the lawsuit may not exist in our base yet), so that search alone is not recommended when you need a freshness guarantee on a specific lawsuit.The On-Demand Query solves exactly that: within the same synchronous POST, it can trigger a real-time extraction at the court when the lawsuit is missing or stale in our base, according to the rules you configure.
The On-Demand Query uses the same endpoint as the Synchronous Datalake QueryPOST /lawsuits — searching with search_type: "lawsuit_cnj". The difference is two new parameters, search.on_demand and search.cache_ttl_in_days, which decide whether it’s worth going to the court before responding.
🤖 Endpoint: POST https://lawsuits.production.judit.io/lawsuits. The response is still synchronous (HTTP 200 with the full JSON) — but when a court extraction is triggered, the timeout increases to up to 3 minutes. In testing, the average update time was 13 seconds, but during peak hours or court instability that time can grow.

How it works

cache_ttl_in_days only works with on_demand: trueWithout it, whether we go to the court depends only on the lawsuit existing or not in our base — not on how old it is.

Court trigger rules

on_demand: true, no cache_ttl_in_days

We only go to the court if the lawsuit number is not found in our database.

on_demand: true, with cache_ttl_in_days

If the lawsuit’s last update is less than the given number of days old, we respond straight from the datalake (no court call). If it’s older — or the lawsuit doesn’t exist in the base — we trigger a real-time extraction.

Request example

On-demand query by CNJ
In the example above: if lawsuit 9999999-99.9999.9.99.9999 was updated in our base less than 1 day ago, the response comes from the datalake. Otherwise, we trigger a court extraction before responding.

Request example (POST)

Adjust your HTTP client’s timeoutWhen a court extraction is triggered, the response can take up to 3 minutes. If your client’s timeout is shorter (many libraries default to 10-30s), the connection will be closed before the response arrives. Explicitly set a timeout of at least 180 seconds for this route.

Reading the response

Small difference from Hot StorageThe response follows the same pattern as the Synchronous Datalake Queryhas_lawsuits + request_id — but the list of lawsuits comes in the lawsuits field (instead of response_data). There is no field indicating whether the data came from cache or from a fresh court extraction; if your application needs that, use the Asynchronous Query, which exposes cached_response.
Lawsuits under judicial secrecyIf any instance of the lawsuit is under secrecy, the corresponding item in lawsuits comes with secrecy_level greater than 0 and most fields empty or absent (parties: [], steps: [], etc.), preserving only non-confidential data (court, county, city).

Full response example

Full structure of each item in the lawsuits array: see Lawsuit Schema. Note that the same CNJ can return more than one item (one per instance), and instances under judicial secrecy come with most fields empty.

When to use

BillingEvery request sent is counted and billed normally, per contract. When the response requires a court visit (fresh extraction), the cost is the same as an Asynchronous Query.

Common errors

Next steps