> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/software-delivery-agent-apis/code-repository/keyword-search.md).

# Keyword Search

## GET /code-search

> Keyword search in a space

```json
{"openapi":"3.0.0","info":{"title":"API Specification","version":"1.111.0"},"servers":[{"url":"gateway/code/api/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"scheme":"bearer","type":"http"}},"schemas":{"TypesSearchResult":{"properties":{"file_matches":{"items":{"$ref":"#/components/schemas/TypesFileMatch"},"nullable":true,"type":"array"},"stats":{"$ref":"#/components/schemas/TypesSearchStats"}},"type":"object"},"TypesFileMatch":{"properties":{"file_name":{"type":"string"},"language":{"type":"string"},"matches":{"items":{"$ref":"#/components/schemas/TypesMatch"},"nullable":true,"type":"array"},"repo_branch":{"type":"string"},"repo_path":{"type":"string"}},"type":"object"},"TypesMatch":{"properties":{"after":{"type":"string"},"before":{"type":"string"},"fragments":{"items":{"$ref":"#/components/schemas/TypesFragment"},"nullable":true,"type":"array"},"line_num":{"type":"integer"}},"type":"object"},"TypesFragment":{"properties":{"match":{"type":"string"},"post":{"type":"string"},"pre":{"type":"string"}},"type":"object"},"TypesSearchStats":{"properties":{"per_repo_matches":{"items":{"$ref":"#/components/schemas/TypesRepoMatchCount"},"nullable":true,"type":"array"},"total_files":{"type":"integer"},"total_matches":{"type":"integer"}},"type":"object"},"TypesRepoMatchCount":{"properties":{"file_matches":{"type":"integer"},"repo_path":{"type":"string"},"total_matches":{"type":"integer"}},"type":"object"},"UsererrorError":{"properties":{"message":{"type":"string"},"values":{"additionalProperties":{},"type":"object"}},"type":"object"}}},"paths":{"/code-search":{"get":{"operationId":"searchSpace","parameters":[{"description":"Account Identifier for the Entity.","in":"query","name":"accountIdentifier","required":true,"schema":{"type":"string"}},{"description":"Organization Identifier for the Entity.","in":"query","name":"orgIdentifier","required":false,"schema":{"type":"string"}},{"description":"Project Identifier for the Entity.","in":"query","name":"projectIdentifier","required":false,"schema":{"type":"string"}},{"description":"The keyword search term.","in":"query","name":"query","required":true,"schema":{"type":"string"}},{"description":"The maximum number of search results to return.","in":"query","name":"limit","required":false,"schema":{"minimum":1,"type":"integer"}},{"description":"Whether the search term should be interpreted as a regular expression.","in":"query","name":"regex","required":false,"schema":{"default":false,"type":"boolean"}},{"description":"The paths of the repositories in the space to search. Can be repeated. Can't be combined with recursive search.","in":"query","name":"repo_path","required":false,"schema":{"items":{"type":"string"},"type":"array"}},{"description":"The result should include entities from child spaces.","in":"query","name":"recursive","required":false,"schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TypesSearchResult"}}},"description":"OK"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Bad Request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Not Found"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Internal Server Error"}},"summary":"Keyword search in a space","tags":["keyword_search"]}}}}
```

## GET /repos/{repo\_identifier}/code-search

> Keyword search in a repository

```json
{"openapi":"3.0.0","info":{"title":"API Specification","version":"1.111.0"},"servers":[{"url":"gateway/code/api/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"scheme":"bearer","type":"http"}},"schemas":{"TypesSearchResult":{"properties":{"file_matches":{"items":{"$ref":"#/components/schemas/TypesFileMatch"},"nullable":true,"type":"array"},"stats":{"$ref":"#/components/schemas/TypesSearchStats"}},"type":"object"},"TypesFileMatch":{"properties":{"file_name":{"type":"string"},"language":{"type":"string"},"matches":{"items":{"$ref":"#/components/schemas/TypesMatch"},"nullable":true,"type":"array"},"repo_branch":{"type":"string"},"repo_path":{"type":"string"}},"type":"object"},"TypesMatch":{"properties":{"after":{"type":"string"},"before":{"type":"string"},"fragments":{"items":{"$ref":"#/components/schemas/TypesFragment"},"nullable":true,"type":"array"},"line_num":{"type":"integer"}},"type":"object"},"TypesFragment":{"properties":{"match":{"type":"string"},"post":{"type":"string"},"pre":{"type":"string"}},"type":"object"},"TypesSearchStats":{"properties":{"per_repo_matches":{"items":{"$ref":"#/components/schemas/TypesRepoMatchCount"},"nullable":true,"type":"array"},"total_files":{"type":"integer"},"total_matches":{"type":"integer"}},"type":"object"},"TypesRepoMatchCount":{"properties":{"file_matches":{"type":"integer"},"repo_path":{"type":"string"},"total_matches":{"type":"integer"}},"type":"object"},"UsererrorError":{"properties":{"message":{"type":"string"},"values":{"additionalProperties":{},"type":"object"}},"type":"object"}}},"paths":{"/repos/{repo_identifier}/code-search":{"get":{"operationId":"searchRepo","parameters":[{"description":"Account Identifier for the Entity.","in":"query","name":"accountIdentifier","required":true,"schema":{"type":"string"}},{"description":"Organization Identifier for the Entity.","in":"query","name":"orgIdentifier","required":false,"schema":{"type":"string"}},{"description":"Project Identifier for the Entity.","in":"query","name":"projectIdentifier","required":false,"schema":{"type":"string"}},{"description":"The keyword search term.","in":"query","name":"query","required":true,"schema":{"type":"string"}},{"description":"The maximum number of search results to return.","in":"query","name":"limit","required":false,"schema":{"minimum":1,"type":"integer"}},{"description":"Whether the search term should be interpreted as a regular expression.","in":"query","name":"regex","required":false,"schema":{"default":false,"type":"boolean"}},{"in":"path","name":"repo_identifier","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TypesSearchResult"}}},"description":"OK"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Bad Request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Not Found"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsererrorError"}}},"description":"Internal Server Error"}},"summary":"Keyword search in a repository","tags":["keyword_search"]}}}}
```
