---
title: Restore an old version (forward-only)
description: "Materializes an old version's tree as a NEW commit on the current branch (WIBLO-085.7)."
api_method: POST
api_path: "/v1/agent-runs/{runId}/git/restore"
canonical_url: https://wiblo.app/docs/developers/api/agent-git/restore-agent-run-git-version
last_updated: 2026-07-28T17:31:44+02:00
md_url: https://wiblo.app/docs/developers/api/agent-git/restore-agent-run-git-version.md
---

# Restore an old version (forward-only)

`POST /v1/agent-runs/{runId}/git/restore`

Materializes an old version's tree as a NEW commit on the current branch (WIBLO-085.7). Never resets, force-pushes, or rewrites history — restoring an old version always creates a new one. Per-user rate-limited at 20/60s.

## Path parameters

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

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sha` | `string` | Yes |  |

## Request

**curl**

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

**TypeScript**

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

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

const { data, error } = await restoreAgentRunGitVersion({
  client: sdk,
  path: { runId: "..." },
  body: {
    "sha": "..."
  },
})
```

## Responses

**`200`** — The forward-only restore commit. Returns `AgentGitRestoreResponse`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |
| `committed` | `boolean` | Yes |  |
| `sha` | `string` | Yes |  |
| `restoredFrom` | `string` | Yes |  |

**`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`** — No live sandbox session holds the checkout (`AGENT_SANDBOX_UNAVAILABLE`), or a turn is already running in the run's thread (`TURN_ALREADY_ACTIVE`). Returns `ApiErrorEnvelope`.

**`422`** — Path/body validation failed, or the run has no Git source (`AGENT_RUN_NOT_GIT_BACKED`). 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 Git operation failed against the provider/checkout (`UPSTREAM_UNAVAILABLE`). Returns `ApiErrorEnvelope`.
