> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # search > Perform a semantic search across all documents. [ref-datasphere]: /docs/server-sdks/reference/typescript/rest/datasphere Perform a semantic search across all documents in the [Datasphere][ref-datasphere]. ### Schema ```yaml openapi: 3.1.0 info: title: API version: 1.0.0 paths: /api/datasphere/documents/search: post: operationId: subpackageDocuments_search_documents summary: Search documents description: >- Finds passages in the project's Datasphere knowledge store that are semantically relevant to a query. Use the results as grounded context for an AI application; use [List documents](/docs/apis/rest/documents/list-documents) to browse the source documents instead. #### Permissions The API token used to authenticate must have the following scope(s) enabled to make a successful request: _DataSphere_. [Learn more about API scopes](/docs/platform/your-signalwire-api-space). tags: - subpackage_documents responses: '200': description: The request has succeeded. content: application/json: schema: $ref: '#/components/schemas/Datasphere.SearchResponse' '400': description: The request is invalid. content: application/json: schema: $ref: '#/components/schemas/Types.StatusCodes.StatusCode400' '401': description: Access is unauthorized. content: application/json: schema: $ref: '#/components/schemas/Types.StatusCodes.StatusCode401' '422': description: The request contains invalid parameters. See errors for details. content: application/json: schema: $ref: '#/components/schemas/Datasphere.SearchStatusCode422' '500': description: An internal server error occurred. content: application/json: schema: $ref: '#/components/schemas/Types.StatusCodes.StatusCode500' requestBody: content: application/json: schema: $ref: '#/components/schemas/Datasphere.DocumentSearchRequest' tags: - name: subpackage_documents servers: - url: https://%7BYour_Space_Name%7D.signalwire.com description: SignalWire API components: schemas: uuid: type: string format: uuid description: Universal Unique Identifier. title: uuid Datasphere.DocumentSearchRequest: type: object properties: tags: type: array items: type: string description: Document tags. document_id: $ref: '#/components/schemas/uuid' description: Unique ID of a Document. query_string: type: string description: Search term. distance: type: number format: double minimum: 0 maximum: 78.3836717690617 description: >- Specifies how closely related the query is to the document. Low distance means high relevance and similarity. High distance means low relevance and similarity. count: type: integer minimum: 1 default: 5 description: Specifies number of returned Chunks. language: type: string default: en description: Language of the Document. pos_to_expand: type: array items: type: string default: - NOUN - VERB - ADJ - ADV description: Part of Speech considered for expansion or analysis. max_synonyms: type: integer minimum: 1 default: 10 description: Maximum number of synonyms to consider. required: - query_string title: Datasphere.DocumentSearchRequest Datasphere.Chunk: type: object properties: text: type: string description: A search result. document_id: $ref: '#/components/schemas/uuid' description: Unique ID of the Document. required: - text - document_id title: Datasphere.Chunk Datasphere.SearchResponse: type: object properties: chunks: type: array items: $ref: '#/components/schemas/Datasphere.Chunk' description: A list of search result chunks. required: - chunks title: Datasphere.SearchResponse TypesStatusCodesStatusCode400Error: type: string enum: - Bad Request title: TypesStatusCodesStatusCode400Error Types.StatusCodes.StatusCode400: type: object properties: error: $ref: '#/components/schemas/TypesStatusCodesStatusCode400Error' required: - error description: The request is invalid. title: Types.StatusCodes.StatusCode400 TypesStatusCodesStatusCode401Error: type: string enum: - Unauthorized title: TypesStatusCodesStatusCode401Error Types.StatusCodes.StatusCode401: type: object properties: error: $ref: '#/components/schemas/TypesStatusCodesStatusCode401Error' required: - error description: Access is unauthorized. title: Types.StatusCodes.StatusCode401 Types.StatusCodes.RestApiErrorItem: type: object properties: type: type: string description: The category of error. code: type: string description: A specific error code. message: type: string description: A description of what caused the error. attribute: type: - string - 'null' description: The request parameter that caused the error, if applicable. url: type: string description: A link to documentation about this error. required: - type - code - message - url description: Details about a specific error. title: Types.StatusCodes.RestApiErrorItem Datasphere.SearchStatusCode422: type: object properties: errors: type: array items: $ref: '#/components/schemas/Types.StatusCodes.RestApiErrorItem' description: List of validation errors. required: - errors description: The request contains invalid parameters. See errors for details. title: Datasphere.SearchStatusCode422 TypesStatusCodesStatusCode500Error: type: string enum: - Internal Server Error title: TypesStatusCodesStatusCode500Error Types.StatusCodes.StatusCode500: type: object properties: error: $ref: '#/components/schemas/TypesStatusCodesStatusCode500Error' required: - error description: An internal server error occurred. title: Types.StatusCodes.StatusCode500 ``` ## **Response Example** ### Response (200) ```json { "chunks": [ { "text": "Cristiano Ronaldo is the highest-paid football player in the world in 2024", "document_id": "acaa5c49-be5e-4477-bce0-48f4b23b7720" } ] } ``` ## **Example** ```typescript {9} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ project: "your-project-id", token: "your-api-token", host: "your-space.signalwire.com" }); const results = await client.datasphere.documents.search( "How do I reset my password?", { count: 5 }, ); for (const chunk of results.chunks) { console.log(chunk.document_id, chunk.text); } ``` > Perform a semantic search across all documents.