invoke-ai/InvokeAI · error · HTTPException

Not authorized to access this style preset

Error message

Not authorized to access this style preset

What it means

This HTTP 403 is raised by _assert_preset_read when a style preset is not readable by the current user: it is not a Default preset, not marked public, and its user_id does not match the caller's user_id. InvokeAI style presets are private by default; only default, public, or owner-owned presets are readable.

Source

Thrown at invokeai/app/api/routers/style_presets.py:54

    negative_prompt: str = Field(description="Negative prompt")
    type: PresetType = Field(description="Preset type")
    is_public: bool = Field(default=False, description="Whether the preset is visible to other users")


style_presets_router = APIRouter(prefix="/v1/style_presets", tags=["style_presets"])


def _assert_preset_read(record: StylePresetRecordDTO, current_user: TokenData) -> None:
    """Allow read access if admin, owner, default preset, or public preset."""
    if current_user.is_admin:
        return
    if record.type == PresetType.Default:
        return
    if record.is_public:
        return
    if record.user_id == current_user.user_id:
        return
    raise HTTPException(status_code=403, detail="Not authorized to access this style preset")


def _assert_preset_write(record: StylePresetRecordDTO, current_user: TokenData) -> None:
    """Allow write access only for admin or owner. Defaults are immutable for non-admins."""
    if current_user.is_admin:
        return
    if record.type == PresetType.Default:
        raise HTTPException(status_code=403, detail="Default style presets cannot be modified")
    if record.user_id == current_user.user_id:
        return
    raise HTTPException(status_code=403, detail="Not authorized to modify this style preset")


def _load_record_or_404(style_preset_id: str) -> StylePresetRecordDTO:
    try:
        return ApiDependencies.invoker.services.style_preset_records.get(style_preset_id)
    except StylePresetNotFoundError:
        raise HTTPException(status_code=404, detail="Style preset not found")

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Ask the preset owner to set the preset's access to public, or to export/share the preset file instead of the ID
  2. Access the preset with an admin account or the owning user account
  3. Re-create the preset under your own user from its exported JSON/image
  4. Verify you are authenticated as the user you believe owns the preset (token/user mismatch is common)

Example fix

// before
const preset = await api.get(`/style_presets/i/${sharedId}`); // 403 if private
// after
try {
  const preset = await api.get(`/style_presets/i/${sharedId}`);
} catch (e) {
  if (e.response?.status === 403) {
    // fall back to importing the shared preset file under own account
    await importStylePreset(sharedPresetFile);
    return;
  }
  throw e;
}
Defensive patterns

Strategy: validation

Validate before calling

const preset = await api.get(`/style_presets/i/${id}`);
const { type, is_public, user_id } = preset.data;
const readable = type === 'Default' || is_public || user_id === currentUser.id;
if (!readable) throw new Error('Preset is private and owned by another user');

Type guard

function canReadPreset(preset, user) {
  return preset.type === 'Default' || preset.is_public === true || preset.user_id === user.user_id;
}

Try / catch

try {
  return (await api.get(`/style_presets/i/${id}`)).data;
} catch (e) {
  if (e.response?.status === 403) {
    console.warn('Private preset; import it under your own account instead');
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling GET /style_presets/i/{style_preset_id} (or fetching its image) for a private preset owned by a different user on a multi-user instance.

Common situations: Sharing preset IDs directly with another user instead of marking the preset public; service tokens operating under a different user than the preset owner; referencing presets copied from another account's export.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/b5af93187eb0934a. Report an issue: GitHub.