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

# Search Repositories

> Searches for repositories across all authenticated SCM hosts.

`Unary` · [`Runners`](/docs/api-reference/generated/runner/overview)

Searches for repositories across all authenticated SCM hosts.

Use this method to:

* List available repositories
* Search repositories by name or content
* Discover repositories for environment creation

Returns repositories from all authenticated SCM hosts in natural sort order.
If no repositories are found, returns an empty list.

### Examples

* List all repositories:

  Returns up to 25 repositories from all authenticated hosts.

  ```yaml theme={null}
  runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  ```

* Search repositories:

  Searches for repositories matching the query across all hosts.

  ```yaml theme={null}
  runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  searchString: "my-project"
  limit: 10
  ```

## Endpoint

```text theme={null}
POST /api/gitpod.v1.RunnerService/SearchRepositories
```

Send a Bearer token as described in [Authentication](/docs/api-reference#authenticate-requests). If your organization uses a custom management-plane domain, replace `https://app.ona.com` with that domain.

## Request example

<CodeGroup>
  ```bash cURL theme={null}
  export ONA_HOST=https://app.ona.com
  export ONA_API_KEY=<your-token>

  curl --request POST \
    --url "$ONA_HOST/api/gitpod.v1.RunnerService/SearchRepositories" \
    --header "Authorization: Bearer $ONA_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
    "runnerId": "<runner-id>"
  }'
  ```

  ```python Python theme={null}
  import gitpod.v1.runner_pb2 as runner_pb2
  from ona_sdk import create_client_from_env

  ona = create_client_from_env()
  request = runner_pb2.SearchRepositoriesRequest(
      runner_id="<runner-id>",
  )
  response = ona.services.runner.search_repositories(request)
  print(response)
  ```

  ```typescript TypeScript theme={null}
  import { create } from "@bufbuild/protobuf";
  import { createClientFromEnv } from "@gitpod/sdk";
  import { SearchRepositoriesRequestSchema } from "@gitpod/sdk/gitpod/v1/runner_pb";

  async function main() {
    const ona = createClientFromEnv();
    const request = create(SearchRepositoriesRequestSchema, {
      runnerId: "<runner-id>",
    });
    const response = await ona.services.runner.searchRepositories(request);
    console.log(response);
  }

  main().catch(console.error);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	"connectrpc.com/connect"
  	"github.com/gitpod-io/gitpod-sdk-go/sdk"
  	gitpodpb "github.com/gitpod-io/gitpod-sdk-go/v1"
  )

  func main() {
  	ona, err := sdk.NewFromEnv()
  	if err != nil {
  		log.Fatal(err)
  	}

  	request := connect.NewRequest(&gitpodpb.SearchRepositoriesRequest{
  		RunnerId: "<runner-id>",
  	})
  	response, err := ona.Services.Runner.SearchRepositories(context.Background(), request)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(response.Msg)
  }
  ```

  ```json Request body theme={null}
  {
    "runnerId": "<runner-id>"
  }
  ```
</CodeGroup>

## Request

`gitpod.v1.SearchRepositoriesRequest`

| Field          | Type                                                    | Required | Description                                                                                                                                                                            |
| -------------- | ------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `runnerId`     | string                                                  | No       | Constraints: `string.uuid=true`.                                                                                                                                                       |
| `searchString` | string                                                  | No       | Search query - interpretation depends on search\_mode                                                                                                                                  |
| `limit`        | integer                                                 | No       | **Deprecated.** Maximum number of repositories to return. Default: 25, Maximum: 100 Deprecated: Use pagination.page\_size instead Constraints: `ignore=2, int32.gte=1, int32.lte=100`. |
| `pagination`   | [PaginationRequest](#type-gitpod-v1-pagination-request) | No       | Pagination parameters for repository search                                                                                                                                            |
| `scmHost`      | string                                                  | No       | The SCM's host to retrieve repositories from                                                                                                                                           |
| `searchMode`   | [SearchMode](#enum-gitpod-v1-search-mode)               | No       | Search mode determines how search\_string is interpreted                                                                                                                               |

## Response

`gitpod.v1.SearchRepositoriesResponse`

| Field          | Type                                                                           | Required | Description                                                                                                                                                                                                              |
| -------------- | ------------------------------------------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `repositories` | array of [Repository](#type-gitpod-v1-search-repositories-response-repository) | No       | List of repositories matching the search criteria                                                                                                                                                                        |
| `pagination`   | [PaginationResponse](#type-gitpod-v1-pagination-response)                      | No       | Pagination information for the response. Token format: "NEXT\_PAGE/TOTAL\_PAGES/TOTAL\_COUNT" (e.g., "2/40/1000"). Use -1 for unknown values (e.g., "2/-1/-1" when totals unavailable). Empty token means no more pages. |
| `lastPage`     | integer                                                                        | No       | **Deprecated.** Deprecated: Use pagination token instead. Total pages can be extracted from token.                                                                                                                       |

## Related types

<a id="type-gitpod-v1-pagination-request" />

<Accordion title="PaginationRequest">
  `gitpod.v1.PaginationRequest`

  | Field      | Type    | Required | Description                                                                                                                              |
  | ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
  | `pageSize` | integer | No       | Page size is the maximum number of results to retrieve per page. Defaults to 25. Maximum 100. Constraints: `int32.gte=0, int32.lte=100`. |
  | `token`    | string  | No       | Token for the next set of results that was returned as next\_token of a PaginationResponse                                               |
</Accordion>

<a id="type-gitpod-v1-pagination-response" />

<Accordion title="PaginationResponse">
  `gitpod.v1.PaginationResponse`

  | Field       | Type   | Required | Description                                                                             |
  | ----------- | ------ | -------- | --------------------------------------------------------------------------------------- |
  | `nextToken` | string | No       | Token passed for retrieving the next set of results. Empty if there are no more results |
</Accordion>

<a id="type-gitpod-v1-search-repositories-response-repository" />

<Accordion title="Repository">
  `gitpod.v1.SearchRepositoriesResponse.Repository`

  | Field  | Type   | Required | Description                                                                                         |
  | ------ | ------ | -------- | --------------------------------------------------------------------------------------------------- |
  | `name` | string | No       | Repository name (e.g., "my-project")                                                                |
  | `url`  | string | No       | Repository URL (e.g., "[https://github.com/owner/my-project](https://github.com/owner/my-project)") |
</Accordion>

<a id="enum-gitpod-v1-search-mode" />

<Accordion title="SearchMode">
  | Value                     | Number | Description                                                                                                                                                                                                                                                                                                                                                   |
  | ------------------------- | -----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `SEARCH_MODE_UNSPECIFIED` |      0 | SEARCH\_MODE\_UNSPECIFIED defaults to KEYWORD for backward compatibility                                                                                                                                                                                                                                                                                      |
  | `SEARCH_MODE_KEYWORD`     |      1 | KEYWORD mode: Simple keyword search with automatic augmentation - GitHub: Adds "user:\<username>" and "is:public" qualifiers - Bitbucket: Searches by name across user's accessible repositories - GitLab: Not yet implemented                                                                                                                                |
  | `SEARCH_MODE_NATIVE`      |      2 | NATIVE mode: Pass search\_string directly to SCM's search API - GitHub: Use GitHub's repository search syntax Examples: "org:gitpod-io language:go", "stars:>100 fork:true" - Bitbucket: Use Bitbucket's query language Examples: "name\~"api" AND project.key="PROJ"" - GitLab: Use GitLab's search parameters Examples: "scope=projects\&search=kubernetes" |
</Accordion>
