Search across memories and episodes with filters.

POST /v1/search

Search across memories and episodes with fine-grained filters. Returns context and matching episodes.

Request

POST /v1/search
Content-Type: application/json
Authorization: Bearer <api-key>
X-Tenant-Id: my-app

Body

{
  "query": "authentication middleware JWT",
  "limit": 20,
  "offset": 0,
  "filters": {
    "source": "github",
    "episode_type": "code",
    "time_range": "30d",
    "namespace": "engineering"
  }
}

Parameters

| Field | Type | Required | Description | |---|---|---|---| | query | string | Yes | Search query | | limit | integer | No | Max results (default: 20) | | offset | integer | No | Pagination offset (default: 0) | | filters | object | No | Filter criteria |

Filters

| Field | Type | Description | |---|---|---| | source | string | Filter by source connector (e.g., "slack", "github") | | episode_type | string | Filter by episode type (e.g., "message", "code") | | time_range | string | Time range filter (e.g., "1h", "24h", "7d", "30d") | | namespace | string | Filter by namespace |

Response

Status: 200 OK

{
  "context": "Refactored auth middleware to support JWT and API key authentication. Added per-tenant rate limiting.",
  "confidence": 0.87,
  "latency_ms": 34,
  "episodes": [
    {
      "id": "ep_def456",
      "actor_name": "bob",
      "source_connector": "github",
      "episode_type": "code",
      "content_preview": "Refactored auth middleware to support JWT...",
      "occurred_at": "2026-03-13T16:45:00Z"
    }
  ],
  "total_episodes": 8
}

| Field | Type | Description | |---|---|---| | context | string | Synthesized context from matching episodes | | confidence | float | Confidence score | | latency_ms | integer | Server-side processing time | | episodes | array | Matching episodes | | total_episodes | integer | Total matching episodes |

Example

# Search with filters
curl -X POST https://api.cortexdb.io/v1/search \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: my-app" \
  -d '{"query":"CORTEX-789","limit":10}'

# Search with time range
curl -X POST https://api.cortexdb.io/v1/search \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: my-app" \
  -d '{"query":"deployment issues","filters":{"time_range":"7d"}}'