Skip to content

Documentation

API reference

A REST API over cases, documents, deadlines, drafting, and audit. Every request is scoped to a tenant and every response is filtered by role.

This is an overview of the endpoint surface. Request and response schemas, error codes, and a sandbox tenant are issued with your API credentials — ask through contact sales.

Authentication

Every request carries a bearer token. The token is a JWT whose claims include the tenant identifier and the caller role; both are validated on each request, and the tenant claim is what row-level security keys off. A token that is valid but belongs to another tenant returns an empty result, not a permission error, so that identifiers cannot be probed.

curl https://api.example.com/api/cases \
  -H "Authorization: Bearer $LEGALAI_TOKEN"

Conventions

Cases

A case is the unit everything else hangs off. Case identifiers follow the pattern EC-YYYY-NNNN-env and are carried through every subsequent call.

MethodPathDescription
GET/api/casesList cases visible to the caller within their tenant.
POST/api/casesCreate a case. Returns the assigned case identifier.
GET/api/cases/:caseIdFetch a single case with its facts and status.
DELETE/api/cases/:caseIdDelete a case and its material. Audit entries survive.

Documents and upload

Files are never posted through the API directly. Request a presigned URL, upload to storage, then register the result.

MethodPathDescription
POST/api/upload/presign-uploadGet a short-lived signed URL for a single file.
POST/api/upload/presign-downloadGet a short-lived signed URL to read a stored file.
GET/api/documents/:caseIdList documents attached to a case.
GET/api/documents/:caseId/:documentIdFetch document metadata and extraction status.
GET/api/documents/:caseId/:documentId/downloadRedirect to a signed download URL.
DELETE/api/documents/:caseId/:documentIdRemove a document from a case.

Deadlines

Calculations use New Zealand working days and observed public holidays. Responses include the date each period was counted from so the working can be checked.

MethodPathDescription
POST/api/deadlines/calculateCalculate procedural deadlines from a set of case dates.
GET/api/deadlines/holidays/:yearList the public holidays applied for a given year.

Generation

Drafting runs asynchronously. A generation request returns a job; the document appears against the case when the linter and citation validator have both passed.

MethodPathDescription
GET/api/generation/typesList the document types available to the tenant.
POST/api/generation/generateGenerate a document of a given type for a case.
POST/api/generation/statement-of-claimGenerate a statement of claim directly.

Corpus retrieval

Search across statutes and judgments. Statute sources rank ahead of case law, and every result carries the citation needed to verify it.

MethodPathDescription
POST/api/corpus/searchSearch the corpus and return cited passages.
GET/api/corpus/freshnessReport how recently each source was last ingested.

Audit

The audit log is append-only. Entries record the actor, the case, and the action — not the contents of files.

MethodPathDescription
GET/api/audit/case/:caseIdRead the audit trail for a case.
GET/api/audit/export/:caseIdExport a case audit trail for an external reviewer.

Errors

Errors return a JSON body with a stable code, a human-readable message, and the request identifier to quote when asking about it. Validation failures list the offending fields. Nothing in an error body reveals data from another tenant.

Next

Provisioning, roles, and SSO are covered in the tenant setup guide.