# Builds

> Build a whole site from a prompt with the AI pipeline, and follow it. 9 endpoints in the Unvop API.

Build a whole site from a prompt with the AI pipeline, and follow it.

## Build a site from a prompt

`POST /v1/builds`

Scope: `generate`.

Start the full AI build: research, a design reference, the design system, copy, pages and images, then deploy, a proof pass and an audit. It takes several minutes and runs on its own; follow it with GET /builds/{buildId} or stream GET /builds/{buildId}/events. The same request sent twice within two minutes returns the build already running. You can have two builds running at once.

### Headers

- `Idempotency-Key` (string): Send the same key to repeat this request safely; the first answer is replayed for 24 hours. (up to 200 characters)

### Request body (JSON)

- `prompt` (string, required): What the business does and who for, in two or three sentences or more. The more real detail, the better the site. (up to 8,000 characters)
- `name` (string): The business name. (up to 120 characters)
- `website` (string): The business’s current website. Research reads it for real details; enough on its own to start from. (up to 300 characters)
- `subdomain` (string): The free address to use, like "harbour-bakery" for harbour-bakery.<sites domain>. Check it with GET /subdomains/{name}. (up to 40 characters)
- `locale` (string): The site’s language, like en-GB or es. (up to 20 characters)
- `address` (string): (up to 300 characters)
- `phone` (string): (up to 40 characters)
- `email` (string): (up to 200 characters)
- `maps` (object): The business’s Google Maps listing.
  - `placeId` (string, required)
  - `url` (string)
- `brand` (object): Colours and a note on the look you want.
  - `tokens` (map of string)
  - `notes` (string): (up to 1,000 characters)
- `logo` (string): An upload id from POST /builds/uploads/logo. (up to 80 characters)
- `icon` (string): A logo upload id to use as the site icon. (up to 80 characters)
- `inspiration` (array of strings): Upload ids from POST /builds/uploads/inspiration: sites or pictures whose look you like. (up to 6 items)
- `siteId` (string): Rebuild this site (you must own it) instead of making a new one.
- `source` (object): Rebuild your own live website as an editable Unvop site.
  - `url` (string, required)
  - `ownSite` (true, required): You confirm the site is your own.
  - `instructions` (string): (up to 2,000 characters)
- `screenshot` (object): Rebuild a screenshot as an editable site.
  - `upload` (string, required): An upload id from POST /builds/uploads/screenshot.
  - `viewport` (object, required)
    - `width` (integer, required)
    - `height` (integer, required)
    - `device` (string, required): One of `desktop`, `tablet`, `mobile`.
  - `instructions` (string): (up to 2,000 characters)

### Response 202

- `job` (object, required): An AI site build: the full research, design, writing, building, deploy and review pipeline.
  - `id` (string, required)
  - `status` (string, required): One of `queued`, `running`, `succeeded`, `failed`.
  - `stage` (string, required): The stage the build is in, like researching, designing, writing, building, deploying, reviewing, done.
  - `message` (string, required): What it is doing now, in a sentence.
  - `prompt` (string, required)
  - `siteId` (string, required, nullable): The site, once deployed.
  - `hostname` (string, required, nullable)
  - `url` (string, required, nullable): The live site, once deployed.
  - `referenceUrl` (string, required, nullable): The design reference image, once drawn.
  - `images` (array of objects, required)
    - `url` (string, required)
    - `alt` (string, required)
    - `placement` (string, required)
  - `error` (string, required, nullable)
  - `errorCode` (string, required, nullable)
  - `createdAt` (string, required): An ISO 8601 timestamp.
  - `updatedAt` (string, required): An ISO 8601 timestamp.

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `409`: It conflicts with the current state.
- `422`: The body is invalid; details say which values.
- `429`: Too many requests; wait for RateLimit-Reset seconds.
- `503`: Not available on this server.

### Example

```sh
curl https://api.unvop.com/v1/builds \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "prompt": "Harbour Bakery is a family bakery in Falmouth. Sourdough, pastries and celebration cakes, open 7 to 3 every day, with a cafe upstairs looking over the harbour.",
    "name": "Harbour Bakery",
    "subdomain": "harbour-bakery"
  }'
```

## List builds

`GET /v1/builds`

Scope: `generate`.

Your account’s 20 most recent builds, newest first.

### Response 200

