> For the complete documentation index, see [llms.txt](https://api.clearinghouse.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.clearinghouse.net/api-reference-v2p1/endpoints/case-text-search.md).

# Case Text Search

### Get cases by full-text search (string).

<mark style="color:blue;">`GET`</mark> `https://clearinghouse.net/api/v2p1/cases/?text=search_string`

**Headers**

| Name                                            | Type   | Description                                                                                                                    |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| Authorization<mark style="color:red;">\*</mark> | String | <p>Authorization</p><p><code>Token XXXXXXXXXXX</code></p><p>where</p><p><code>XXXXXXXXXXX</code></p><p>is the token string</p> |

{% tabs %}
{% tab title="200 Cases successfully retrieved" %}

{% endtab %}

{% tab title="400: Bad Request No results, key not found, or invalid parameter" %}

```
\\ No results
\\ Example query endpoint: /api/v2p1/cases/?text=zzznomatch
["No results for {'text': 'zzznomatch'}"]

\\ Key not found
\\ Example query endpoint: /api/v2p1/cases?test_key=1
["API Error: Key: test_key, Value: 1 not found."]
```

{% endtab %}

{% tab title="401 Permission denied" %}

```javascript
{
    "detail":"Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

Returns all cases that have at least one document matching the search query. Note: this search uses the same index as the [Document text search](/api-reference-v2p1/endpoints/documents.md#text-search). Searching cases by `text` returns cases that have at least one document matching the query. Search is powered by PostgreSQL full-text search and runs across the following fields, in descending order of relevance weight:

| Field          | Weight      |
| -------------- | ----------- |
| Case name      | A (highest) |
| Document title | B           |
| Case summary   | C           |
| Document text  | D (lowest)  |

Queries are matched using PostgreSQL's `SearchQuery`, which supports natural language stemming (e.g. "running" matches "run"). Multi-word queries are treated as AND by default — all terms must appear somewhere across the searched fields.

**Example**

{% tabs %}
{% tab title="URL" %}

```
https://clearinghouse.net/api/v2p1/cases?text=solitary+confinement
```

{% endtab %}

{% tab title="python" %}

```python
import requests

url = "https://clearinghouse.net/api/v2p1/cases?text=solitary+confinement"
headers = { 'Authorization': 'Token XXXXXXXXXX',
'User-Agent': 'Chrome v22.2 Linux Ubuntu'
}
response = requests.request("GET", url, headers=headers, data={})

print(response.text)
```

{% endtab %}
{% endtabs %}


---

# 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://api.clearinghouse.net/api-reference-v2p1/endpoints/case-text-search.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.
