API ReferenceContext Repository
Search the project's context
Finds assets for a query by text match, best first.
POST /context/v1/search
Finds assets for a query by text match, best first. It never calls a model, so it is fast and has no per-call cost beyond the request itself. Restrict the types searched with asset_type. Send queries instead of query to run up to 20 independent searches, answered in the same order. An unknown asset type is a 400.
Requires the context:read scope.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
asset_type | array of string or null | no | Restrict the search to these asset types, for example skill or knowledge_page. Omit to search every type. An unknown type is a 400. |
max_results | integer | no | At most this many results, 20 by default. With queries it applies to each query, not to the total. |
queries | array of string or null | no | Up to 20 independent searches, each answered on its own and returned in the same order. Send either queries or query, not both. |
query | string or null | no | What to search for. Send either query or queries, not both. |
Responses
| Status | Meaning |
|---|---|
200 | The request succeeded. |
401 | The token is missing, expired or invalid. |
403 | The token does not carry the scope this operation requires. |
404 | No such project, or the token belongs to a different project. |
422 | The request was not valid: a parameter or the body failed validation. |
The 200 response body:
| Field | Type | Required | Description |
|---|---|---|---|
queries | array of string or null | no | The queries, when several were sent. |
query | string or null | no | The query, when one was sent. |
results | array of (SearchResult or SearchQueryResults) | yes | For one query, the assets it found, best first. For several, one entry per query, in the order sent. |
Shapes
The named shapes used above.
SearchResult
One asset a search found.
| Field | Type | Required | Description |
|---|---|---|---|
asset_id | string | yes | The asset's id. |
asset_type | string | yes | The asset's type. |
label | string | yes | The asset's display name. |
name | string or null | no | The asset's canonical name, projects/{project}/assets/{asset_id}. A request that takes an asset id in its body or query accepts this name in its place; a URL path takes the bare id. It is null when the id cannot be written in a canonical name. |
rank | integer | yes | The asset's position in the returned list, starting at 1. |
SearchQueryResults
The results of one query of several.
| Field | Type | Required | Description |
|---|---|---|---|
query | string | yes | The query. |
results | array of SearchResult | yes | What it found, best first. |
Example
A request body (ids and values are placeholders), saved as body.json:
{
"asset_type": [
"knowledge_page"
],
"max_results": 5,
"query": "refund policy"
}curl -sS -X POST "$API_URL/context/v1/search" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @body.json