# Quickstart

> Create a free test site with curl, follow its provisioning job, then read the site.

Source: https://docs.wpwaterfall.com/developers/quickstart

Create a free test site from the command line with curl and watch it come up. A test site runs on a simulated server, so it needs no site license. A company can hold 10 test sites at a time. You need an API key with `sites:write`: [create an API key](https://docs.wpwaterfall.com/developers/create-an-api-key) and grant `sites:write`.

Test sites are available when `GET /v1/platform` returns `"test_sites": true`. If it does not, `POST /v1/sites` with `"test": true` answers `403`, and you create a real site with a site license instead.



### Step 1: Create the site

Send a POST with an `Idempotency-Key`. Set `test` to `true` so the request works without a site license.

```bash
curl -s -i -X POST https://api.wpwaterfall.com/v1/sites \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET" \
  -H "Idempotency-Key: quickstart-demo-1" \
  -H "Content-Type: application/json" \
  -d '{"name":"demo","test":true}'
```

The response is `202 Accepted`. The body is a Job object and the `Location` header points at `/v1/jobs/{id}`. Copy the job `id`.

Without `"test": true`, a company with no site license gets `402` with the problem type `payment-required`.


### Step 2: Follow the job

Read the job until it ends.

```bash
curl -s https://api.wpwaterfall.com/v1/jobs/JOB_ID \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET"
```

For live progress instead of polling, open the event stream:

```bash
curl -s -N https://api.wpwaterfall.com/v1/jobs/JOB_ID/events \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET" \
  -H "Accept: text/event-stream"
```

See [Jobs and events](https://docs.wpwaterfall.com/developers/jobs-and-events) for the job states and the stream.


### Step 3: Read the site

List your sites and read the new one.

```bash
curl -s https://api.wpwaterfall.com/v1/sites \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET"

curl -s https://api.wpwaterfall.com/v1/sites/SITE_ID \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET"
```

`GET /v1/sites/{id}/environments` lists its environments.


### Step 4: Retry safely

Run the first POST again with the same `Idempotency-Key` and body. You get the same response and no second site. Change the body and keep the key, and you get `422`. See [Idempotency](https://docs.wpwaterfall.com/developers/idempotency).



## How do I clean up?

Delete the test site when you are done. The route needs `?confirm=true` and a key with `danger:destroy`, which needs two-factor on your account and an expiry on the key.

```bash
curl -s -X DELETE "https://api.wpwaterfall.com/v1/sites/SITE_ID?confirm=true" \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET"
```

Or delete it from the dashboard, which asks you to type the site name.

## What if a call fails?

| Status | Meaning | What to do |
|---|---|---|
| 401 | Missing, unknown, or revoked key | Copy the secret again from a new key. |
| 402 | No site license | Add `"test": true` to the body, or buy a site license. |
| 403 | Key lacks the scope, or test sites are off | `POST /v1/sites` needs `sites:write`. |
| 422 | Bad body, or a reused `Idempotency-Key` with a different body | Fix the body or use a new key. |
| 429 | Rate limit | Wait for `Retry-After`. See [Rate limits](https://docs.wpwaterfall.com/developers/rate-limits). |

Every response carries a `request_id`. Quote it when you write to support. See [Errors](https://docs.wpwaterfall.com/developers/errors).
