Lyrics Generation Callbacks
Webhook callback payload specification sent to your server when a structured song lyrics generation task completes. Delivers metrically structured verses, catchy choruses, bridges, and suggested song titles.
When Callbacks Are Sent
The SongMesh API automatically triggers an HTTP POST request to your designated callBackUrl under these events:
- Lyrics Composition Complete (callbackType: 'complete'): Dispatched once structured verses, choruses, bridges, and suggested titles are written and metrically balanced.
- Moderation Failure / Error (callbackType: 'error'): Dispatched if the topic prompt violates copyright rules or content safety guidelines.
Webhook Payload Format
{
"code": 200,
"msg": "All generated successfully.",
"data": {
"callbackType": "complete",
"task_id": "3b66882fde0a5d398bd269cab6d9542b",
"data": [
{
"title": "Starry Night Dreams",
"text": "[Verse 1]\nMoonlight spreads across the windowsill\nStars dance, never standing still\nNight breeze weaves dreams with gentle skill\nLeaving all worries on the hill\n\n[Chorus]\nIn starry dreams we find tomorrow\nBreak free from ordinary sorrow\nAll our dreams will bloom and follow\nDon't fear the path, don't fear tomorrow",
"status": "complete",
"error_message": ""
},
{
"title": "Main Street Summer",
"text": "[Verse 1]\nGolden sunshine on the pavement warm\nSummer breezes after the afternoon storm\nRadio playing our favorite song\nSinging out loud where we belong\n\n[Chorus]\nOh this summer feeling never fades\nDancing through the sunlit masquerades",
"status": "complete",
"error_message": ""
}
]
}
}Callback Payload Fields
| Field | Type | Description |
|---|---|---|
code | integer | HTTP status code of task processing (200 = Success, 400/500 = Error). |
msg | string | Status message indicating outcome (e.g. "All generated successfully."). |
data.callbackType | string | Status indicator: "complete" when lyrics generation succeeded, or "error" on failure. |
data.task_id | string | Unique identifier matching the taskId returned by POST /api/v1/createTask. |
data.data | array | Array of distinct generated lyrics proposals (typically 2 creative variations). |
data.data[].title | string | Generated song title suggested for this lyrics variation. |
data.data[].text | string | Full song lyrics structured with standard bracketed musical tags ([Verse], [Chorus], [Bridge], [Outro]). |
data.data[].status | string | Generation state of this specific lyric proposal ("complete" or "failed"). |
data.data[].error_message | string | Error details if this lyric proposal failed; empty string on success. |
Receiver Implementation Example
const express = require('express');
const app = express();
app.use(express.json({ limit: '10mb' }));
app.post('/suno-lyrics-callback', (req, res) => {
const { code, msg, data } = req.body;
const taskId = data?.task_id;
const lyricsList = data?.data || [];
console.log('Received lyrics callback:', {
taskId,
status: code,
message: msg
});
if (code === 200 && data) {
lyricsList.forEach((song, idx) => {
console.log(`Option #${idx + 1}: ${song.title}`);
console.log(song.text);
});
} else {
console.error('Lyrics generation failed:', msg);
}
// Always return HTTP 200 within 15 seconds to acknowledge receipt
return res.status(200).json({ status: 'received' });
});
app.listen(3000, () => {
console.log('Lyrics callback server running on port 3000');
});Webhook Security Recommendation
Always verify incoming webhook payloads on your server. Respond with a 200 OK immediately after parsing the payload to prevent redundant delivery retries from the webhook dispatcher.
Bracketed Tags & Metric Rhyme Structure
When requesting lyrics via POST /api/v1/createTask (taskType: "generate_lyrics"), the model formats output with industry-standard musical structure tags:
Includes [Verse], [Chorus], [Bridge], and [Outro] tags, ready to feed directly into Suno Music Generation prompts.
Returns two alternative lyrical perspectives with different rhythm meters and title proposals for selection.
Webhook Delivery & Reliability Protocol
Webhook Receiver Examples
// app/api/webhook/suno-lyrics/route.ts
import { NextRequest, NextResponse } from 'next/server';
interface LyricsItem {
title: string;
text: string;
status: 'complete' | 'failed';
error_message?: string;
}
interface LyricsCallbackPayload {
code: number;
msg: string;
data: {
callbackType: 'complete' | 'error';
task_id: string;
data?: LyricsItem[];
};
}
export async function POST(req: NextRequest) {
try {
const payload: LyricsCallbackPayload = await req.json();
const { code, msg, data } = payload;
const taskId = data?.task_id;
const lyricsList = data?.data || [];
console.log(`[Lyrics Webhook] Task ${taskId} -> Stage: ${data?.callbackType} (Code: ${code})`);
if (code === 200 && data) {
console.log(`Generated ${lyricsList.length} lyric options:`);
lyricsList.forEach((song, i) => {
if (song.status === 'complete') {
console.log(`Option #${i + 1}: "${song.title}"`);
console.log(song.text.slice(0, 100) + '...');
} else {
console.error(`Option #${i + 1} failed: ${song.error_message}`);
}
});
// Store lyrics in database or feed into music generation API
} else {
console.error(`Lyrics generation failed: ${msg}`);
}
// Always acknowledge receipt immediately with HTTP 200
return NextResponse.json({ code: 200, msg: 'success' });
} catch (error) {
console.error('Webhook error:', error);
return NextResponse.json({ code: 500, msg: 'Internal server error' }, { status: 500 });
}
}{
"code": 200,
"msg": "success"
}Ready to integrate Lyrics Generation Callbacks?
Create your free account, obtain your Secret Key, and receive structured lyrics webhooks with 5 free generation credits.