> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glider.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger Manual Rebalance

> Dispatches a one-off rebalance for a portfolio your API key has access to.

Dispatches a one-off rebalance run outside the portfolio's schedule. Typical
use cases: an end-user wants to re-target immediately to capture or hedge
market volatility, or your UI exposes a "rebalance now" control. The
endpoint returns `202` immediately with an `operationId`; poll
`GET /v2/portfolios/{portfolioId}/operations/{operationId}` until the
operation completes (`state`: `completed`, `failed`, or `cancelled`).

To decide when (or whether) to surface a manual trigger, read `nextDueAt`
and `lastRebalanceAt` from `GET /v2/portfolios/{portfolioId}` first.

* Auth: `x-api-key` header (required)
* Scope: `portfolios:write`

If a rebalance is still in progress for the portfolio, the response
returns the same `operationId` and original `submittedAt` from the
in-flight run. Treat `operationId` as an opaque token.

Each portfolio has a cooldown between manual triggers. Calls that arrive
too soon after the previous rebalance return `429` with a `Retry-After`
header (in seconds) indicating when to retry.

Returns `404` for portfolios your API key does not have access to —
same response shape as a portfolio that doesn't exist.

<ParamField path="portfolioId" type="string" required>
  Portfolio identifier returned by `POST /v2/enroll` or `GET /v2/portfolios`.
</ParamField>

Common error responses:

* `401` when `x-api-key` header is missing or the key is invalid
* `403` when the API key lacks the `portfolios:write` scope
* `404` when the portfolio does not exist or your API key cannot access it
* `429` when triggered too soon after the previous rebalance — see the `Retry-After` header
* `500` on unexpected server errors

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.glider.fi/v2/portfolios/pf_01JWZG3KH9P4N5QXJVNK7M3WTV/rebalance' \
    --header 'x-api-key: gldr_sk_your_api_key'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.glider.fi/v2/portfolios/pf_01JWZG3KH9P4N5QXJVNK7M3WTV/rebalance",
    {
      method: "POST",
      headers: { "x-api-key": "gldr_sk_your_api_key" },
    },
  );
  const { data } = await response.json();
  const { operationId } = data;
  ```
</RequestExample>

<ResponseExample>
  ```json 202 theme={null}
  {
    "success": true,
    "data": {
      "operationId": "rebalance:pf_01JWZG3KH9P4N5QXJVNK7M3WTV:pf_01JWZG3KH9P4N5QXJVNK7M3WTV%3Amanual%3Areq_01JWZEE2MF30KVRMRX53N88VA4",
      "submittedAt": "2026-04-17T12:00:00.000Z"
    }
  }
  ```

  ```json 404 theme={null}
  {
    "success": false,
    "error": {
      "code": "API_006",
      "message": "Portfolio with ID pf_01JWZG3KH9P4N5QXJVNK7M3WTV not found"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "success": false,
    "error": {
      "code": "API_004",
      "message": "Rebalance for this portfolio finished too recently; see the Retry-After header"
    }
  }
  ```
</ResponseExample>
