# IvyForms REST API

IvyForms exposes the admin SPA API in Lite. The public developer API is an Agency plan feature in Pro.

## Admin SPA API (`ivyforms/v1`) — Lite

Used by the Vue admin UI and public form embed. Authenticate with a logged-in WordPress session and the `X-WP-Nonce` header (`wp_create_nonce('wp_rest')`), injected as `window.wpIvyApiSettings.nonce`.

**Base URL:** `{site}/wp-json/ivyforms/v1/`

**Response envelope:**

```json
{
  "message": "OK",
  "data": { }
}
```

**Permissions:** `ivyforms_manage` (or `manage_options` for backward compatibility).

### Core resources

| Method | Path | Description |
|--------|------|-------------|
| GET | `/form`, `/form/{id}` | List / get form |
| POST | `/form/add/`, `/form/update/{id}`, `/form/delete/{id}` | Form CRUD |
| POST | `/form/submission/` | Public form submission (no auth) |
| GET | `/entries/search`, `/entry/{id}` | Entries |
| GET/POST | `/confirmation/*`, `/notification/*` | Confirmations & notifications |
| GET/POST | `/settings/*`, `/integrations`, `/templates` | Settings & integrations |

### Extension hook (Pro and third-party)

```php
do_action('ivyforms/rest/register_additional_routes', $container, 'ivyforms/v1');
```

Pro routes use the `/pro/` path prefix (e.g. `/pro/license/status`).

## Public developer API (`ivyforms-public/v1`) — Pro Agency

Lite only fires the extension hook; **all routes, controllers, and permissions live in `ivyforms-pro` Agency plan**.

```php
// Lite fires (no routes registered without Pro):
do_action('ivyforms/rest/register_public_routes', $container, 'ivyforms-public/v1');

// Pro Agency enables when licensed:
apply_filters('ivyforms/public_api/enabled', false);
```

Authenticated requests use the `X-IvyForms-Api-Key` header (Agency plan). See `ivyforms-pro/docs/rest-api-public.md` for scopes and key management.

## Architecture

```
rest_api_init
  → Routes::registerRoutes()                    // ivyforms/v1 (Lite)
    → do_action('ivyforms/rest/register_additional_routes')  // Pro ivyforms/v1
    → do_action('ivyforms/rest/register_public_routes')      // Pro Agency ivyforms-public/v1
```

Layers: **Routes → Controllers → Services → Repositories**
