---
title: "Clone a repo into the run's workspace"
description: "Clones a workspace-owned managed repo (by Wiblo repoId) or a GitHub import into a sibling folder on the RUNNING sandbox (WIBLO-131) — the agent can use it immediately."
api_method: POST
api_path: "/v1/agent-runs/{runId}/repos"
canonical_url: https://wiblo.app/docs/developers/api/agent-run-repos/add-agent-run-repo
last_updated: 2026-07-28T17:31:44+02:00
md_url: https://wiblo.app/docs/developers/api/agent-run-repos/add-agent-run-repo.md
---

# Clone a repo into the run's workspace

`POST /v1/agent-runs/{runId}/repos`

Clones a workspace-owned managed repo (by Wiblo `repoId`) or a GitHub import into a sibling folder on the RUNNING sandbox (WIBLO-131) — the agent can use it immediately. The folder defaults from the source (managed → `site`, github → the sanitized repo name); `main` is reserved for the base agent project. A GitHub import must not target the Wiblo-managed owner (the run-source cross-tenant guard). A short-lived repo-scoped clone credential is minted per call, rides only per-command env inside the sandbox, and is revoked after. Per-user rate-limited at 15/60s.

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |

## Request body

## Request

**curl**

```bash
curl https://api.wiblo.app/v1/agent-runs/{runId}/repos \
  -X POST \
  -H "Authorization: Bearer $WIBLO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "repo",
  "repoId": "..."
}'
```

**TypeScript**

```ts
import { createSdk, addAgentRunRepo } from "@workspace/sdk"

const sdk = createSdk({ baseUrl: "https://api.wiblo.app" })

const { data, error } = await addAgentRunRepo({
  client: sdk,
  path: { runId: "..." },
  body: {
    "kind": "repo",
    "repoId": "..."
  },
})
```

## Responses

**`201`** — The repo was cloned into its folder. Returns `AddAgentRepoResponse`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |
| `repo` | `AgentRepoEntry` | Yes |  |
| `cloneMs` | `integer` | Yes |  |

**`400`** — Invalid or reserved folder (`INVALID_REPO_FOLDER`), or the source repo is not addable (`AGENT_SOURCE_REPO_NOT_FOUND`). Returns `ApiErrorEnvelope`.

**`401`** — No valid session cookie or `wbl_*` bearer was present. Returns `ApiErrorEnvelope`.

**`404`** — No run visible to the caller with this id (`AGENT_RUN_NOT_FOUND`). Returns `ApiErrorEnvelope`.

**`409`** — The folder already exists in the workspace (`REPO_FOLDER_EXISTS`), or no live sandbox session (`AGENT_SANDBOX_UNAVAILABLE`). Returns `ApiErrorEnvelope`.

**`422`** — Path param failed UUID validation (`INVALID_PARAMS`). Returns `ApiErrorEnvelope`.

**`429`** — Rate limit exceeded. The body's `error.code` is `RATE_LIMITED` and `error.details.retry_after` is the same number of seconds as the `Retry-After` header. Returns `ApiErrorEnvelope`.

**`502`** — The in-sandbox clone failed (`REPO_CLONE_FAILED`). Returns `ApiErrorEnvelope`.

### The AgentRepoEntry object

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `folder` | `string` | Yes |  |
| `remote` | `string \| null` | No | Defaults to `null`. |
| `branch` | `string \| null` | No | Defaults to `null`. |
| `commit` | `string \| null` | No | Defaults to `null`. |
| `dirty` | `boolean` | Yes |  |
