# Previews API

4 operations under /api/v1. Errors are RFC 9457 problem+json with a stable `code` field. The complete schemas are in https://nebulactrl.com/api/v1/openapi.json.

## DELETE /previews/{previewId}

Delete a pull-request preview

Removes the preview's services, containers, volumes and domains, then its environment. Runs asynchronously.

Authentication: session cookie or `Authorization: Bearer nct_…` token.

Parameters:
- `previewId` (path, string, required)

Response 202: Accepted (PreviewView)
  - `createdAt` (string (date-time), required)
  - `environmentId` (string, required)
  - `environmentSlug` (string, required)
  - `fromFork` (boolean, required)
  - `headBranch` (string, required)
  - `headSha` (string, required)
  - `id` (string, required)
  - `lastPushAt` (string (date-time), required)
  - `pausedAt` (string (date-time) | null, required)
  - `prAuthor` (string, required)
  - `prNumber` (integer (int64), required)
  - `prTitle` (string, required)
  - `prUrl` (string, required)
  - `projectId` (string, required)
  - `provider` (string, required)
  - `repo` (string, required)
  - `status` (enum: creating | deploying | seeding | ready | failed | paused | deleting, required)
  - `statusMessage` (string, required)
  - `urls` (string[], required)
Errors: 401 Unauthorized; 403 Forbidden; 404 Not Found; 422 Unprocessable Entity; 500 Internal Server Error

## GET /projects/{projectId}/previews

List a project's pull-request previews

Authentication: session cookie or `Authorization: Bearer nct_…` token.

Parameters:
- `projectId` (path, string, required)

Response 200: OK (ListOutputBody2)
  - `items` (PreviewView[] | null, required)
Errors: 401 Unauthorized; 403 Forbidden; 404 Not Found; 422 Unprocessable Entity; 500 Internal Server Error

## GET /projects/{projectId}/previews/settings

Get a project's pull-request preview settings

Authentication: session cookie or `Authorization: Bearer nct_…` token.

Parameters:
- `projectId` (path, string, required)

Response 200: OK (PreviewSettings)
  - `baseEnvironmentId` (string | null, required)
  - `enabled` (boolean, required)
  - `excludedServices` (string[] | null, required)
  - `forkPrs` (boolean, required)
  - `idleDays` (integer (int64), required)
  - `maxConcurrent` (integer (int64), required)
  - `projectId` (string, required)
  - `seedCommands` (PreviewSeedCommand[] | null, required)
  - `updatedAt` (string (date-time) | null, required)
Errors: 401 Unauthorized; 403 Forbidden; 404 Not Found; 422 Unprocessable Entity; 500 Internal Server Error

## PUT /projects/{projectId}/previews/settings

Update a project's pull-request preview settings

Previews clone the base environment for every open pull request of a connected repository. Fork pull requests are off by default; a fork preview never receives secrets.

Authentication: session cookie or `Authorization: Bearer nct_…` token.

Parameters:
- `projectId` (path, string, required)

Request body (application/json, required): PutSettingsInputBody1
  - `baseEnvironmentId` (string)
  - `enabled` (boolean)
  - `excludedServices` (string[] | null)
  - `forkPrs` (boolean)
  - `idleDays` (integer (int64))
  - `maxConcurrent` (integer (int64))
  - `seedCommands` (PreviewSeedCommand[] | null)

Response 200: OK (PreviewSettings)
  - `baseEnvironmentId` (string | null, required)
  - `enabled` (boolean, required)
  - `excludedServices` (string[] | null, required)
  - `forkPrs` (boolean, required)
  - `idleDays` (integer (int64), required)
  - `maxConcurrent` (integer (int64), required)
  - `projectId` (string, required)
  - `seedCommands` (PreviewSeedCommand[] | null, required)
  - `updatedAt` (string (date-time) | null, required)
Errors: 401 Unauthorized; 403 Forbidden; 404 Not Found; 422 Unprocessable Entity; 500 Internal Server Error
