Getting Started
Audio

Uploading audio

Getting started

In order to send audio to the Audio API, you can do so by sending a POST request to the https://api.fivemanage.com/api/audio (opens in a new tab) endpoint.

To upload audio, simply submit a form with a form field called file with your audio as value.

A lot like images, audio uploads also allow for metadata through the metadata form field.

Uploading audio

const axios = require('axios');
const fs = require('fs');
 
const apiKey = 'YOUR_API_TOKEN';
const url = 'https://api.fivemanage.com/api/audio';
 
const formData = new FormData();
 
formData.append('file', yourAudioBlob);
// Optional metadata field (JSON string)
formData.append("metadata", JSON.stringify({
    name: 'My audio',
    description: 'This is a recording of something cool",
    // or any other field
}));
 
axios.post(url, formData, {
    headers: {
        Authorization: apiKey,
    }
}).then(res => {
    console.log(res.data.url);
}).catch(err => {
    console.error(err);
});

Response

Success
{
    "url": "https://r2.fivemanage.com/audio/1234567890",
    "id": "0987654321"
}

Deleting audio

When we want to delete audio, we can do so by sending a DELETE request to the https://api.fivemanage.com/api/audio/:id (opens in a new tab) endpoint.

The :id parameter should be the ID of the audio file you want to delete. You can get the ID from the response when you upload the audio file (see above).

import axios from "axios";
 
const options = {
  method: 'DELETE',
  url: 'http://api.fivemanage.com/api/audio/delete/0987654321',
  headers: {
    Authorization: 'YOUR_API_TOKEN'
  }
};
 
axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});