API documentation

A REST API over Ghanaian judgments, statutes and grounded summaries. All responses are JSON. Get a key from the developer dashboard.

Base URL

https://lawandlegal.app/api/public/v1

Authentication

Send your key as a bearer token on every request. Keys are shown once at creation; if you lose one, revoke it and issue another.
Authorization: Bearer sk_law_xxxxxxxxxxxxxxxxxxxx
Developer keys are the only accepted credential. Platform sign-in tokens from the legal workspace are rejected with 401 developer_key_required, and developer keys can never reach workspace data.

Environments

Every key belongs to one environment, identified by its prefix and echoed back on the X-Law-Environment response header.
  • sk_law_test_… — sandbox: 250 calls a month, 30 a minute, at most 3 results per call, and summaries return a deterministic stub with no billed generation.
  • sk_law_… — live: your plan's full quota, burst limit and corpus.

Scopes

A key only reaches the endpoints it was scoped for; anything else returns 403 insufficient_scope. Choose scopes when you issue the key.
  • case_law:readPOST /case-law/search
  • statutes:readPOST /statutes/search
  • documents:readGET /documents/{id}
  • summaries:generatePOST /summaries

Quotas and rate limits

Each plan sets a monthly call allowance and a per-minute burst limit. Exceeding the burst returns 429; exhausting the monthly allowance returns 402 quota_exceeded. Check your remaining allowance any time:
curl https://lawandlegal.app/api/public/v1/me \
  -H "Authorization: Bearer $LAW_API_KEY"

POST /case-law/search

Hybrid keyword and semantic search across judgments and rulings. Returns the source passage behind every hit, so results can be verified before citation.
curl -X POST https://lawandlegal.app/api/public/v1/case-law/search \
  -H "Authorization: Bearer $LAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"repudiation of contract","limit":5,"court":null}'
{
  "query": "repudiation of contract",
  "semantic": true,
  "count": 5,
  "results": [
    {
      "document_id": "…",
      "title": "Mensah v. Adjei",
      "citation": "[2019] GHASC 12",
      "court": "Supreme Court",
      "decided_at": "2019-05-14",
      "page_number": 7,
      "passage": "…",
      "score": 0.81
    }
  ]
}

POST /statutes/search

The same search restricted to legislation: statutes, constitutional instruments and legislative instruments. Optional doc_type narrows it further.
curl -X POST https://lawandlegal.app/api/public/v1/statutes/search \
  -H "Authorization: Bearer $LAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"limitation period","limit":5}'

GET /documents/{id}

Full metadata and the ordered passages of a single authority.
curl https://lawandlegal.app/api/public/v1/documents/1f0c…e2 \
  -H "Authorization: Bearer $LAW_API_KEY"

POST /summaries

A grounded summary built only from retrieved passages, with a numbered citation after each statement. Pass a query, or a document_id to summarise one authority. Available on Pro and Scale.
curl -X POST https://lawandlegal.app/api/public/v1/summaries \
  -H "Authorization: Bearer $LAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"When is time of the essence in a sale of land?"}'

Errors

Errors use the shape {"error": {"code": "...", "message": "..."}}.
  • 401 unauthenticated / invalid_key — missing or unknown key
  • 401 developer_key_required — a platform session token was sent
  • 403 insufficient_scope — the key is not scoped for that endpoint
  • 402 plan_upgrade_required — endpoint not in your plan
  • 402 quota_exceeded — monthly allowance used up
  • 403 client_suspended — the app has been disabled
  • 429 rate_limited — burst limit; retry after 60 seconds
  • 400 invalid_request — request body failed validation

Fair use

Results are extracts of public court and legislative material, provided for research. Verify against the official report before relying on any passage in filed work. Bulk redistribution of the corpus is not permitted.