immich-app/immich · error · Error

Failed to fetch activation key

Error message

Failed to fetch activation key

What it means

Thrown by getActivationKey (web/src/lib/utils/license-utils.ts) when the fetch to PUBLIC_IMMICH_PAY_HOST/api/v1/activate/<licenseKey> returns a non-ok HTTP status. This is the client-side call that exchanges a license key for an activation key before sending it to the Immich server.

Source

Thrown at web/src/lib/utils/license-utils.ts:20

import { PUBLIC_IMMICH_BUY_HOST, PUBLIC_IMMICH_PAY_HOST } from '$env/static/public';
import type { ImmichProduct } from '$lib/constants';
import { authManager } from '$lib/managers/auth-manager.svelte';
import { serverConfigManager } from '$lib/managers/server-config-manager.svelte';

export const activateProduct = async (licenseKey: string, activationKey: string): Promise<LicenseResponseDto> => {
  // TODO is this needed?
  await authManager.load();

  const isServerActivation = authManager.user.isAdmin && licenseKey.search('IMSV') !== -1;
  const licenseKeyDto = { licenseKey, activationKey };
  // Send server key to user activation if user is not admin
  return isServerActivation ? setServerLicense({ licenseKeyDto }) : setUserLicense({ licenseKeyDto });
};

export const getActivationKey = async (licenseKey: string): Promise<string> => {
  const response = await fetch(new URL(`/api/v1/activate/${licenseKey}`, PUBLIC_IMMICH_PAY_HOST).href);
  if (!response.ok) {
    throw new Error('Failed to fetch activation key');
  }
  return response.text();
};

export const getLicenseLink = (license: ImmichProduct) => {
  const url = new URL('/', PUBLIC_IMMICH_BUY_HOST);
  url.searchParams.append('productId', license);
  url.searchParams.append('instanceUrl', serverConfigManager.value.externalDomain || globalThis.origin);
  return url.href;
};

View on GitHub (pinned to 199723261c)

Solutions

  1. Double-check the license key for typos and that it has not been activated elsewhere.
  2. Retry later if the IMMICH_PAY service is having an outage (check status.immich.app / community).
  3. Disable ad-blockers/privacy extensions that may block the external request, or whitelist PUBLIC_IMMICH_PAY_HOST.
  4. Contact Immich support if the key is valid but activation keeps failing.

Example fix

// before
const key = await getActivationKey(licenseKey); // throws on non-ok

// after — surface the status for diagnosis
const res = await fetch(new URL(`/api/v1/activate/${licenseKey}`, PUBLIC_IMMICH_PAY_HOST));
if (!res.ok) throw new Error(`Activation failed: ${res.status} ${res.statusText}`);
const key = await res.text();
Defensive patterns

Strategy: retry

Validate before calling

// validate key format before hitting the endpoint
const re = /^[A-Z0-9-]{6,}$/i;
if (!re.test(licenseKey.trim())) { notify('Invalid key format'); return; }

Type guard

const looksLikeLicenseKey = (k: string): boolean => typeof k === 'string' && k.trim().length >= 6;

Try / catch

try { return await getActivationKey(licenseKey); }
catch (e) { if (/Failed to fetch activation key/.test(e.message)) { await sleep(backoff); return getActivationKey(licenseKey); } throw e; }

Prevention

When it happens

Trigger: User enters a license key in the purchase/activation UI; the external payment/activation endpoint returns 4xx/5xx (invalid key, already-activated key, server down, network/CORS error).

Common situations: Typo in the license key; key already activated on another instance; the IMMICH_PAY service is temporarily unavailable; ad-blocker or network policy blocks the external host; CORS misconfiguration; expired license.

Related errors


AI-assisted analysis of immich-app/immich@199723261c (2026-08-12). Data as JSON: /api/errors/d67e33703ac246e2. Report an issue: GitHub.