twentyhq/twenty · error · Error

Failed to create app registration: ${errorDetail}

Error message

Failed to create app registration: ${errorDetail}

What it means

Thrown by ensureAppRegistration when the createApplicationRegistration GraphQL mutation fails and the error is NOT a 'UNIVERSAL_IDENTIFIER_ALREADY_CLAIMED' sub-code. This means an unexpected server-side or network error occurred during app registration creation. The error detail is extracted from the result's error object and included in the message.

Source

Thrown at packages/twenty-sdk/src/cli/utilities/auth/ensure-app-registration.ts:48

      clientId: applicationRegistration.oAuthClientId,
      clientSecret,
      isNewRegistration: true,
    };
  }

  const isAlreadyClaimed = hasGraphQLErrorSubCode(
    createResult.error,
    'UNIVERSAL_IDENTIFIER_ALREADY_CLAIMED',
  );

  if (!isAlreadyClaimed) {
    const errorDetail =
      createResult.error instanceof Error
        ? createResult.error.message
        : ((createResult.error as { message?: string })?.message ??
          String(createResult.error));

    throw new Error(`Failed to create app registration: ${errorDetail}`);
  }

  const findResult =
    await apiService.findApplicationRegistrationByUniversalIdentifier(
      app.universalIdentifier,
    );

  if (!findResult.success || !findResult.data) {
    throw new Error(
      `App registration exists but could not be found: ${app.universalIdentifier}`,
    );
  }

  const registration = findResult.data;

  await configService.setConfig({
    appRegistrationId: registration.id,
    appRegistrationClientId: registration.oAuthClientId,

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Re-authenticate by running the SDK login/auth command to refresh the access token.
  2. Check the errorDetail in the thrown message for the specific server error (validation message, auth error, etc.).
  3. Verify the apiUrl in your config points to the correct Twenty instance.
  4. If rate limited, wait and retry the command.
  5. Ensure the app name and universalIdentifier comply with server-side format requirements.

Example fix

// before — registration fails with unknown error
const result = await ensureAppRegistration(apiService, configService, app);

// after — inspect and handle the error
try {
  const result = await ensureAppRegistration(apiService, configService, app);
} catch (e) {
  if (e.message.startsWith('Failed to create app registration:')) {
    console.error('Registration failed:', e.message);
    // Re-authenticate if the detail suggests an auth issue
    await refreshToken();
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const result = await ensureAppRegistration(apiService, configService, app);
} catch (error) {
  if (error instanceof Error && error.message.startsWith('Failed to create app registration')) {
    const detail = error.message.replace('Failed to create app registration: ', '');
    if (detail.includes('auth') || detail.includes('unauthorized')) {
      console.error('Token expired. Re-run: npx twenty-sdk auth login');
    } else {
      console.error('Registration failed:', detail);
    }
    process.exit(1);
  }
  throw error;
}

Prevention

When it happens

Trigger: apiService.createApplicationRegistration returns { success: false, error } where the error lacks the UNIVERSAL_IDENTIFIER_ALREADY_CLAIMED sub-code. This covers network failures, auth errors, validation errors, rate limiting, or any server-side mutation failure other than the already-claimed case.

Common situations: The CLI's access token expired or is invalid. The API URL in config points to a wrong/unreachable server. The app name violates server-side naming constraints. Rate limiting or transient network issues. The universalIdentifier format is rejected by server validation.

Related errors


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/2b0e2d7b4c989356. Report an issue: GitHub.