{"record":{"id":"d4f5c8f9e736589d","repo":"Budibase/budibase","slug":"license-key-has-already-been-activated","errorCode":null,"errorMessage":"License key has already been activated","messagePattern":"License key has already been activated","errorType":"exception","errorClass":"HTTPError","httpStatus":409,"severity":"error","filePath":"packages/pro/src/sdk/licensing/licenses/client.ts","lineNumber":243,"sourceCode":"  const body: LicenseActivateRequest = {\n    installVersion: install.version,\n    installId: install.installId,\n  }\n\n  const response = await api.post(`/api/license/activate`, {\n    headers: {\n      [constants.Header.LICENSE_KEY]: licenseKey,\n    },\n    body,\n  })\n\n  // don't propagate the 403 to prevent logout\n  if (response.status === 403) {\n    throw new HTTPError(\"Invalid license key\", 400)\n  }\n\n  if (response.status === 409) {\n    throw new HTTPError(\"License key has already been activated\", 409)\n  }\n\n  if (response.status !== 200) {\n    const message = await getResponseErrorMessage(response)\n    throw new HTTPError(\n      `Error activating license key: ${message}`,\n      response.status\n    )\n  }\n\n  return response.json()\n}\n","sourceCodeStart":225,"sourceCodeEnd":256,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/pro/src/sdk/licensing/licenses/client.ts#L225-L256","documentation":"Thrown by activateLicenseKey when POST /api/license/activate responds with 409 Conflict — the license key has already been activated against another (or the same) installation. The portal enforces one activation per key, so re-activating the same key elsewhere conflicts with the existing binding.","triggerScenarios":"Calling activateLicenseKey(licenseKey) for a key already bound to an installId — e.g. activating on a second environment, re-running activation after a restore with a changed installId, or a stale portal record.","commonSituations":"Migrating Budibase to a new server without deactivating the old one; restoring a backup where the installId changed; CI/test environments sharing a production license key; duplicate activation attempts after a network timeout that actually succeeded.","solutions":["Check if the key is already active on this install — if the install already works, skip activation and just fetch the license.","Deactivate the license on the old installation (or via the account portal) before reactivating on the new one.","Contact Budibase support to reset the activation binding if the old install is gone/unrecoverable.","Use a distinct license key per environment (dev/staging/prod) instead of sharing one key."],"exampleFix":"// before\nawait activateLicenseKey(key) // throws 409 on retry\n// after\ntry {\n  await activateLicenseKey(key)\n} catch (e) {\n  if (e instanceof HTTPError && e.status === 409) {\n    console.warn(\"Key already activated — fetching existing license instead\")\n    await getLicenseFromKey(key)\n  } else {\n    throw e\n  }\n}","handlingStrategy":"try-catch","validationCode":"// Before activating, check whether this install already has a working license\nconst existing = await getLicenseFromKey(key)\nif (existing) { /* already activated — skip activateLicenseKey */ }","typeGuard":"function isAlreadyActivated(e: unknown): boolean {\n  return e instanceof HTTPError && e.status === 409\n}","tryCatchPattern":"try {\n  await activateLicenseKey(key)\n} catch (e) {\n  if (isAlreadyActivated(e)) {\n    // treat as success or fetch existing license instead of rethrowing\n  } else throw e\n}","preventionTips":["Treat 409 as idempotent success when re-running activation scripts.","Deactivate licenses on decommissioned installs before migrating.","Never share one license key across dev/staging/prod.","After restores that change installId, reissue rather than re-activate the same key."],"tags":["licensing","activation","conflict","http-error"],"backgroundTag":"license-already-activated","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}