# Query Files

<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Query Files"}
>
</Heading>

<MethodEndpoint
  method={"post"}
  path={"/api/v1/workspaces/{workspace_name}/files/_sql"}
  context={"endpoint"}
>
  
</MethodEndpoint>

Executes an SQL query on the workspace's file index and returns the raw response. The query must follow the [OpenSearch SQL Query syntax](https://docs.opensearch.org/latest/search-plugins/sql/sql/index/).The table must be `file`.

<Heading
  id={"request"}
  as={"h2"}
  className={"openapi-tabs__heading"}
  children={"Request"}
>
</Heading>

<ParamsDetails
  parameters={[{"description":"Type the name of the workspace.","in":"path","name":"workspace_name","required":true,"schema":{"description":"Type the name of the workspace.","title":"Workspace Name","type":"string"}},{"description":"The format of the response. For explanation, see [Opensearch response formats](https://docs.opensearch.org/latest/search-plugins/sql/response-formats/).","in":"query","name":"format","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The format of the response. For explanation, see [Opensearch response formats](https://docs.opensearch.org/latest/search-plugins/sql/response-formats/).","title":"Format"}}]}
>
  
</ParamsDetails>

<RequestSchema
  title={"Body"}
  body={{"content":{"application/json":{"schema":{"properties":{"cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The cursor for paginating through results.","title":"Cursor"},"fetch_size":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"The number of results to return per page.","title":"Fetch size"},"query":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The OpenSearch SQL query to execute.","title":"SQL query"}},"title":"SQLRequest","type":"object"}}},"required":true}}
>
  
</RequestSchema>

<StatusCodes
  id={undefined}
  label={undefined}
  responses={{"200":{"content":{"application/json":{"schema":{}}},"description":"Successful Response"},"422":{"content":{"application/json":{"schema":{"properties":{"detail":{"items":{"properties":{"ctx":{"title":"Context","type":"object"},"input":{"title":"Input"},"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location","type":"array"},"msg":{"title":"Message","type":"string"},"type":{"title":"Error Type","type":"string"}},"required":["loc","msg","type"],"title":"ValidationError","type":"object"},"title":"Detail","type":"array"}},"title":"HTTPValidationError","type":"object"}}},"description":"Validation Error"}}}
>
  
</StatusCodes>
