---
title: API Reference
description: REST API endpoints for programmatic access to PageWeave resources.
section: API
order: 1
---

# API Reference

REST API endpoints under `/api/v1/`. All responses are JSON.

**OpenAPI Specification:** [openapi.json](/openapi.json) — full machine-readable API schema (OpenAPI 3.0).

## Authentication

API requests require authentication via:

- **API key** — `Authorization: Bearer pagew_...`
- **OAuth token** — `Authorization: Bearer <token>`

## Websites

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites` | List websites |
| POST | `/api/v1/websites` | Create website |
| GET | `/api/v1/websites/:id` | Get website |
| PATCH | `/api/v1/websites/:id` | Update website |
| DELETE | `/api/v1/websites/:id` | Delete website |

## Pages

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/pages` | List pages |
| POST | `/api/v1/websites/:website_id/pages` | Create page |
| GET | `/api/v1/websites/:website_id/pages/:id` | Get page |
| PATCH | `/api/v1/websites/:website_id/pages/:id` | Update page |
| DELETE | `/api/v1/websites/:website_id/pages/:id` | Delete page |

### Page Versions

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/pages/:page_id/versions` | List versions |
| PATCH | `/api/v1/websites/:website_id/pages/:page_id/versions/:id/pin` | Pin version |
| POST | `/api/v1/websites/:website_id/pages/:page_id/versions/:id/revert` | Revert to version |

## Assets

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/assets` | List assets |
| POST | `/api/v1/websites/:website_id/assets` | Upload file (multipart direct). Pass `asset_id` to replace an existing asset. |
| POST | `/api/v1/websites/:website_id/assets/request_upload_url` | Get session-based upload URL. Pass `asset_id` to bind the session to a replace target. |
| PUT | `/api/v1/websites/uploads/:id` | Upload file via session-based URL |
| POST | `/api/v1/websites/:website_id/assets/upload` | Upload file (url or base64). Pass `asset_id` to replace an existing asset. |
| GET | `/api/v1/websites/:website_id/assets/:id` | Get asset |
| DELETE | `/api/v1/websites/:website_id/assets/:id` | Delete asset |

`request_upload_url` returns `{ upload_url, expires_at, storage }`. To upload via the session-based URL, PUT raw file bytes with `?filename=photo.jpg` and the matching `Content-Type` header (e.g. `image/png`). The session is reusable within its 10-minute TTL.

### Asset replacement

All three upload endpoints (`POST /assets`, `POST /assets/upload`, `POST /assets/request_upload_url`) accept an optional `asset_id` parameter. When set, the uploaded file replaces the named asset's bytes instead of creating a new asset. The asset's `id`, URL, and filename are preserved; only the bytes change. The new file's content type must match the existing asset's content type exactly (no format conversion). Replace returns `200 OK` (not `201 Created`).

## Forms

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/forms` | List forms |
| POST | `/api/v1/websites/:website_id/forms` | Create form |
| GET | `/api/v1/websites/:website_id/forms/:id` | Get form |
| PATCH | `/api/v1/websites/:website_id/forms/:id` | Update form |
| DELETE | `/api/v1/websites/:website_id/forms/:id` | Delete form |

## Tables

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/tables` | List tables |
| POST | `/api/v1/websites/:website_id/tables` | Create table |
| GET | `/api/v1/websites/:website_id/tables/:id` | Get table |
| PATCH | `/api/v1/websites/:website_id/tables/:id` | Update table |
| DELETE | `/api/v1/websites/:website_id/tables/:id` | Delete table |

## Headers, Footers, & HTML Head

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/headers` | List header instances |
| POST | `/api/v1/websites/:website_id/headers` | Create header instance |
| GET | `/api/v1/websites/:website_id/headers/:id` | Get header instance |
| PATCH | `/api/v1/websites/:website_id/headers/:id` | Update header instance |
| DELETE | `/api/v1/websites/:website_id/headers/:id` | Delete header instance |
| GET | `/api/v1/websites/:website_id/headers/:header_id/versions` | List header versions |
| PATCH | `/api/v1/websites/:website_id/headers/:header_id/versions/:id/pin` | Pin header version |
| POST | `/api/v1/websites/:website_id/headers/:header_id/versions/:id/revert` | Revert header version |
| DELETE | `/api/v1/websites/:website_id/headers/:id/unpin` | Unpin header version |

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/footers` | List footer instances |
| POST | `/api/v1/websites/:website_id/footers` | Create footer instance |
| GET | `/api/v1/websites/:website_id/footers/:id` | Get footer instance |
| PATCH | `/api/v1/websites/:website_id/footers/:id` | Update footer instance |
| DELETE | `/api/v1/websites/:website_id/footers/:id` | Delete footer instance |
| GET | `/api/v1/websites/:website_id/footers/:footer_id/versions` | List footer versions |
| PATCH | `/api/v1/websites/:website_id/footers/:footer_id/versions/:id/pin` | Pin footer version |
| POST | `/api/v1/websites/:website_id/footers/:footer_id/versions/:id/revert` | Revert footer version |
| DELETE | `/api/v1/websites/:website_id/footers/:id/unpin` | Unpin footer version |

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/html_heads` | List html_head instances |
| POST | `/api/v1/websites/:website_id/html_heads` | Create html_head instance |
| GET | `/api/v1/websites/:website_id/html_heads/:id` | Get html_head instance |
| PATCH | `/api/v1/websites/:website_id/html_heads/:id` | Update html_head instance |
| DELETE | `/api/v1/websites/:website_id/html_heads/:id` | Delete html_head instance |
| GET | `/api/v1/websites/:website_id/html_heads/:html_head_id/versions` | List html_head versions |
| PATCH | `/api/v1/websites/:website_id/html_heads/:html_head_id/versions/:id/pin` | Pin html_head version |
| POST | `/api/v1/websites/:website_id/html_heads/:html_head_id/versions/:id/revert` | Revert html_head version |
| DELETE | `/api/v1/websites/:website_id/html_heads/:id/unpin` | Unpin html_head version |

Flat routes (global-ID access, no `website_id`):

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/headers/:id` | Get header instance |
| PATCH | `/api/v1/websites/headers/:id` | Update header instance |
| DELETE | `/api/v1/websites/headers/:id` | Delete header instance |
| GET | `/api/v1/websites/footers/:id` | Get footer instance |
| PATCH | `/api/v1/websites/footers/:id` | Update footer instance |
| DELETE | `/api/v1/websites/footers/:id` | Delete footer instance |
| GET | `/api/v1/websites/html_heads/:id` | Get html_head instance |
| PATCH | `/api/v1/websites/html_heads/:id` | Update html_head instance |
| DELETE | `/api/v1/websites/html_heads/:id` | Delete html_head instance |

## Analytics

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/v1/websites/:website_id/analytics` | Get analytics data |

## Error Responses

| Status | Meaning |
|--------|---------|
| 400 | Bad Request — invalid parameters |
| 401 | Unauthorized — missing or invalid auth |
| 403 | Forbidden — insufficient permissions |
| 404 | Not Found — resource doesn't exist |
| 422 | Unprocessable Entity — validation errors |
| 429 | Too Many Requests — rate limited |
