> ## Documentation Index
> Fetch the complete documentation index at: https://docs.search-artemis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /search

## Header

<ParamField header="Authorization" type="string" required>
  Bearer authentication header of the form `Bearer <API_KEY>`, where `<API_KEY>` is your organization's API key.
</ParamField>

## Body

<ParamField query="projectId" type="string" required>
  The project ID to perform the search on. This is displayed in the "Project Details" card on the project page.
</ParamField>

<ParamField query="searchQuery" type="string" required>
  The search query string. For example, "companies that require HIPAA compliance"
</ParamField>

<ParamField query="numberOfBatches" type="integer" minimum="10" maximum="70" required>
  The number of batches of synthetic data to generate for the search. This parameter may range from 10 to 70. Increasing this may improve search quality but will increase response time.
</ParamField>

<ParamField query="topK" type="integer" required>
  The maximum number of results to return. This parameter may range from 1 to Infinity. Changing this parameter will not affect search time.
</ParamField>

<ParamField query="filterQuery" type="string">
  The filter query string which enables you to filter the search results using the filter columns in the dataset. Learn more about filter queries [here](/search/search-parameters#filter-query).
</ParamField>

## Success Response

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="state" type="success">
      The state of the search will be "success" to indicate that the search was successful.
    </ResponseField>

    <ResponseField name="tags" type="string[]">
      The tags associated with the search results
    </ResponseField>

    <ResponseField name="proba" type="number[]">
      The probability that the result matches the search query, ranging from 0 to 1.
    </ResponseField>

    <ResponseField name="labels" type="(0|1)[]">
      The labels associated with the search results. 0 means the result does not match the search query, 1 means the result matches the search query.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="success" type="true">
  This field is always true if the search was successful.
</ResponseField>

<ResponseField name="error" type="null">
  This field is always null if the search was successful.
</ResponseField>

<RequestExample>
  ```js Example Request theme={null}
  fetch('https://api.search-artemis.com/search', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer YOUR_API_KEY`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      projectId: 'YOUR_PROJECT_ID',
      searchQuery: 'companies that require HIPAA compliance',
      filterQuery: 'company_size == "large"',
      numberOfBatches: 50,
      topK: 4,
    })
  })
  .then(response => response.json())

  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "data": {
      "state": "success",
      "tags": [
        "Acme Healthcare Solutions",
        "HealthGuard Technologies",
        "PatientPrivacy Inc.",
        "Compliance Med"
      ],
      "proba": [
        0.95,
        0.89,
        0.87,
        0.85
      ],
      "labels": [
        1,
        0,
        1,
        0
      ]
    },
    "success": true,
    "error": null
  }
  ```
</ResponseExample>

## Error Response

<ResponseField name="data" type="null">
  This field is always null if the search was not successful.
</ResponseField>

<ResponseField name="success" type="false">
  Indicates the search was not successful.
</ResponseField>

<ResponseField name="error" type="object">
  An error object containing the error message and code.

  <Expandable title="properties">
    <ResponseField name="code" type="error_code">
      The error code. Refer to the table below for possible error codes.

      | Error Code                    | Description                                                                                                    |
      | ----------------------------- | -------------------------------------------------------------------------------------------------------------- |
      | `invalid_json`                | The request body is not valid JSON.                                                                            |
      | `invalid_request_body`        | The request body schema did not match the expected schema.                                                     |
      | `internal_server_error`       | An internal server error occurred. Please contact support.                                                     |
      | `no_bearer_token`             | The request is missing the `Authorization` header.                                                             |
      | `invalid_bearer_token`        | The API key is invalid.                                                                                        |
      | `filter_columns_not_found`    | The filter query attempted to filter on a column that does not exist.                                          |
      | `filter_query_error`          | The filter query is not valid. Learn more about filter queries [here](/search/search-parameters#filter-query). |
      | `dataset_embedding_not_found` | The dataset uploaded is missing the 'embedding' column.                                                        |
      | `dataset_tag_not_found`       | The dataset uploaded is missing the 'tag' column.                                                              |
      | `dataset_empty`               | The dataset uploaded is empty.                                                                                 |
      | `invalid_top_k`               | The top K is not valid. It must be an integer between 1 and Infinity.                                          |
      | `invalid_number_of_batches`   | The number of batches is not valid. It must be an integer between 10 and 70.                                   |
      | `invalid_search_query`        | The search query is invalid. It must be a non-empty string.                                                    |
    </ResponseField>

    <ResponseField name="message" type="string">
      The error message explaining the error in detail.
    </ResponseField>
  </Expandable>
</ResponseField>
