# Save an event search

Save a list of filter conditions and get back a `queryId` to pass to GET /v1/events.

Canonical: https://chikaraintel.com/docs/api/reference/search/create-event-search

```text
POST https://api.chikaraintel.com/v1/search/events
```

Authentication: `Authorization: Bearer <token>`.

## Parameters

- `query` (array, body, required) Chips, in order. A condition chip is `{ fieldType, label, value, operator }`. A join chip is `{ fieldType: "Operator", label, value }` with `AND` or `OR`, placed between conditions. See [search and filtering](/docs/concepts/search-and-filtering).

## Response

The payload is under `success`.

- `queryId` (uuid) Pass to `GET /v1/events?queryId=…`.
- `ignored_field_types` (array) Field types that were accepted but will not filter anything. Treat a non-empty list as an error.

Saving the same chips twice returns the same `queryId`, so it's safe to call before every search. Saved searches don't expire.

An invalid chip returns 400 with `Invalid chip data detected.`

## Examples

cURL:

```bash
curl -sS -X POST "https://api.chikaraintel.com/v1/search/events" \
  -H "Authorization: Bearer $CHIKARA_API_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "query": [
      {
        "fieldType": "EventType",
        "label": "move",
        "value": "move",
        "operator": "EQUAL"
      },
      {
        "fieldType": "Operator",
        "label": "AND",
        "value": "AND"
      },
      {
        "fieldType": "MoveType",
        "label": "Departure",
        "value": "Departure",
        "operator": "EQUAL"
      }
    ]
  }'
```

JavaScript:

```javascript
const BASE = "https://api.chikaraintel.com";
const headers = {
  Authorization: `Bearer ${process.env.CHIKARA_API_TOKEN}`,
  Accept: "application/json",
  "Content-Type": "application/json"
};

const res = await fetch(`${BASE}/v1/search/events`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    "query": [
      {
        "fieldType": "EventType",
        "label": "move",
        "value": "move",
        "operator": "EQUAL"
      },
      {
        "fieldType": "Operator",
        "label": "AND",
        "value": "AND"
      },
      {
        "fieldType": "MoveType",
        "label": "Departure",
        "value": "Departure",
        "operator": "EQUAL"
      }
    ]
  })
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);

const { success } = await res.json();
console.log(success);
```

Python:

```python
import os
import requests

BASE = "https://api.chikaraintel.com"
HEADERS = {
    "Authorization": f"Bearer {os.environ['CHIKARA_API_TOKEN']}",
    "Accept": "application/json",
}

res = requests.post(
    f"{BASE}/v1/search/events",
    headers=HEADERS,
    json={
        "query": [
            {
                "fieldType": "EventType",
                "label": "move",
                "value": "move",
                "operator": "EQUAL"
            },
            {
                "fieldType": "Operator",
                "label": "AND",
                "value": "AND"
            },
            {
                "fieldType": "MoveType",
                "label": "Departure",
                "value": "Departure",
                "operator": "EQUAL"
            }
        ]
    },
    timeout=30,
)
res.raise_for_status()
print(res.json()["success"])
```

Response:

```json
{
  "status": {
    "code": 201,
    "messages": []
  },
  "success": {
    "queryId": "9f2a3b4c-d6e7-4f8a-9b0c-d1e2f3a4b5f1",
    "ignored_field_types": []
  },
  "correlation_id": "5f0c2a9e4b7d4c1e"
}
```

## Used by

- search_events
