Coelevate Documentation
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

FieldTypeRequiredDescription
asset_typearray of string or nullnoRestrict the search to these asset types, for example skill or knowledge_page. Omit to search every type. An unknown type is a 400.
max_resultsintegernoAt most this many results, 20 by default. With queries it applies to each query, not to the total.
queriesarray of string or nullnoUp to 20 independent searches, each answered on its own and returned in the same order. Send either queries or query, not both.
querystring or nullnoWhat to search for. Send either query or queries, not both.

Responses

StatusMeaning
200The request succeeded.
401The token is missing, expired or invalid.
403The token does not carry the scope this operation requires.
404No such project, or the token belongs to a different project.
422The request was not valid: a parameter or the body failed validation.

The 200 response body:

FieldTypeRequiredDescription
queriesarray of string or nullnoThe queries, when several were sent.
querystring or nullnoThe query, when one was sent.
resultsarray of (SearchResult or SearchQueryResults)yesFor 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.

FieldTypeRequiredDescription
asset_idstringyesThe asset's id.
asset_typestringyesThe asset's type.
labelstringyesThe asset's display name.
namestring or nullnoThe 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.
rankintegeryesThe asset's position in the returned list, starting at 1.

SearchQueryResults

The results of one query of several.

FieldTypeRequiredDescription
querystringyesThe query.
resultsarray of SearchResultyesWhat 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