# Update explorer preset

> Source: https://docs.clonepartner.com/api-reference/explorer-presets/update-explorer-preset/

`PUT /api/explorer-presets/{id}`

Updates a preset's name and/or definition. Creator or admin/superadmin only. Applies the same definition validation as create.

**Operation ID:** `updateExplorerPreset`

## Authentication

### Option 1

- **BearerAuth** (`http bearer`)
  API key token. Create via POST /api/api-keys. Format: `envoy_<hex>`

### Option 2

- **CookieAuth** (`apiKey`)
  Session cookie set after login + TOTP verification

## Path parameters

- `id` — `integer`, `required`
  Resource ID

## Request body

The request body is required.

### `application/json`

- Type: `object`
- Properties:
  - `name` (`string`)
  - `connector_id` (`integer | null`)
    - Nullable: yes
  - `resource` (`string | null`)
    - Nullable: yes
  - `definition` (`ExplorerPresetDefinition`)
    - Reference: `ExplorerPresetDefinition`
      - Properties:
        - `mode` (`string`, `required`) — Parameters are allowed in `visual` mode (placeholders in filter values) and in `raw` mode when `rawQuery` is valid JSON (placeholders inside JSON string literals). SQL/OData raw queries cannot be parameterized.
          - Description: Parameters are allowed in `visual` mode (placeholders in filter values) and in `raw` mode when `rawQuery` is valid JSON (placeholders inside JSON string literals). SQL/OData raw queries cannot be parameterized.
          - Allowed values: `visual`, `raw`
        - `filters` (`array<ExplorerFilter>`)
          - Items:
            - Reference: `ExplorerFilter`
              - Type: `object`
              - Properties:
                - `field` (`string`, `required`)
                - `operator` (`string`, `required`)
                - `value` (`string`, `required`) — A literal value, or a `{{param}}` placeholder referencing a name in the preset's `parameters`.
                - `valueType` (`string`) — Optional type hint. Use `objectId` for MongoDB ObjectId fields so the value is coerced to Extended JSON on apply.
                  - Description: Optional type hint. Use `objectId` for MongoDB ObjectId fields so the value is coerced to Extended JSON on apply.
                  - Allowed values: `auto`, `string`, `number`, `boolean`, `null`, `objectId`, `date`
        - `action` (`string`) — Visual builder action. Defaults to find when omitted.
          - Description: Visual builder action. Defaults to find when omitted.
          - Allowed values: `find`, `count`, `insert`, `update`, `delete`
        - `rawQuery` (`string`) — Raw query string for `mode: raw` (SQL, Mongo Extended JSON, or OData). Ignored by parameterization.
        - `columns` (`array<string>`)
          - Items:
            - Type: `string`
        - `limit` (`string`)
        - `sort` (`string`) — Visual-mode sort column
        - `order` (`string`) — Visual-mode sort direction (omit or asc when unsorted / ascending)
          - Description: Visual-mode sort direction (omit or asc when unsorted / ascending)
          - Allowed values: `asc`, `desc`
        - `resultView` (`string`)
          - Allowed values: `table`, `json`
        - `jsonata` (`string`)
        - `csvDelimiter` (`string`)
        - `parameters` (`array<PresetParameter>`) — Visual-mode only. Every parameter must be referenced by a `{{name}}` placeholder in a filter value, and every placeholder must reference a declared parameter.
          - Description: Visual-mode only. Every parameter must be referenced by a `{{name}}` placeholder in a filter value, and every placeholder must reference a declared parameter.
          - Items:
            - Reference: `PresetParameter`
              - Type: `object`
              - Properties:
                - `name` (`string`, `required`) — Referenced as `{{name}}` in a filter value. Letters, numbers, and underscores only; unique within the preset.
                - `label` (`string`, `required`) — Shown in the apply dialog.
                - `required` (`boolean`)
                  - Default: `true`
                - `type` (`string`, `required`) — `string` — free text. `objectId` — free text validated as a 24-char hex ObjectId. `mongoRecord` — searchable record picker over a Mongo collection on the preset's connector.
                  - Description: `string` — free text. `objectId` — free text validated as a 24-char hex ObjectId. `mongoRecord` — searchable record picker over a Mongo collection on the preset's connector.
                  - Allowed values: `string`, `objectId`, `mongoRecord`
                - `collection` (`string`) — Required for `mongoRecord`. The Mongo collection to query (e.g. `migration_jobs`).
                - `valueField` (`string`) — mongoRecord. Field substituted into the filter. Defaults to `_id` (coerced to ObjectId hex).
                - `labelField` (`string`) — mongoRecord. Primary display label (e.g. `name`).
                - `descriptionFields` (`array<string>`) — mongoRecord. Muted metadata fields shown under the label.
                  - Description: mongoRecord. Muted metadata fields shown under the label.
                  - Items:
                    - Type: `string`
                - `searchFields` (`array<string>`) — mongoRecord. Fields searched server-side for the picker query.
                  - Description: mongoRecord. Fields searched server-side for the picker query.
                  - Items:
                    - Type: `string`
                - `filter` (`object`) — mongoRecord. Base filter merged into every picker query.
                - `sort` (`object`) — mongoRecord. Mongo sort object.
                  - Description: mongoRecord. Mongo sort object.
                  - Additional properties:
                    - Type: `integer`
                    - Allowed values: `1`, `-1`

## Success responses

### 200

Updated preset

**Content type:** `application/json`

