Creating an Audio Clip
This tutorial walks through the process of creating and publishing an audio clip using the Arc XP Audio API.
1. Create an Empty Record
First, create a metadata record for your audio clip. This establishes the clip in the system before you upload the actual audio file.
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/ \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "title": "Tutorial Audio Clip", "description": "A sample audio clip created via API", "tags": ["tutorial"] }'The API returns a 201 Created response, which includes the ID of the new audio clip. The Location header in the response contains the URL of the new resource.
2. Upload Audio
Once you have the audio_id, you can upload your audio file. Supported formats include WAV, MP3, FLAC, M4A, and MP4 (see the developer guide for details).
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/{audio_id}/upload \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "file=@/path/to/your/audio.mp3"Monitoring Progress with SSE
Audio processing happens asynchronously. To monitor this process in real-time, include the Accept: text/event-stream header in your upload request:
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/{audio_id}/upload \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: text/event-stream" \ -F "file=@/path/to/your/audio.mp3"When this header is present, the API returns a Server-Sent Events (SSE) stream with progress notifications as the audio is processed:
encoding_started: File received, encoding has begun.encoding_analyzing: Audio analysis in progress.encoding_complete: Encoding finished; the clip is ready to be published.encoding_failed: An error occurred during processing.
3. Publish the Clip
To make the audio clip available on the public internet, it needs to be published.
After the processing state reaches READY, you can publish the clip to make it available for delivery.
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/{audio_id}/publish \ -H "Authorization: Bearer YOUR_API_TOKEN"Once published, the clip’s publishing_status will transition to PUBLISHED.
4. Use with the Audio Player
Provide the audio_id to the audio player to play the clip.
<script type="module" src="https://[org]-[environment].audio.arc-cdn.net/player/koi/v0.2.17/koi-player.min.js"></script>
<h1>Hello Audio!</h1><koi-audio-player media-id="{AUDIO_ID}" org-id="{ORG_ID}"></koi-audio-player>