> 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/filters.md).

# Filters

Filter Knowledge Base retrieve requests.

Use filters to restrict which documents a Knowledge Base searches. Filters are most useful for legislation Knowledge Bases, especially provincial and municipal collections.

## Recommended legislation filters

For most legislation queries, start with:

```json
{
  "filters": {
    "principal": true,
    "repealed": false
  }
}
```

These filters exclude amendment or commencement works and repealed legislation.

## Place filters

Use `frbr_place` or `frbr_place__in` when you know the country, province, municipality or other locality you want to search.

```json
{
  "filters": {
    "frbr_place": "za-cpt"
  }
}
```

```json
{
  "filters": {
    "frbr_place__in": ["za-cpt", "za-jhb"]
  }
}
```

`frbr_place` is usually the safest place filter because it includes both the country and locality code.

## Other filters

The retrieve API also supports:

* `work_frbr_uri` and `work_frbr_uri__in`;
* `expression_frbr_uri` and `expression_frbr_uri__in`;
* `frbr_country`;
* `frbr_doctype` and `frbr_doctype__in`;
* `frbr_subtype` and `frbr_subtype__in`;
* `repealed`;
* `commenced`;
* `principal`.

Use exact filters only when your application already knows the relevant value. For exploratory search, start broad and then narrow the query.

## Example

```json
{
  "text": "informal trading permit",
  "top_k": 5,
  "filters": {
    "principal": true,
    "repealed": false,
    "frbr_place": "za-cpt"
  }
}
```

See the [retrieve endpoint reference](broken://pages/GxCVmalmkkGrVfvlFuXp) for the full request schema.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.laws.africa/knowledge-bases/filters.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
