# Plugins

> Email, Stripe, SEO, analytics, booking, spam protection and more. 4 endpoints in the Unvop API.

Email, Stripe, SEO, analytics, booking, spam protection and more.

## List plugins

`GET /v1/sites/{siteId}/plugins`

Scope: `content:read`.

Every plugin (email, Stripe, SEO, analytics, booking, spam protection, reviews…) with its settings fields and its state on the site. Secret values are never returned.

### Path parameters

- `siteId` (string, required): The site’s id.

### Response 200

- `items` (array of objects, required)
  - `id` (string, required)
  - `name` (string, required)
  - `description` (string, required)
  - `category` (string, required)
  - `settings` (array, required): The plugin’s settings fields. Fields with secret: true are write-only.
  - `state` (object, required)
    - `id` (string, required)
    - `enabled` (boolean, required)
    - `config` (object, required)
    - `secretsSet` (array of strings, required)
- `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).
- `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/sites/site_123/plugins \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Get a plugin

`GET /v1/sites/{siteId}/plugins/{pluginId}`

Scope: `content:read`.

One plugin with its settings fields and state.

### Path parameters

- `siteId` (string, required): The site’s id.
- `pluginId` (string, required)

### Response 200

- `id` (string, required)
- `name` (string, required)
- `description` (string, required)
- `category` (string, required)
- `settings` (array, required): The plugin’s settings fields. Fields with secret: true are write-only.
- `state` (object, required)
  - `id` (string, required)
  - `enabled` (boolean, required)
  - `config` (object, required)
  - `secretsSet` (array of strings, 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.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl https://api.unvop.com/v1/sites/site_123/plugins/email \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Turn on or configure a plugin

`PUT /v1/sites/{siteId}/plugins/{pluginId}`

Scope: `settings:write`, as a site owner or admin.

Turn a plugin on or off and change its settings. Secret fields (API keys, tokens) go in secrets: they are encrypted, write-only and never returned. Core plugins can’t be turned off. Owners and admins only.

### Path parameters

- `siteId` (string, required): The site’s id.
- `pluginId` (string, required)

### Request body (JSON)

- `enabled` (boolean)
- `config` (object)
- `secrets` (map of string)

### Response 200

- `id` (string, required)
- `enabled` (boolean, required)
- `config` (object, required)
- `secretsSet` (array of strings, 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.
- `422`: The body is invalid; details say which values.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl -X PUT https://api.unvop.com/v1/sites/site_123/plugins/email \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "config": {
      "fromEmail": "hello@example.com"
    }
  }'
```

## Test a plugin

`POST /v1/sites/{siteId}/plugins/{pluginId}/test`

Scope: `settings:write`, as a site owner or admin.

Check a plugin’s connection (for example, send a test email). Owners and admins only.

### Path parameters

- `siteId` (string, required): The site’s id.
- `pluginId` (string, required)

### Response 200

- `ok` (boolean, required)
- `message` (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 -X POST https://api.unvop.com/v1/sites/site_123/plugins/email/test \
  -H "Authorization: Bearer $UNVOP_KEY"
```
