---
title: "Redeploy"
method: POST
path: "/api/v1/deployments/{id}/redeploy"
tags: ["Deployments"]
---

# Redeploy

`POST /api/v1/deployments/{id}/redeploy`

## Request

- Base URL: `https://previewdrop.dev`
- URL: `https://previewdrop.dev/api/v1/deployments/{id}/redeploy`
- Auth: HTTP bearer

Rebuilds an existing deployment using the same branch and project configuration. Use this to refresh a preview after new commits or to provide a fresh repository token.

**When to use redeploy vs. create**

- Use **redeploy** when you want to rebuild from the same deployment record (keeps the same deployment ID and project link).
- Use **create** when you want a brand-new deployment record (e.g. for a different branch or a new PR).

**Fresh token for private repos**

If the original `repoUrl` embedded a short-lived token (e.g. a GitHub Actions `GITHUB_TOKEN`), pass a fresh `repoUrl` with a new token. If omitted and the deployment is linked to a project, the project's GitHub repo is used.

**Environment variables**

Merged in this order (highest priority last): project env vars → body `envVars`. `PORT` is always set to `3000`.

## Path parameters

- `id` string, uuid, required

## Request body

- object
  - `repoUrl` string, uri: Public HTTPS clone URL on github.com, gitlab.com or bitbucket.org to override the source for this rebuild — credentials embedded in the URL are not supported. If omitted, the URL is derived from the linked project with the workspace's own provider credentials.
  - `envVars` object: Additional or overriding env vars for this rebuild. Merged on top of project env vars.
  - `ttlMs` integer: Override the preview TTL for this rebuild. Defaults to plan TTL if omitted.
  - `githubToken` string: A GitHub personal access token or installation token for cloning private repos via `repoUrl`. The token is embedded in the clone URL sent to the build worker and is never stored.

## Response `200`

Rebuild triggered. The deployment status resets to `building`.

- DeploymentWrapper
  - `deployment` Deployment, required: An ephemeral preview deployment.
    - `id` string, uuid, required: Unique deployment identifier.
    - `tenant_id` string, uuid, required: Workspace (tenant) that owns this deployment.
    - `project_id` string, uuid, nullable: ID of the linked project, or `null` for ad-hoc deployments created directly with `repoUrl`.
    - `pd_projects` object, nullable: Nested project record. Only present in **list** responses (`GET /api/v1/deployments`). `null` for ad-hoc deployments with no linked project.
      - `id` string, uuid
      - `name` string
      - `github_repo` string
    - `worker_deploy_id` string, nullable: Internal ID used by the build worker. Use this to correlate with worker logs.
    - `url` string, uri, nullable: Publicly accessible preview URL. Available once status is `ready`. `null` while building.
    - `status` 'queued' | 'building' | 'deploying' | 'ready' | 'failed' | 'expired' | 'stopped', required: Current state of the deployment: - `queued` — accepted, waiting for a build slot - `building` — Docker image is being built - `deploying` — container is starting - `ready` — container is live and reachable via `url` - `failed` — build or startup error (check `build_log`) - `expired` — TTL elapsed, container destroyed automatically - `stopped` — manually stopped via the API or dashboard
    - `framework` string, nullable: Auto-detected framework (e.g. `nextjs`, `vite`, `create-react-app`). `null` until detected.
    - `branch` string, required: Git branch that was built.
    - `detected_env_vars` string[], nullable: Environment variable names detected in the build output (e.g. from a missing `.env` warning). Useful for debugging misconfigured previews. Populated after first successful worker poll.
    - `build_log` string, nullable: Raw stdout/stderr from the build process. Updated in real time while building. Use `GET /api/v1/deployments/{id}/logs` for a dedicated logs endpoint.
    - `expires_at` string, date-time, nullable: ISO 8601 timestamp when the preview will be automatically destroyed. Determined by your plan TTL at the time of creation.
    - `created_at` string, date-time, required: ISO 8601 timestamp when the deployment was created.
    - `updated_at` string, date-time, required: ISO 8601 timestamp of the last status update.

## Other responses

- `400`: Cannot redeploy — the deployment has no project or `repoUrl` attached.
- `401`: Missing or invalid API key.
- `403`: API access is not available on your current plan. Upgrade to Starter or higher.
- `404`: The requested deployment does not exist or does not belong to your workspace.
- `409`: The workspace has reached its concurrent preview limit (or per-project limit) for the current plan. Stop an existing preview or upgrade your plan — retrying without changing state will keep returning 409.
- `429`: You have exceeded the rate limit. Check the `Retry-After` header for when to resume. The limit value reflects the specific endpoint's cap (10, 60, or 120 req/60s — see Rate Limits in the overview).
- `502`: The build worker returned an error. The deployment is marked `failed`.

---

[API](https://skmtc.dev/previewdrop/apis/previewdrop-api.md) · [All operations](https://skmtc.dev/previewdrop/apis/previewdrop-api/llms.txt) · [OpenAPI document](https://skmtc.dev/previewdrop/apis/previewdrop-api/revisions/0742e253496b?raw)
