# POST /service-requests/search

**Resource:** [Service Requests](./service-requests.md)  
**Scopes:** `service-requests:read`  
**Write operation:** no

Semantic search across the workspace's service requests using vector embeddings (Voyage voyage-3, 1024 dimensions). Returns results ranked by cosine similarity. Useful for: finding duplicate requests before filing, grouping related open tickets, retrieving historical resolutions. Scoped per-workspace -- cross-company search is only available via the internal agent-write webhook.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `query` | body | string | yes | Natural-language description of what you are looking for (max 5000 chars) |
| `status` | body | string | no | Optional: restrict results to a single status: pending, in_progress, completed, rejected, cancelled, backlog |
| `limit` | body | number | no | Max results to return, 1-50 (default 10) |
| `threshold` | body | number | no | Minimum cosine similarity 0-1 (default 0.5). Lower = broader recall. |

## Request example

```bash
curl -X POST https://ucqwijexmjctglmrxlej.supabase.co/functions/v1/api/v1/service-requests/search \
  -H "Authorization: Bearer tp_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "query": "missing status filter on list opportunities",
    "status": "pending",
    "limit": 5
  }'
```

## Response example

```json
{
  "data": [
    {
      "id": "f112de7b-c7df-4193-bacd-2d43c31c1f11",
      "title": "Add status filter to list_opportunities",
      "description": "Cannot filter opportunities by status (won/lost/open).",
      "status": "pending",
      "similarity": 0.8621,
      "created_at": "2026-04-19T05:08:56.498025+00:00"
    }
  ],
  "meta": { "credits_remaining": 3456 }
}
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`