> ## 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.

# Admin Portfolio Mirrorability

> Internal-only endpoints for setting portfolio blueprint mirrorability state

These endpoints let operators set the mirrorability state for existing Glider
portfolio blueprints before the public mirroring product surface is deployed.

## Auth

All routes are protected by the platform admin token:

* `Authorization: Bearer <admin-token>`
* `Content-Type: application/json`

## Request Body

All mirrorability endpoints accept the same request body:

```json theme={null}
{
  "canMirror": true
}
```

`canMirror` is the target mirrorability state. `isPublic` is optional. When
omitted, enabling mirroring also marks the blueprint public; disabling mirroring
leaves the existing visibility unchanged.

```json theme={null}
{
  "canMirror": false,
  "isPublic": true
}
```

## Update One Portfolio

`PATCH /v1/admin/portfolios/:portfolioId/mirrorable`

`portfolioId` is the strategy instance / portfolio id. The backend resolves the
source portfolio to its DB-v2 strategy blueprint, updates
`strategy_blueprints.can_mirror`, and writes the same state to the legacy
blueprint row when a legacy id exists.

Passing a mirrored child portfolio is rejected because mirrorability belongs to
the source blueprint.

Response:

```json theme={null}
{
  "success": true,
  "data": {
    "blueprintId": "bp_...",
    "canMirror": true,
    "isPublic": true,
    "portfolioId": "s_..."
  }
}
```

## Update One Strategy Blueprint

`PATCH /v1/admin/strategy-blueprints/:blueprintId/mirrorable`

`blueprintId` is the strategy blueprint/template id. Operators usually pass the
legacy template id returned to clients as `blueprintTemplateId`, for example
`01KVXD93001RE2NVTRT8A66C1C`. The endpoint resolves that id directly to the
DB-v2 strategy blueprint, validates its head version, updates
`strategy_blueprints.can_mirror`, and writes the same state to the legacy
blueprint row when a legacy id exists.

The route also accepts a numeric DB-v2 blueprint id as a fallback for ops-only
repair work.

Response:

```json theme={null}
{
  "success": true,
  "data": {
    "blueprintId": "01KVXD93001RE2NVTRT8A66C1C",
    "canMirror": true,
    "isPublic": true
  }
}
```

## Update Glider-Owned Public Portfolios

`PATCH /v1/admin/portfolios/mirrorable/glider-owned`

Updates mirrorability for every public DB-v2 blueprint owned by the Glider
account `0xf27de7c0d516b5dbc752b0ed13f582fb2d62a0cf`. Private blueprints are
skipped.

The endpoint validates head versions before mutating so a bad DB-v2 head pointer
does not produce a partial batch. If a required legacy write fails after a DB-v2
write, the DB-v2 update is rolled back and the request fails. Bulk updates only
select blueprints that are public at request start; explicit `isPublic` controls
their final visibility.

Request:

```json theme={null}
{
  "canMirror": true
}
```

Response:

```json theme={null}
{
  "success": true,
  "data": {
    "ownerAddress": "0xf27de7c0d516b5dbc752b0ed13f582fb2d62a0cf",
    "canMirror": true,
    "isPublic": true,
    "totalOwnedBlueprintCount": 12,
    "eligiblePublicBlueprintCount": 10,
    "skippedPrivateBlueprintCount": 2,
    "alreadyInDesiredStateBlueprintIds": ["bp_existing"],
    "updatedBlueprintIds": ["bp_updated"],
    "legacySyncFailedBlueprintIds": []
  }
}
```

## Update Public Portfolios For An Owner

`PATCH /v1/admin/portfolios/mirrorable/owners/:ownerAddress`

Updates mirrorability for every public DB-v2 blueprint owned by the supplied EVM
or Solana owner address. Private blueprints are skipped. This uses the same
request body, validation, legacy write, and rollback behavior as the
Glider-owned shortcut.

## Errors

* `401`: missing or invalid admin token
* `403`: attempted to toggle mirrorability from a mirrored child portfolio
* `404`: portfolio or DB-v2 blueprint was not found
* `500`: DB-v2 repository unavailable, invalid head pointer, or required legacy
  write failure
