When music generation tasks are completed, the system will send results to your provided callback URL via POST request
When you submit a task to the music generation API, you can use the callBackUrl parameter to set a callback URL. When the task is completed, the system will automatically push the results to your specified address.Callback Mechanism Overview#
The callback mechanism eliminates the need to poll the API for task status. The system will proactively push task completion results to your server.
Callback Timing#
The system will send callback notifications in the following situations:Text generation completed (text stage)
First music track generated (first stage)
All music tracks generated (complete stage)
Music generation task failed
Error occurred during task processing
Callback Method#
Content Type: application/json
When the task is completed, the system will send a POST request to your callBackUrl in the following format:Text Generation Complete Callback
First Track Complete Callback
All Tracks Complete Callback
{
"code": 200,
"msg": "Text generation completed successfully.",
"data": {
"callbackType": "text",
"task_id": "2fac****9f72",
"data": []
}
}
Status Code Description#
code · integer · requiredCallback status code indicating task processing result:| Status Code | Description |
|---|
| 200 | Success - Music generation completed |
| 400 | Bad Request - Parameter error or content violation |
| 401 | Unauthorized - Invalid API key |
| 413 | Content Too Long - Prompt or style description exceeds limit |
| 429 | Insufficient Credits - Account credit balance insufficient |
| 500 | Server Error - Please retry later |
Status message providing detailed status descriptiondata.callbackType · string · requiredCallback type indicating the current callback stage:text: Text generation completed
first: First music track generated
complete: All music tracks generated
data.task_id · string · requiredTask ID, consistent with the taskId returned when you submitted the taskMusic generation result information, returned on successAudio unique identifier (audioId)data.data[].audio_url · stringdata.data[].source_audio_url · string · deprecatedDeprecated. Original audio file link returned by Suno. This link expires after a period of time and is no longer maintained — do not rely on it for long-term storage. Use the Recovery Audio endpoint to obtain a fresh playable link.data.data[].stream_audio_url · stringStreaming audio playback linkdata.data[].image_url · stringdata.data[].prompt · stringPrompt/lyrics used for generationdata.data[].model_name · stringdata.data[].title · stringdata.data[].tags · stringdata.data[].createTime · stringdata.data[].duration · numberCallback Reception Examples#
Here are example codes for receiving callbacks in various popular programming languages:Best Practices#
Callback URL Configuration Recommendations#
1.
Use HTTPS: Ensure your callback URL uses HTTPS protocol for secure data transmission
2.
Verify Source: Verify the legitimacy of the request source in callback processing
3.
Idempotent Processing: Ensure processing logic is idempotent as the same taskId may receive multiple callbacks
4.
Quick Response: Callback processing should return 200 status code quickly to avoid timeout
5.
Asynchronous Processing: Complex business logic should be processed asynchronously to avoid blocking callback response
6.
Stage-based Processing: Handle different callback stages (text, first, complete) with appropriate business logic
7.
Music Download: Music download and processing should be done in asynchronous tasks to avoid blocking callback response
Important Reminders#
Callback URL must be publicly accessible
Server must respond within 15 seconds, otherwise considered timeout
After 3 consecutive retry failures, the system will stop sending callbacks
Ensure stability of callback processing logic to avoid callback failures due to exceptions
Generated audio URLs may have time limits, recommend downloading and saving promptly
Pay attention to content compliance to avoid generation failures due to violations
Music generation has three stages, each stage will trigger callback notifications
Troubleshooting#
If you don't receive callback notifications, please check the following:Alternative Solutions#
If you cannot use the callback mechanism, you can also use polling:
Poll Query Results
Use the Get Music Generation Details interface to regularly query task status. Recommend querying every 30 seconds.