# Query a search profile

`POST /query`



[AI Search API guide](https://docs.contextual.io/tenants/tenant-apis/ai-search-api.md)

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "AI Search Api",
    "description": " ",
    "version": "1.7.5"
  },
  "security": [
    {
      "jwt": []
    }
  ],
  "servers": [
    {
      "url": "https://ai-search.{tenantId}.my.contextual.io/api/v1",
      "variables": {
        "tenantId": {
          "default": "YOUR-TENANT-ID"
        }
      }
    }
  ],
  "paths": {
    "/query": {
      "post": {
        "tags": [
          "Search"
        ],
        "summary": "Query a search profile",
        "parameters": [],
        "deprecated": false,
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "profileId": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 64,
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "indexId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "query": {
                    "type": "string",
                    "minLength": 1
                  },
                  "topK": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": [
                  "profileId",
                  "query"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid search query",
            "content": {}
          },
          "401": {
            "description": "Missing or invalid authorization header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Search profile or index preset not found",
            "content": {}
          },
          "409": {
            "description": "Search profile is not indexed yet",
            "content": {}
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "SearchResponse": {
        "type": "object",
        "properties": {
          "profileId": {
            "type": "string",
            "minLength": 3,
            "maxLength": 64,
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "indexId": {
            "type": "string",
            "minLength": 1
          },
          "generationId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,64}$"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "recordUri": {
                  "type": "string",
                  "minLength": 1
                },
                "sourceHash": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "documentId": {
                  "type": "string",
                  "minLength": 1
                },
                "chunkId": {
                  "type": "string",
                  "minLength": 1
                },
                "score": {
                  "type": "number"
                },
                "semanticRank": {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                },
                "keywordRank": {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                },
                "rerankScore": {
                  "type": "number"
                },
                "content": {
                  "type": "string"
                },
                "projections": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "number"
                        }
                      }
                    ]
                  }
                }
              },
              "required": [
                "recordUri",
                "documentId",
                "score",
                "content",
                "projections"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "profileId",
          "generationId",
          "items"
        ],
        "additionalProperties": false
      },
      "$ErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": [
              "string",
              "number"
            ]
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
```