# Search todos

`POST /v4/todos/search`

Searches todos in the todos index. Requires `todos:read`.

All request fields are optional. Blank or omitted `query` defaults to match-all; omitted `limit` defaults to 10 and is clamped to 1-200; negative `offset` clamps to 0; omitted `sort` defaults to `created_at desc`. Filter clauses address bare todo metadata keys such as `owner_type`, `assigned_to`, `list_id`, `completed_at`, and `is_priority_task`. `checklist` is an array of task objects mirroring `TodoResponse` and is not addressable as a scalar; its leaf paths `checklist.text`, `checklist.completed`, and `checklist.id` are addressable. Do not prefix fields with `meta.`.

Authentication (security requirement alternatives):

```json
[
  {
    "bearer_auth": [
      "todos:read"
    ]
  },
  {
    "oauth2_auth": [
      "todos:read"
    ]
  },
  {
    "apikey_auth": [
      "todos:read"
    ]
  }
]
```

- bearer_auth: http (bearer). API key or OAuth access token in Authorization header; scopes: todos:read
- oauth2_auth: oauth2. OAuth authorization code flow with mandatory S256 PKCE.; scopes: todos:read
- apikey_auth: apiKey, query api_key. API key in query string; scopes: todos:read

Request body: application/json

Type: object

Schema: [SearchRecordsRequest](https://docs.searchsoftware.nl/api/models/searchrecordsrequest.md)

- `query` (optional)
  Type: string
  
  Search query. Blank or omitted values default to *.
  
  Example:
  
  ```json
  "*"
  ```

- `limit` (optional)
  Type: integer, int32
  
  Maximum results. Defaults to 10 and is clamped to 1-200.
  
  Example:
  
  ```json
  10
  ```

- `offset` (optional)
  Type: integer, int32
  
  Zero-based offset. Defaults to 0 and negative values clamp to 0.
  
  Example:
  
  ```json
  0
  ```

- `filters` (optional)
  Type: array
  
  Additional filter groups ANDed with the immutable server-owned type scope.
  
  Items:
    Reference: [RecordSearchFilterGroup](https://docs.searchsoftware.nl/api/models/recordsearchfiltergroup.md); Type: object

- `sort` (optional)
  Type: array
  
  At most one entry; more than one is rejected. Empty or omitted defaults to created_at desc, or nearest first with near.
  
  Items:
    Reference: [RecordSearchSort](https://docs.searchsoftware.nl/api/models/recordsearchsort.md); Type: object

- `objects` (optional)
  Type: boolean
  
  Include hydrated object summaries in top-level data.objects when true. Defaults to false. File summaries (`file:<sqid>`) carry a `url`: a download URL that works without authentication until it expires, between 12 and 13 hours after the response. Request the record again for a fresh one.
  
  Example:
  
  ```json
  false
  ```

- `near` (optional)
  Reference: [RecordSearchNear](https://docs.searchsoftware.nl/api/models/recordsearchnear.md); Type: object

- `document_query` (optional)
  Type: string
  
  People, companies and jobs: a keyword that must appear in the record's document text (a person's parsed CV; the primary document of other records). At most 200 matching records are considered; data.document_matches_truncated says when there were more. Document text needs files:read, and through the MCP server the workspace's document text setting (403 DOCUMENT_TEXT_DISABLED).
  
  Example:
  
  ```json
  "AutoCAD"
  ```

Responses:

- 200: Todo search results

Content type: application/json

Type: object

Schema: [TodoSearchResponse](https://docs.searchsoftware.nl/api/models/todosearchresponse.md)

- `status` (required)
  Type: string
  
  Example:
  
  ```json
  "ok"
  ```

- `data` (required)
  Reference: [TodoSearchData](https://docs.searchsoftware.nl/api/models/todosearchdata.md); Type: object

- 400: Invalid request body

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_BODY",
    "status_code": 400,
    "message": "Invalid request body"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_BODY",
    "status_code": 400,
    "message": "Invalid request body"
  }
}
```

- 401: Invalid API key

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

- 403: Insufficient scope

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

- 422: Validation error

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

- 500: Internal server error

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

## Examples

### cURL

```bash
curl -X POST 'https://api.searchsoftware.nl/v4/todos/search' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}'
```

### TypeScript

```typescript
const body = `{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}`;

const response = await fetch('https://api.searchsoftware.nl/v4/todos/search', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}'''

response = requests.post(
    'https://api.searchsoftware.nl/v4/todos/search',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```

### Ruby

```ruby
require 'net/http'
require 'json'

uri = URI('https://api.searchsoftware.nl/v4/todos/search')
request = Net::HTTP::Post.new(uri)
request.body = <<-'BODY'.chomp
{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}
BODY
request['Authorization'] = 'Bearer YOUR_TOKEN'
request['Content-Type'] = 'application/json'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
data = JSON.parse(response.body)
```

### Go

```go
package main

import (
  "fmt"
  "io"
  "net/http"
  "strings"
)

func main() {
  body := strings.NewReader(`{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}`)
  req, _ := http.NewRequest("POST", "https://api.searchsoftware.nl/v4/todos/search", body)
  req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
  req.Header.Set("Content-Type", "application/json")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  data, _ := io.ReadAll(resp.Body)
  fmt.Println(string(data))
}
```

### PHP

```php
<?php
$body = <<<'BODY'
{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}
BODY;

$ch = curl_init('https://api.searchsoftware.nl/v4/todos/search');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_TOKEN', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

### Rust

```rust
use reqwest;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = reqwest::Client::new();
    let body = r#"{
  "query": "*",
  "limit": 10,
  "offset": 0,
  "filters": [
    {
      "op": "and",
      "clauses": [
        {
          "field": "status",
          "op": "eq",
          "value": "normal"
        }
      ]
    }
  ],
  "sort": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "objects": false,
  "near": {
    "place": "Amsterdam",
    "lat": 52.37,
    "lng": 4.9,
    "radius_km": 40
  },
  "document_query": "AutoCAD"
}"#;
    let response = client.post("https://api.searchsoftware.nl/v4/todos/search")
        .body(body)
        .header("Authorization", "Bearer YOUR_TOKEN")
        .header("Content-Type", "application/json")
        .send()
        .await?
        .text()
        .await?;
    println!("{}", response);
    Ok(())
}
```
