# Refetch

`POST /workspaces/:workspace/sandboxes/:sandbox_id/fetches/:fetch_id/refetch`

Fetch a source again

**Required Scopes:** `SANDBOX_WRITE`

## URL Parameters

```typescript
interface URLParameters {
  /** The human-readable ID of the workspace */
  workspace: string; // Example: "my-company"
  /** The ID of the sandbox */
  sandbox_id: string; // Example: "sb-1234567890abcdef"
  /** The ID of the fetch */
  fetch_id: string; // Example: "f1a2b3c4d5"
}
```

## Response Body

```typescript
interface ResponseBody {
  /** The type of the fetch item: PROJECT_REPO, PUBLIC_REPO, or ARTIFACT */
  type?: "PROJECT_REPO" | "PUBLIC_REPO" | "ARTIFACT";
  /** The auto-generated ID of the fetch */
  id?: string;
  /** The URL of the git repository (for PUBLIC_REPO type) */
  repository?: string;
  /** The branch, tag, or commit to checkout. Defaults to the default branch */
  ref?: string;
  /** The target directory where the item is cloned/downloaded. It identifies the fetch, so two entries cannot share it. Defaults to the app directory */
  path?: string;
  /** The path inside the artifact to fetch instead of its whole content (for ARTIFACT type) */
  source_path?: string;
  /** The revision currently checked out in the sandbox (for repository fetches) */
  current_revision?: string;
  /** How many commits the fetched revision is behind the configured ref, null when it cannot be measured */
  behind?: number;
  /** Whether the fetched artifact version differs from the current one, null when it cannot be measured */
  outdated?: boolean;
  /** When the source was last fetched into the sandbox, null when it has not been fetched yet */
  fetched_date?: string;
  /** State of this entry: FETCHING, FETCHED, ERROR after a failed run, STALE when it needs a refetch: it was changed, added while the sandbox was not running, or its fetch was interrupted. Only Refetch brings a STALE entry up to date */
  status?: "FETCHING" | "FETCHED" | "ERROR" | "STALE";
  /** Why the last fetch failed, null unless the status is ERROR */
  error_message?: string;
  /** The command to run after fetching */
  build_command?: string;
  /** The artifact identifier in format pkg:version (for ARTIFACT type) */
  artifact?: string;
}
```

## Response Example

**Status:** `200 OK`


---
Original source: https://buddy.works/docs/api/sandboxes/refetch