- Reference: `ExplorerPreset`
  - Type: `object`
  - Properties:
    - `id` (`integer`)
    - `name` (`string`)
    - `connector_id` (`integer | null`)
      - Nullable: yes
    - `resource` (`string | null`)
      - Nullable: yes
    - `definition` (`ExplorerPresetDefinition`)
      - Reference: `ExplorerPresetDefinition`
        - Properties:
          - `mode` (`string`, `required`) — Parameters are allowed in `visual` mode (placeholders in filter values) and in `raw` mode when `rawQuery` is valid JSON (placeholders inside JSON string literals). SQL/OData raw queries cannot be parameterized.
            - Description: Parameters are allowed in `visual` mode (placeholders in filter values) and in `raw` mode when `rawQuery` is valid JSON (placeholders inside JSON string literals). SQL/OData raw queries cannot be parameterized.
            - Allowed values: `visual`, `raw`
          - `filters` (`array<ExplorerFilter>`)
            - Items:
              - Reference: `ExplorerFilter`
                - Type: `object`
                - Properties:
                  - `field` (`string`, `required`)
                  - `operator` (`string`, `required`)
                  - `value` (`string`, `required`) — A literal value, or a `{{param}}` placeholder referencing a name in the preset's `parameters`.
                  - `valueType` (`string`) — Optional type hint. Use `objectId` for MongoDB ObjectId fields so the value is coerced to Extended JSON on apply.
                    - Description: Optional type hint. Use `objectId` for MongoDB ObjectId fields so the value is coerced to Extended JSON on apply.
                    - Allowed values: `auto`, `string`, `number`, `boolean`, `null`, `objectId`, `date`
          - `action` (`string`) — Visual builder action. Defaults to find when omitted.
            - Description: Visual builder action. Defaults to find when omitted.
            - Allowed values: `find`, `count`, `insert`, `update`, `delete`
          - `rawQuery` (`string`) — Raw query string for `mode: raw` (SQL, Mongo Extended JSON, or OData). Ignored by parameterization.
          - `columns` (`array<string>`)
            - Items:
              - Type: `string`
          - `limit` (`string`)
          - `sort` (`string`) — Visual-mode sort column
          - `order` (`string`) — Visual-mode sort direction (omit or asc when unsorted / ascending)
            - Description: Visual-mode sort direction (omit or asc when unsorted / ascending)
            - Allowed values: `asc`, `desc`
          - `resultView` (`string`)
            - Allowed values: `table`, `json`
          - `jsonata` (`string`)
          - `csvDelimiter` (`string`)
          - `parameters` (`array<PresetParameter>`) — Visual-mode only. Every parameter must be referenced by a `{{name}}` placeholder in a filter value, and every placeholder must reference a declared parameter.
            - Description: Visual-mode only. Every parameter must be referenced by a `{{name}}` placeholder in a filter value, and every placeholder must reference a declared parameter.
            - Items:
              - Reference: `PresetParameter`
                - Type: `object`
                - Properties:
                  - `name` (`string`, `required`) — Referenced as `{{name}}` in a filter value. Letters, numbers, and underscores only; unique within the preset.
                  - `label` (`string`, `required`) — Shown in the apply dialog.
                  - `required` (`boolean`)
                    - Default: `true`
                  - `type` (`string`, `required`) — `string` — free text. `objectId` — free text validated as a 24-char hex ObjectId. `mongoRecord` — searchable record picker over a Mongo collection on the preset's connector.
                    - Description: `string` — free text. `objectId` — free text validated as a 24-char hex ObjectId. `mongoRecord` — searchable record picker over a Mongo collection on the preset's connector.
                    - Allowed values: `string`, `objectId`, `mongoRecord`
                  - `collection` (`string`) — Required for `mongoRecord`. The Mongo collection to query (e.g. `migration_jobs`).
                  - `valueField` (`string`) — mongoRecord. Field substituted into the filter. Defaults to `_id` (coerced to ObjectId hex).
                  - `labelField` (`string`) — mongoRecord. Primary display label (e.g. `name`).
                  - `descriptionFields` (`array<string>`) — mongoRecord. Muted metadata fields shown under the label.
                    - Description: mongoRecord. Muted metadata fields shown under the label.
                    - Items:
                      - Type: `string`
                  - `searchFields` (`array<string>`) — mongoRecord. Fields searched server-side for the picker query.
                    - Description: mongoRecord. Fields searched server-side for the picker query.
                    - Items:
                      - Type: `string`
                  - `filter` (`object`) — mongoRecord. Base filter merged into every picker query.
                  - `sort` (`object`) — mongoRecord. Mongo sort object.
                    - Description: mongoRecord. Mongo sort object.
                    - Additional properties:
                      - Type: `integer`
                      - Allowed values: `1`, `-1`
    - `created_by` (`integer`)
    - `created_at` (`string`)
      - Format: `date-time`
    - `updated_at` (`string | null`)
      - Format: `date-time`
      - Nullable: yes

## Error responses

### 400

Validation error (invalid definition)

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

### 404

Resource not found

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "NOT_FOUND",
  "message": "Resource not found"
}
```

## Examples

### cURL

```bash
curl --request PUT \
  --url 'https://your-envoy.example.com/api/explorer-presets/YOUR_ID' \
  --header 'Authorization: Bearer $API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "connector_id": 0,
  "resource": "string",
  "definition": {
    "mode": "visual"
  }
}'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/explorer-presets/YOUR_ID', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "string",
    "connector_id": 0,
    "resource": "string",
    "definition": {
      "mode": "visual"
    }
  }),
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
