REST API Reference
The SemiLayer REST API is available at https://api.semilayer.com. All endpoints
accept and return JSON. Authentication is via API key in the Authorization header.
Authentication
Use sk_ keys for server-side calls. Use pk_ keys for client-side calls — they
enforce Lens access rules.
For per-user access control, also pass the user JWT:
Base URL
Search
Search the vector index for a given query. Does not hit your source database.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
query | string | ✓ | Search query |
limit | number | Max results. Default: 10 | |
minScore | number | Minimum similarity score (0-1). Default: 0 | |
mode | string | semantic | keyword | hybrid. Default: lens config then semantic |
Response
Example
Similar
Find records similar to a given record using its stored vector.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | Source record primary key (as string) |
limit | number | Max results. Default: 10 | |
minScore | number | Minimum similarity score. Default: 0 |
Response
Same shape as Search: { results: SearchResult[], meta: {...} }
Example
Query
Read directly from your source database through the Bridge.
Must be explicitly enabled in the Lens config with rules.query.
Returns 403 Forbidden if not enabled.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
where | object | Equality filters. Keys are output field names | |
orderBy | object | array | { field, dir? } or array of same | |
limit | number | Default: 100 | |
offset | number | Row offset | |
cursor | string | Opaque pagination cursor from previous response | |
select | string[] | Field names to include in response |
Response
Example
Paginate with cursor:
Ingest Webhook
Trigger an ingest job from your application. Use an ik_ key.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
mode | string | ✓ | incremental | full | records |
Mode incremental — time-windowed sync using changeTrackingColumn:
Mode full — re-index all records from scratch:
Mode records — sync specific records:
Response
Example
Error Responses
All errors return a JSON body with an error field:
| Status | When |
|---|---|
400 | Invalid request body |
401 | Missing or invalid API key |
403 | Key does not have permission for this operation |
404 | Lens not found |
429 | Rate limit exceeded (SaaS only) — Retry-After header included |
502 | Embedding provider error |
Streaming (WebSocket)
See HTTP & WebSocket for the full WebSocket protocol reference, including connection setup, op frames, event frames, heartbeat handling, and close codes.