- `items` (array of objects, required)
  - `id` (string, required)
  - `status` (string, required): One of `queued`, `running`, `succeeded`, `failed`.
  - `stage` (string, required): The stage the build is in, like researching, designing, writing, building, deploying, reviewing, done.
  - `message` (string, required): What it is doing now, in a sentence.
  - `prompt` (string, required)
  - `siteId` (string, required, nullable): The site, once deployed.
  - `hostname` (string, required, nullable)
  - `url` (string, required, nullable): The live site, once deployed.
  - `referenceUrl` (string, required, nullable): The design reference image, once drawn.
  - `images` (array of objects, required)
    - `url` (string, required)
    - `alt` (string, required)
    - `placement` (string, required)
  - `error` (string, required, nullable)
  - `errorCode` (string, required, nullable)
  - `createdAt` (string, required): An ISO 8601 timestamp.
  - `updatedAt` (string, required): An ISO 8601 timestamp.
- `cursor` (string, nullable): Pass as ?cursor= to get the next page. Null when there are no more.
- `total` (integer): How many there are in all, when the list knows.

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl https://api.unvop.com/v1/builds \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Get a build

`GET /v1/builds/{buildId}`

Scope: `generate`.

Where a build is: its status (queued, running, succeeded, failed), stage, a sentence on what it is doing, the images so far, and once deployed the site id and live address. A build that went quiet is picked back up.

### Path parameters

- `buildId` (string, required)

### Response 200

- `job` (object, required): An AI site build: the full research, design, writing, building, deploy and review pipeline.
  - `id` (string, required)
  - `status` (string, required): One of `queued`, `running`, `succeeded`, `failed`.
  - `stage` (string, required): The stage the build is in, like researching, designing, writing, building, deploying, reviewing, done.
  - `message` (string, required): What it is doing now, in a sentence.
  - `prompt` (string, required)
  - `siteId` (string, required, nullable): The site, once deployed.
  - `hostname` (string, required, nullable)
  - `url` (string, required, nullable): The live site, once deployed.
  - `referenceUrl` (string, required, nullable): The design reference image, once drawn.
  - `images` (array of objects, required)
    - `url` (string, required)
    - `alt` (string, required)
    - `placement` (string, required)
  - `error` (string, required, nullable)
  - `errorCode` (string, required, nullable)
  - `createdAt` (string, required): An ISO 8601 timestamp.
  - `updatedAt` (string, required): An ISO 8601 timestamp.

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl https://api.unvop.com/v1/builds/job_123 \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Stream a build’s progress

`GET /v1/builds/{buildId}/events`

Scope: `generate`.

Server-Sent Events: a "build" event with the build each time its stage or message changes, then "done" when it succeeds or fails. The stream closes after five minutes; reconnect to keep following. Send Accept: text/event-stream.

### Path parameters

- `buildId` (string, required)

### Response 200 (Server-Sent Events)

- `id` (string, required)
- `status` (string, required): One of `queued`, `running`, `succeeded`, `failed`.
- `stage` (string, required): The stage the build is in, like researching, designing, writing, building, deploying, reviewing, done.
- `message` (string, required): What it is doing now, in a sentence.
- `prompt` (string, required)
- `siteId` (string, required, nullable): The site, once deployed.
- `hostname` (string, required, nullable)
- `url` (string, required, nullable): The live site, once deployed.
- `referenceUrl` (string, required, nullable): The design reference image, once drawn.
- `images` (array of objects, required)
  - `url` (string, required)
  - `alt` (string, required)
  - `placement` (string, required)
