jackwener/OpenCLI · error · AuthRequiredError

Suno API rejected request (HTTP ${status}). Re-login on suno

Error message

Suno API rejected request (HTTP ${status}). Re-login on suno.com.

What it means

submitSunoGeneration posts to Suno's /api/generate/v2-web/ endpoint; when the API responds 401 or 403 it throws AuthRequiredError with this message, meaning your Clerk bearer JWT is no longer accepted. The CLI deliberately routes these statuses to the auth-recovery path rather than reporting a generic failure.

Source

Thrown at clis/suno/utils.js:332

    const bodyJson = JSON.stringify(body);
    const deviceId = payload.deviceId;
    const result = unwrapEvaluateResult(await page.evaluate(`(async () => {
        const res = await fetch('${STUDIO_API}/api/generate/v2-web/', {
            method: 'POST',
            headers: ${sunoHeadersJs(deviceId, { 'Content-Type': 'application/json' })},
            body: ${JSON.stringify(bodyJson)},
        });
        const text = await res.text();
        let parsed = null;
        try { parsed = JSON.parse(text); } catch {}
        return { status: res.status, ok: res.ok, body: parsed, raw: parsed ? null : text.slice(0, 600) };
    })()`));

    if (!result || !result.ok) {
        const status = result?.status || 'unknown';
        const detail = result?.body?.detail || result?.raw || JSON.stringify(result?.body || {}).slice(0, 500);
        if (status === 401 || status === 403) {
            throw new AuthRequiredError(SUNO_DOMAIN, `Suno API rejected request (HTTP ${status}). Re-login on suno.com.`);
        }
        if (status === 402) {
            throw new CommandExecutionError(`Suno API: insufficient credits (HTTP 402). ${detail}`);
        }
        throw new CommandExecutionError(`Suno generate failed (HTTP ${status}): ${detail}`);
    }

    if (!result.body || typeof result.body !== 'object' || Array.isArray(result.body)) {
        throw new CommandExecutionError('Suno generate returned malformed JSON payload.');
    }
    const clips = result.body?.clips || [];
    if (!clips.length) {
        throw new EmptyResultError('suno generate', `Submission accepted but Suno returned no clip ids. Raw: ${JSON.stringify(result.body).slice(0, 300)}`);
    }
    return result.body;
}

// ─────────────────────────────────────────────────────────────────────────────

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://suno.com in the Chrome profile the CLI drives and re-login, then retry the generation.
  2. Ensure the session pre-flight (suno status / session check) passes before generating.
  3. Clear suno.com cookies if re-login alone doesn't refresh the Clerk token, then sign in again.
  4. Check you haven't signed in on a different browser than the automation target.
  5. Update the CLI if 401/403 persist after fresh login — Suno may have changed the auth schema.

Example fix

// before
opencli suno generate --prompt "song"   // HTTP 401 -> AuthRequiredError
// after (re-login in the automated Chrome first)
// 1. sign in at https://suno.com
opencli suno generate --prompt "song"
Defensive patterns

Strategy: try-catch

Validate before calling

// Refresh session before generation
const session = await ensureSunoSession(page, deviceId); // throws AuthRequiredError early if logged out
if (!session.ok) throw new Error('Sign in to suno.com before generating');

Type guard

function isSunoAuthError(err) {
  return err instanceof AuthRequiredError || /rejected request \(HTTP (401|403)\)/.test(err.message || '');
}

Try / catch

try {
  await submitSunoGeneration(page, params);
} catch (err) {
  if (isSunoAuthError(err)) {
    console.error('Re-login on suno.com, then retry.');
    process.exitCode = 2;
  } else throw err;
}

Prevention

When it happens

Trigger: Calling a generate/submission flow while logged out or with an expired Clerk session token; Suno rejecting the JWT (revoked session, token refresh failure in the page context, or server-side session invalidation).

Common situations: JWT expired during a long session; user signed out or changed password in the browser; suno.com rotating auth and invalidating old tokens; clock skew in the browser-token anti-replay header combined with auth checks.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a9dd7be1f73f8331. Report an issue: GitHub.