# Search

> Search across all entity types with full-text and natural language queries.

- **Category:** Guides
- HTML version: https://www.ondayzero.com/docs/guides/search
- All guides: https://www.ondayzero.com/docs/guides/index.md
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md

---

# Search

DayZero provides two search modes: **structured search** with filters and **natural language search** powered by AI.

## Full-Text Search

Search across all entity types in a single query:

```bash
curl "https://api.ondayzero.com/api/v1/search?search_term=acme&limit=20" \
  -H "Authorization: Bearer dz_your_token_here" \
  -H "x-business-id: YOUR_BUSINESS_ID"
```

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `search_term` | string | Search query, 1–200 characters (required) |
| `entity_type` | string | Limit to a single type (see below); omit to search everything |
| `date_from` / `date_to` | date (`YYYY-MM-DD`) | Restrict to records created in this range |
| `limit` | integer | Max results per entity type, 1–100 (10 if omitted). Always pass it explicitly |

Search is not cursor paginated: the response has no `next_cursor`, and the `cursor`, `direction`, `sort_by` and `descending` parameters of other list endpoints have no effect here. Within each type, results are ordered by relevance (an exact name match first) and then newest first. For types with amounts, a dollar amount such as `1250` or `$1,250.00` also matches records whose amount equals it.

### Response

Results are grouped by type:

```json
{
  "success": true,
  "data": {
    "results": {
      "customers": [ { "id": "…", "name": "Acme Corp", "email": "billing@acme.com" } ],
      "invoices": [ { "id": "…", "number": "INV-1042", "status": "sent", "total": 125000, "customer_id": "…" } ],
      "transactions": [],
      "metadata": { "search_term": "acme", "total_count": 2 }
    }
  }
}
```

Each item carries its `id`, its `entity_type` (singular, for example `invoice`), and the fields shown for that type; `metadata.total_count` counts the matches across all types returned. Types with no matches come back as empty arrays.

### Searchable Entity Types

| `entity_type` | What's searched |
|---------------|-----------------|
| `transactions` | Bank transactions (description, counterparty) |
| `invoices` | Invoice numbers and descriptions |
| `bills` | Bill numbers and descriptions |
| `journal_entries` | Entry descriptions |
| `customers` | Customer names and emails |
| `vendors` | Vendor names and emails |
| `ledgers` | Account names and descriptions |
| `products` | Product names and types |
| `variants` | Variant names, SKUs and manufacturer SKUs |
| `projects` / `contracts` | Project names and codes; contract numbers |
| `emails` | Inbox email subjects, senders and descriptions |
| `inventory_orders` | Purchase order names, PO numbers and descriptions |
| `shipments` | Shipment tracking numbers and descriptions |

An unknown `entity_type` returns a `200` with no result groups and `metadata.error` set to `Invalid entity_type: …` — check for it rather than assuming an empty result means no matches.

## Natural Language Search

Ask a question in plain language. An AI model interprets it and returns a ranked list of suggested results:

```bash
curl -X POST "https://api.ondayzero.com/api/v1/search/natural" \
  -H "Authorization: Bearer dz_your_token_here" \
  -H "x-business-id: YOUR_BUSINESS_ID" \
  -H "Content-Type: application/json" \
  -d '{"query": "What did we spend on software last month?"}'
```

The response has `interpreted_query` (how the question was understood), `results` and `total`. Each result has `entity_type`, `entity_id`, `title`, an optional `subtitle` and a `score` between 0 and 1:

```json
{
  "success": true,
  "data": {
    "interpreted_query": "transactions categorized as software expenses between 2026-08-01 and 2026-08-31",
    "results": [
      { "entity_type": "transaction", "entity_id": "…", "title": "GitHub", "subtitle": "-$210.00 · 2026-08-04", "score": 0.94 }
    ],
    "total": 1
  }
}
```

This endpoint returns the model's interpretation, not a database lookup, so do not treat `entity_id` as a record you can fetch or `title` as a ledger figure. To retrieve actual records and amounts, use the full-text search above, the entity list endpoints (e.g. `GET /api/v1/transactions`), or the aggregate [Reports](/docs/guides/reports).

## Searching the documentation

To find the right *endpoint* rather than your own data, use the docs search at `https://www.ondayzero.com/docs/search?q=void+invoice` — see [Using DayZero from an AI Agent](/docs/guides/ai-agents).
