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
- Re-authenticate by running the SDK login/auth command to refresh the access token.
- Check the errorDetail in the thrown message for the specific server error (validation message, auth error, etc.).
- Verify the apiUrl in your config points to the correct Twenty instance.
- If rate limited, wait and retry the command.
- 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
- Ensure the CLI access token is valid before running registration commands.
- Check network connectivity to the Twenty API before running the CLI.
- Log the full errorDetail to diagnose the specific server-side rejection.
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
- App registration exists but could not be found: ${app.univer
- Failed to introspect core schema: ${JSON.stringify(coreSchem
- ${res.statusText}: ${await res.text()}
- ${response.statusText}: ${response.rawBody}
- Invalid JSON response
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/2b0e2d7b4c989356.
Report an issue: GitHub.