---
title: "Turn auto-optimization on or off for a site"
method: POST
path: "/auto-optimization/toggle"
tags: ["Optimizations"]
---

# Turn auto-optimization on or off for a site

`POST /auto-optimization/toggle`

## Request

- Base URL: `https://next.frase.io/api/v1`
- URL: `https://next.frase.io/api/v1/auto-optimization/toggle`
- Auth: API key in header `X-API-KEY`

Enable or disable auto-optimization for one site, and optionally reconfigure which suggestion types are auto-applied and the confidence threshold they must clear. Requires the `write:optimizations` scope.

`site_id` and `enabled` are always required. `auto_apply_types` and `confidence_threshold` are optional and are only written when supplied — omitting them leaves the site's stored values untouched, so disabling never discards a configuration you can re-enable later.

The response echoes the RAW PERSISTED site settings, not the effective policy. GET /auto-optimization/status reports the effective values, which may be narrower because a saved workspace policy (Content Guard) intersects the allowed types and takes the stricter threshold. An empty `auto_apply_types` means nothing is applied automatically and every suggestion waits for review.

A site that does not exist in your organization, or is in the Trash, is reported as a 400 (`Site not found`) rather than a 404. Invalid suggestion types and an out-of-range threshold are also 400s, with the message naming the valid values.

CORS preflight is supported (OPTIONS returns 204; allowed methods POST, OPTIONS; allowed headers Content-Type, X-API-KEY).

## Request body

- object
  - `site_id` string, uuid, required: Required. The site to configure. Must belong to your organization and not be trashed.
  - `enabled` boolean, required: Required. True turns auto-optimization on for the site; false pauses it while preserving the stored types and threshold.
  - `auto_apply_types` string[]: Optional. Suggestion types eligible for automatic application. Only written when supplied; an empty array means nothing is auto-applied. Any value outside the enum rejects the whole request.
  - `confidence_threshold` number: Optional. Minimum confidence (0-100) a suggestion must reach to be auto-applied. Only written when supplied.

## Response `200`

Site settings persisted. Values are the raw stored site settings, not the workspace-narrowed effective policy.

- object
  - `data` object
    - `site_id` string, uuid
    - `enabled` boolean: Auto-optimization toggle as now stored on the site; false when the column is unset.
    - `auto_apply_types` string[]: Suggestion types now stored on the site. Empty array when none are configured.
    - `auto_apply_confidence_threshold` number: Confidence threshold now stored on the site. Defaults to 80 when the column is unset.

## Other responses

- `400`: Bad request. Parameter-shape problems — `site_id` missing, not a string, or not a UUID; `enabled` missing or not a boolean; `auto_apply_types` not an array of strings; `confidence_threshold` not a number — return the standard validation envelope with `param` naming the field. Refusals from the update itself instead return the data-wrapped shape `{"data": {"error": "..."}}` with no `code`: `Site not found` (unknown, other-org, or trashed site), `Invalid auto-apply types: ... Valid types: ...`, `Confidence threshold must be between 0 and 100`, `Failed to update site`, or `Failed to toggle auto-optimization` (the core's own catch - a DB fault during the update lands HERE, not at 500).
- `401`: Authentication failed
- `403`: Forbidden - action not allowed on this resource
- `429`: Rate limit exceeded
- `500`: The request body was not valid JSON, or the route itself faulted. (A DB fault inside the update is a 400 - see above.)

---

[API](https://skmtc.dev/frase/apis/frase-api.md) · [All operations](https://skmtc.dev/frase/apis/frase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/frase/apis/frase-api/revisions/7fb75d89f7a4?raw)
