When you submit an audio upload and 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
  • Retry Mechanism: Retry 3 times after failure, with intervals of 1 minute, 5 minutes, and 15 minutes respectively

Callback Request Format

When the task progresses or completes, the system will send a POST request to your callBackUrl in the following format:
{
  "code": 200,
  "msg": "All generated successfully.",
  "data": {
    "callbackType": "complete",
    "task_id": "2fac****9f72",
    "data": [
      {
        "id": "8551****662c",
        "audio_url": "https://example.cn/****.mp3",
        "source_audio_url": "https://example.cn/****.mp3",
        "stream_audio_url": "https://example.cn/****",
        "source_stream_audio_url": "https://example.cn/****",
        "image_url": "https://example.cn/****.jpeg",
        "source_image_url": "https://example.cn/****.jpeg",
        "prompt": "[Verse] Night city lights shining bright",
        "model_name": "chirp-v3-5",
        "title": "Iron Man",
        "tags": "electrifying, rock",
        "createTime": "2025-01-01 00:00:00",
        "duration": 198.44
      }
    ]
  }
}

Status Code Description

code
integer
required
Callback status code indicating task processing result:
Status CodeDescription
200Success - Request has been processed successfully
400Validation Error - Lyrics contained copyrighted material
408Rate Limited - Timeout
413Conflict - Uploaded audio matches existing work of art
500Server Error - An unexpected error occurred while processing the request
501Audio generation failed
531Server Error - Sorry, the generation failed due to an issue. Your credits have been refunded. Please try again
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
data.data[].audio_url
string
Extended audio file URL for download
data.data[].source_audio_url
string
Original source audio file URL
data.data[].stream_audio_url
string
Extended streaming audio URL for real-time playback
data.data[].source_stream_audio_url
string
Original source streaming audio URL
data.data[].image_url
string
Extended cover image URL
data.data[].source_image_url
string
Original source 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:
const express = require('express');
const fs = require('fs');
const https = require('https');
const app = express();

app.use(express.json());

app.post('/suno-extend-callback', (req, res) => {
  const { code, msg, data } = req.body;
  
  console.log('Received Suno audio extension callback:', {
    taskId: data.task_id,
    callbackType: data.callbackType,
    status: code,
    message: msg
  });
  
  if (code === 200) {
    // Task progressed or completed successfully
    const { callbackType, task_id, data: tracks } = data;
    
    console.log(`Callback type: ${callbackType}`);
    console.log(`Number of tracks: ${tracks.length}`);
    
    switch (callbackType) {
      case 'text':
        console.log('Text generation completed, waiting for audio...');
        break;
        
      case 'first':
        console.log('First track completed, processing remaining tracks...');
        downloadTracks(tracks, task_id);
        break;
        
      case 'complete':
        console.log('All tracks completed successfully!');
        downloadTracks(tracks, task_id);
        break;
    }
    
  } else {
    // Task failed
    console.log('Suno audio extension failed:', msg);
    
    // Handle specific error types
    if (code === 400) {
      console.log('Validation error - check for copyrighted content');
    } else if (code === 408) {
      console.log('Rate limited - please wait before retrying');
    } else if (code === 413) {
      console.log('Content conflict - uploaded audio matches existing work');
    } else if (code === 501) {
      console.log('Generation failed - may need to adjust parameters');
    } else if (code === 531) {
      console.log('Server error with credit refund - safe to retry');
    }
  }
  
  // Return 200 status code to confirm callback received
  res.status(200).json({ status: 'received' });
});

// Function to download tracks
function downloadTracks(tracks, taskId) {
  tracks.forEach((track, index) => {
    const { 
      id, 
      audio_url, 
      source_audio_url,
      image_url, 
      source_image_url,
      title, 
      duration 
    } = track;
    
    console.log(`Track ${index + 1}: ${title} (${duration}s)`);
    
    // Download extended audio file
    if (audio_url) {
      downloadFile(audio_url, `suno_extended_${taskId}_${id}.mp3`)
        .then(() => console.log(`Extended audio downloaded: ${id}`))
        .catch(err => console.error(`Extended audio download failed for ${id}:`, err));
    }
    
    // Download source audio file
    if (source_audio_url) {
      downloadFile(source_audio_url, `suno_source_${taskId}_${id}.mp3`)
        .then(() => console.log(`Source audio downloaded: ${id}`))
        .catch(err => console.error(`Source audio download failed for ${id}:`, err));
    }
    
    // Download extended cover image
    if (image_url) {
      downloadFile(image_url, `suno_extended_cover_${taskId}_${id}.jpeg`)
        .then(() => console.log(`Extended cover downloaded: ${id}`))
        .catch(err => console.error(`Extended cover download failed for ${id}:`, err));
    }
    
    // Download source cover image
    if (source_image_url) {
      downloadFile(source_image_url, `suno_source_cover_${taskId}_${id}.jpeg`)
        .then(() => console.log(`Source cover downloaded: ${id}`))
        .catch(err => console.error(`Source cover download failed for ${id}:`, err));
    }
  });
}

// Helper function to download files
function downloadFile(url, filename) {
  return new Promise((resolve, reject) => {
    const file = fs.createWriteStream(filename);
    
    https.get(url, (response) => {
      if (response.statusCode === 200) {
        response.pipe(file);
        file.on('finish', () => {
          file.close();
          resolve();
        });
      } else {
        reject(new Error(`HTTP ${response.statusCode}`));
      }
    }).on('error', reject);
  });
}

app.listen(3000, () => {
  console.log('Callback server running on port 3000');
});

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
  7. Download Both Versions: Consider downloading both extended and source files for comparison

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)
  • Be aware of both extended and source file URLs for complete asset management
  • Generated files will be retained for 14 days

Troubleshooting

If you do not receive callback notifications, please check the following:

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.