MCPcopy
hub / github.com/gcui-art/suno-api / keepAlive

Method keepAlive

src/lib/SunoApi.ts:173–190  ·  view source on GitHub ↗

* Keep the session alive. * @param isWait Indicates if the method should wait for the session to be fully renewed before returning.

(isWait?: boolean)

Source from the content-addressed store, hash-verified

171 * @param isWait Indicates if the method should wait for the session to be fully renewed before returning.
172 */
173 public async keepAlive(isWait?: boolean): Promise<void> {
174 if (!this.sid) {
175 throw new Error('Session ID is not set. Cannot renew token.');
176 }
177 // URL to renew session token
178 const renewUrl = `${SunoApi.CLERK_BASE_URL}/v1/client/sessions/${this.sid}/tokens?__clerk_api_version=2025-11-10&_clerk_js_version=${SunoApi.CLERK_VERSION}`;
179 // Renew session token
180 logger.info('KeepAlive...\n');
181 const renewResponse = await this.client.post(renewUrl, {}, {
182 headers: { Authorization: this.cookies.__client }
183 });
184 if (isWait) {
185 await sleep(1, 2);
186 }
187 const newToken = renewResponse.data.jwt;
188 // Update Authorization field in request header with the new JWT token
189 this.currentToken = newToken;
190 }
191
192 /**
193 * Get the session token (not to be confused with session ID) and save it for later use.

Callers 11

initMethod · 0.95
generateMethod · 0.95
concatenateMethod · 0.95
generateSongsMethod · 0.95
generateLyricsMethod · 0.95
generateStemsMethod · 0.95
getLyricAlignmentMethod · 0.95
getMethod · 0.95
getClipMethod · 0.95
get_creditsMethod · 0.95
getPersonaPaginatedMethod · 0.95

Calls 1

sleepFunction · 0.90

Tested by

no test coverage detected