Skip to main content

Music Extension Callbacks

System will call this callback when audio generation is complete
When you submit a music extension task to the Suno API, you can use the callBackUrl parameter to set a callback URL. The system will automatically push the results to your specified address when the task is completed.

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 (callbackType: “text”)
  • First audio track generation completed (callbackType: “first”)
  • All audio tracks generation completed (callbackType: “complete”)
  • Audio generation task failed
  • Errors occurred during task processing

Callback Method

  • HTTP Method: POST
  • Content Type: application/json
  • Timeout Setting: 15 seconds

Callback Request Format

When the task progresses or completes, the system will send a POST request to your callBackUrl in the following format:

Status Code Description

code
integer
required
Callback status code indicating task processing result:
msg
string
required
Status message providing detailed status description
data.callbackType
string
required
Callback type indicating the stage of generation:
  • text: Text generation complete
  • first: First track complete
  • complete: All tracks complete
  • error: Generation failed
data.task_id
string
required
Task ID, consistent with the taskId returned when you submitted the task
data.data
array
required
Array of generated audio tracks. Empty for text callbacks or failures.
data.data[].id
string
Audio unique identifier (audioId)
data.data[].audio_url
string
Audio file URL for download
data.data[].stream_audio_url
string
Streaming audio URL for real-time playback
data.data[].image_url
string
Cover image URL
data.data[].prompt
string
Generation prompt/lyrics used
data.data[].model_name
string
Model name used for generation (e.g., “chirp-v3-5”)
data.data[].title
string
Music title
data.data[].tags
string
Music tags/genre
data.data[].createTime
string
Creation timestamp
data.data[].duration
number
Audio duration in seconds

Callback Reception Examples

Here are example codes for receiving callbacks in 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: The same task_id may receive multiple callbacks, ensure processing logic is idempotent
  4. Quick Response: Callback processing should return a 200 status code as quickly as possible to avoid timeout
  5. Asynchronous Processing: Complex business logic should be processed asynchronously to avoid blocking callback response
  6. Handle Multiple Callbacks: Be prepared to receive text, first, and complete callbacks for the same task

Important Reminders

  • Callback URL must be a publicly accessible address
  • Server must respond within 15 seconds, otherwise it will be considered a timeout
  • If 3 consecutive retries fail, the system will stop sending callbacks
  • You may receive multiple callbacks for the same task (text → first → complete)
  • Please ensure the stability of callback processing logic to avoid callback failures due to exceptions
  • Handle copyright and conflict errors appropriately (codes 400, 413)
  • Credit refunds are automatic for certain server errors (code 531)

Troubleshooting

If you do not receive callback notifications, please check the following:
  • Confirm that the callback URL is accessible from the public network
  • Check firewall settings to ensure inbound requests are not blocked
  • Verify that domain name resolution is correct
  • Ensure the server returns HTTP 200 status code within 15 seconds
  • Check server logs for error messages
  • Verify that the interface path and HTTP method are correct
  • Confirm that the received POST request body is in JSON format
  • Check that Content-Type is application/json
  • Verify that JSON parsing is correct
  • Confirm that audio URLs are accessible
  • Check audio download permissions and network connections
  • Verify audio save paths and permissions
  • Handle both regular and streaming audio URLs appropriately
  • Process multiple tracks in the same callback
  • Handle timeout errors gracefully (code 408)
  • Implement appropriate retry logic with backoff
  • Monitor API usage to avoid rate limits
  • Consider upgrading service plan if needed

Alternative Solution

If you cannot use the callback mechanism, you can also use polling:

Poll Query Results

Use the get music details endpoint to regularly query task status. We recommend querying every 30 seconds.

To find navigation and other pages in this documentation, fetch the llms.txt file at: https://docs.apikley.ru/llms.txt
Rate limits and quotas are enforced by Apikley and may differ from upstream providers.