# GET /api/v1/search

> Global search

- **Tag:** search
- **Operation ID:** `search_entities_api_v1_search_get`

## Description

Search across products, variants, customers, invoices, vendors, and more.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `entity_type` (query, string, optional) — Limit to: products, variants, customers, invoices, vendors, transactions, journal_entries, ledgers, emails
- `date_from` (query, string, optional) — Results after this date (ISO 8601: YYYY-MM-DD)
- `date_to` (query, string, optional) — Results before this date (ISO 8601: YYYY-MM-DD)
- `search_term` (query, string, required)
- `limit` (query, integer, optional) — Pagination limit
- `cursor` (query, string, optional) — Cursor for pagination
- `direction` (query, string, optional) — Pagination direction: 'next' or 'prev'
- `include_total_count` (query, boolean, optional) — Whether to include total count (expensive - avoid if possible)
- `sort_by` (query, string, optional) — Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None.
- `descending` (query, boolean, optional) — Sort direction: true for descending (newest/largest first), false for ascending

## Responses

### 200 — Successful Response

Schema: `SearchResponse`

- `success` (boolean) — Whether search completed successfully.
- `results` (SearchResults · required) → `SearchResults` — Search results by entity type.
  - `products` (array · object) — Matching products.
  - `variants` (array · object) — Matching product variants.
  - `invoices` (array · object) — Matching invoices.
  - `bills` (array · object) — Matching bills.
  - `inventory_orders` (array · object) — Matching inventory orders.
  - `shipments` (array · object) — Matching shipments.
  - `customers` (array · object) — Matching customers.
  - `vendors` (array · object) — Matching vendors.
  - `journal_entries` (array · object) — Matching journal entries.
  - `transactions` (array · object) — Matching transactions.
  - `ledgers` (array · object) — Matching ledger accounts.
  - `emails` (array · object) — Matching emails.
  - `metadata` (SearchMetadata · required) → `SearchMetadata` — Search metadata.
    - `total_count` (integer · required) — Total matches across all entity types.
    - `search_term` (string · required) — The search term used.

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X GET 'https://api.ondayzero.com/api/v1/search' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/search', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
  },
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

response = httpx.get("https://api.ondayzero.com/api/v1/search", headers=headers)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/search/search-entities
- OpenAPI slice: https://www.ondayzero.com/docs/reference/search/search-entities/openapi.json
- Other endpoints in **search**: https://www.ondayzero.com/docs/reference/search
