Skip to main content

Replace Music Section Callbacks

Understand the callback mechanism for replace music section tasks
When you submit a replace music section task to the API, you can provide a callBackUrl to receive real-time notifications about task progress and completion.

Callback Mechanism

When Callbacks Are Sent

The system sends callbacks at the following times:
  • Complete: When the replacement task is fully completed

Callback Method

  • HTTP Method: POST
  • Content-Type: application/json
  • Timeout: 10 seconds
  • Retry Policy: Up to 3 attempts with exponential backoff

Request Format

Success Callback

When the replacement task completes successfully:

Failure Callback

When the replacement task fails:

Status Codes

Response Fields

Success Response Fields

code
integer
required
Status code indicating the result of the replacement task
msg
string
required
Status message describing the result
data
object
required
Container for callback data

Implementation Examples

Node.js (Express)

Python (Flask)

PHP

Callback Security

Verification Recommendations

  1. IP Whitelist: Restrict callback endpoints to known IP addresses
  2. HTTPS Only: Always use HTTPS for callback URLs in production
  3. Request Validation: Validate the structure and content of callback requests
  4. Timeout Handling: Implement proper timeout handling for callback processing

Example Security Implementation

Troubleshooting

Common Issues

Q: Callbacks are not being received
  • Verify your callback URL is publicly accessible
  • Check that your server is responding within 10 seconds
  • Ensure your endpoint accepts POST requests with JSON content
Q: Receiving duplicate callbacks
  • This can happen due to network issues or timeouts
  • Implement idempotency using the task_id to handle duplicates
Q: Callback data is missing or incomplete
  • Check the callbackType field to understand the callback stage
  • For error callbacks, check the error message for details
Q: How to handle callback failures?
  • Always return a 200 status code to acknowledge receipt
  • Use the Get Music Details endpoint to poll task status as a fallback

Best Practices

  1. Always Acknowledge: Return HTTP 200 even if your processing fails
  2. Implement Retry Logic: Handle temporary failures gracefully
  3. Log Everything: Keep detailed logs for debugging
  4. Use Fallback Polling: Don’t rely solely on callbacks for critical workflows
  5. Validate Data: Always validate callback data before processing

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.