- `error` (string, required, nullable)
- `errorCode` (string, required, nullable)
- `createdAt` (string, required): An ISO 8601 timestamp.
- `updatedAt` (string, required): An ISO 8601 timestamp.

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl -N https://api.unvop.com/v1/builds/job_123/events \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Accept: text/event-stream"
```

## Stop a build

`POST /v1/builds/{buildId}/cancel`

Scope: `generate`.

Stop a build in progress. Finished stages stay stored; nothing after this point runs or spends.

### Path parameters

- `buildId` (string, required)

### Response 200

- `job` (object, required): An AI site build: the full research, design, writing, building, deploy and review pipeline.
  - `id` (string, required)
  - `status` (string, required): One of `queued`, `running`, `succeeded`, `failed`.
  - `stage` (string, required): The stage the build is in, like researching, designing, writing, building, deploying, reviewing, done.
  - `message` (string, required): What it is doing now, in a sentence.
  - `prompt` (string, required)
  - `siteId` (string, required, nullable): The site, once deployed.
  - `hostname` (string, required, nullable)
  - `url` (string, required, nullable): The live site, once deployed.
  - `referenceUrl` (string, required, nullable): The design reference image, once drawn.
  - `images` (array of objects, required)
    - `url` (string, required)
    - `alt` (string, required)
    - `placement` (string, required)
  - `error` (string, required, nullable)
  - `errorCode` (string, required, nullable)
  - `createdAt` (string, required): An ISO 8601 timestamp.
  - `updatedAt` (string, required): An ISO 8601 timestamp.

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `409`: It conflicts with the current state.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl -X POST https://api.unvop.com/v1/builds/job_123/cancel \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Pick a failed build back up

`POST /v1/builds/{buildId}/retry`

Scope: `generate`.

Restart a failed build where it stopped. Finished stages are skipped, so only the failed stage and those after it run again.

### Path parameters

- `buildId` (string, required)

### Response 202

- `job` (object, required): An AI site build: the full research, design, writing, building, deploy and review pipeline.
  - `id` (string, required)
  - `status` (string, required): One of `queued`, `running`, `succeeded`, `failed`.
  - `stage` (string, required): The stage the build is in, like researching, designing, writing, building, deploying, reviewing, done.
  - `message` (string, required): What it is doing now, in a sentence.
  - `prompt` (string, required)
  - `siteId` (string, required, nullable): The site, once deployed.
  - `hostname` (string, required, nullable)
  - `url` (string, required, nullable): The live site, once deployed.
  - `referenceUrl` (string, required, nullable): The design reference image, once drawn.
  - `images` (array of objects, required)
    - `url` (string, required)
    - `alt` (string, required)
    - `placement` (string, required)
  - `error` (string, required, nullable)
  - `errorCode` (string, required, nullable)
  - `createdAt` (string, required): An ISO 8601 timestamp.
  - `updatedAt` (string, required): An ISO 8601 timestamp.

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `409`: It conflicts with the current state.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl -X POST https://api.unvop.com/v1/builds/job_123/retry \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Upload a file for a build

`POST /v1/builds/uploads/{kind}`

Scope: `generate`.

Upload the owner’s logo (PNG, JPEG, WebP or SVG), an inspiration image, or a screenshot to rebuild, as multipart/form-data in a "file" field. Returns an upload id to pass to POST /builds as logo, icon, inspiration or screenshot.upload. Uploads stay private to your account.

### Path parameters

- `kind` (string, required): logo, inspiration or screenshot.

### Request body (multipart/form-data)

- `file` (file, required)
- `alt` (string)

### Response 201

- `upload` (object, required)
  - `id` (string, required)

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `413`: Too large.
- `422`: The body is invalid; details say which values.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl https://api.unvop.com/v1/builds/uploads/logo \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -F "file=@logo.png"
```

## Check a free address

`GET /v1/subdomains/{name}`

Scope: `generate`.

Whether a free address (name.<sites domain>) is available for a new site.

### Path parameters

- `name` (string, required)

### Response 200

- `available` (boolean, required)
- `hostname` (string)
- `url` (string, nullable)
- `reason` (string)

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl https://api.unvop.com/v1/subdomains/harbour-bakery \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Generate a site in one call (legacy)

`POST /v1/generate`

Scope: `generate`.

The older one-call generator: one model writes a SiteSpec and the site is created when it returns. It has no research, design reference, images or review. Prefer POST /builds, which runs the full pipeline. Send Accept: text/event-stream for progress events.

### Headers

- `Idempotency-Key` (string): Send the same key to repeat this request safely; the first answer is replayed for 24 hours. (up to 200 characters)

### Request body (JSON)

- `prompt` (string, required): (at least 20 characters; up to 8,000 characters)
- `name` (string): (at least 1 characters; up to 120 characters)
- `locale` (string): (up to 20 characters)
- `hostname` (string)
- `owner` (object)
  - `email` (string, required): (email)
  - `name` (string): (up to 120 characters)
- `brand` (object)
  - `tokens` (map of string)
  - `logoUrl` (string): (up to 2,000 characters)
  - `tagline` (string): (up to 200 characters)
  - `notes` (string): (up to 1,000 characters)
- `publish` (boolean): (default true)
- `dryRun` (boolean): (default false)

### Response 201

- `site` (object, required, nullable): A website.
  - `id` (string, required)
  - `name` (string, required)
  - `hostnames` (array of strings, required): The web addresses the site answers at.
  - `theme` (string, required)
  - `settings` (object, required): Navigation, footer, organization, SEO, tokens, design and more.
  - `createdAt` (string, required): An ISO 8601 timestamp.
- `urls` (object, required)
  - `site` (string, required, nullable)
  - `admin` (string, required)
  - `setup` (string, required, nullable)
  - `preview` (string, required, nullable)
- `warnings` (array of objects, required)
  - `path` (string, required)
  - `message` (string, required)
- `dryRun` (boolean, required)

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `422`: The body is invalid; details say which values.
- `429`: Too many requests; wait for RateLimit-Reset seconds.
- `503`: Not available on this server.

### Example

```sh
curl https://api.unvop.com/v1/generate \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "prompt": "Harbour Bakery is a family bakery in Falmouth. Sourdough, pastries and celebration cakes."
  }'
```
