> For the complete documentation index, see [llms.txt](https://developers.laws.africa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.laws.africa/knowledge-bases/concepts.md).

# Concepts

Knowledge Bases retrieve legal context from maintained Laws.Africa collections. They are designed for applications that need search and grounding, not full local copies of legal content.

## Knowledge Base codes

Each Knowledge Base has a unique `code`. You use the code in API URLs:

```
POST /ai/v1/knowledge-bases/{code}/retrieve
```

List the Knowledge Bases available to your account with:

```
GET /ai/v1/knowledge-bases
```

## Places and content types

Knowledge Bases are scoped by place and content type. A place can be a country, province, municipality or other locality.

The current content types are:

* legislation;
* judgments.

For legislation, place identifiers follow the FRBR place codes used by Akoma Ntoso and the Content API. For example, `za` is South Africa and `za-cpt` is the City of Cape Town.

## Retrieve requests

A retrieve request includes:

* `text`: the query text to match;
* `top_k`: the maximum number of results to return;
* `filters`: optional metadata filters.

```json
{
  "text": "delict slip and trip",
  "top_k": 5,
  "filters": {}
}
```

`top_k` defaults to `10`. The maximum is `100`.

## Retrieve results

Each result includes:

* `content.text`: the matched legal text or summary;
* `metadata`: source information such as title, FRBR URI, dates and public URLs;
* `score`: the similarity score.

Lower scores indicate a closer match.

Use public URLs from result metadata when showing results to users or grounding AI responses. They let users inspect the source material.

## Query text

You can send a user's question directly as `text`, but AI workflows often get better matches when a model first rewrites the question as a focused legal search query.

For example, a user may ask:

```
Can my landlord lock me out without a court order?
```

Your application might query:

```
eviction lockout without court order residential tenant
```

## Plans and limits

Knowledge Bases are available on the platform's Sandbox, Build and Scale plans. Plans differ by country coverage, content availability and rate limits. See [Pricing and plans](/get-started/pricing.md) for developer-facing details.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.laws.africa/knowledge-bases/concepts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
