Deployments

Create deployment

Triggers a new preview build. The deployment record is created as queued, then immediately dispatched to the build worker — the response reflects the worker's initial status (typically building).

In-flight cancellation

If a deployment for the same project and branch is already queued, building, or deploying, it is automatically cancelled (status set to stopped) before the new build starts. This matches the push webhook behavior: the last deploy always wins, orphaned containers are not left running.

Specifying the repository

You must provide either projectId or repoUrl:

  • projectId — uses the GitHub repo and env vars configured on the project. Request-level envVars are merged on top. Private repos are accessed automatically via the GitHub App.
  • repoUrl — ad-hoc build from any public GitHub HTTPS URL (credentials embedded in the URL are not supported; use projectId for private repos).

Environment variables

Keys are automatically normalised to UPPERCASE. Each key must match [A-Z_][A-Z0-9_]* (up to 100 chars) and each value may be up to 8 KiB.

TTL

If omitted, the preview lives for your plan's default TTL (1 h / 4 h / 8 h / 7 d depending on plan). Pass ttlMs to override, e.g. 3600000 for 1 hour.

Polling for completion

After creating a deployment, poll GET /api/v1/deployments/{id} every 5–15 seconds until status is ready or failed. A typical build takes 60–180 seconds.

Idempotency

Supply an Idempotency-Key request header (e.g. a UUID) to safely retry failed requests without triggering duplicate deploys. If the key matches a request processed within the last 5 minutes, the cached successful response is returned with an Idempotency-Replayed: true header instead of firing a new build. Keys must be 8–128 alphanumeric/hyphen/underscore characters.

post/api/v1/deployments

Request

  • Base URL: https://previewdrop.dev
  • URL: https://previewdrop.dev/api/v1/deployments
  • Auth: HTTP bearer

Headers

Idempotency-Keystring
Example:550e8400-e29b-41d4-a716-446655440000

Unique key (UUID recommended) to deduplicate retried requests. Requests with the same key from the same workspace replay the cached 201 response for up to 5 minutes.

Request body

projectIdstring uuid

ID of a project configured in your dashboard. The project's linked GitHub repo and env vars are used as the base. Mutually exclusive with repoUrl — provide one or the other.

repoUrlstring uri

Public HTTPS clone URL on github.com, gitlab.com or bitbucket.org — credentials embedded in the URL (e.g. x-access-token:TOKEN@) are rejected. For private repos, use projectId instead (PreviewDrop uses the workspace's GitHub App installation or GitLab/Bitbucket OAuth token automatically). Mutually exclusive with projectId.

branchstring

Git branch to build. Must match [a-zA-Z0-9/_\-.]{1,200}. Defaults to the project's default branch (when using projectId) or main.

envVarsobject

Runtime environment variables injected into the container. Keys are normalised to UPPERCASE. When using projectId, these are merged on top of the project's stored env vars (request values take precedence on key conflicts).

ttlMsinteger

Preview lifetime in milliseconds. The container is automatically destroyed after this duration. Defaults to your plan TTL (free: 3 600 000 / starter: 14 400 000 / pro: 28 800 000 / enterprise: 604 800 000).

githubTokenstring

A GitHub personal access token or installation token for cloning private repos when using repoUrl directly (without projectId). The token is embedded in the clone URL sent to the build worker and is never stored. Must match [A-Za-z0-9_.\-]{4,255}.

Example request

{
  "projectId": "11223344-5566-7788-99aa-bbccddeeff00",
  "repoUrl": "https://github.com/acme/my-app.git",
  "branch": "feat/new-checkout",
  "envVars": {
    "DATABASE_URL": "postgres://user:pass@host/db",
    "NEXT_PUBLIC_API_URL": "https://api.example.com"
  },
  "ttlMs": 28800000,
  "githubToken": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

Response

Deployment queued successfully.

Example response

{
  "deployment": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "tenant_id": "f0e1d2c3-b4a5-6789-0abc-def123456789",
    "project_id": "11223344-5566-7788-99aa-bbccddeeff00",
    "pd_projects": {
      "github_repo": "acme/my-app"
    },
    "worker_deploy_id": "abc123def456",
    "url": "https://prv-abc123.previews.previewdrop.dev",
    "status": "ready",
    "framework": "nextjs",
    "branch": "feat/new-checkout",
    "detected_env_vars": [
      "DATABASE_URL",
      "NEXT_PUBLIC_API_URL"
    ],
    "build_log": "[1/4] Installing dependencies...\n[2/4] Building application...",
    "expires_at": "2026-04-09T14:00:00.000Z",
    "created_at": "2026-04-09T10:00:00.000Z",
    "updated_at": "2026-04-09T10:03:42.000Z"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.