API Documentation

POST /item/{id}/audio

Add a new Item Audio
https://api.vendbits.com/v1/item/{id}/audio

Parameters

api_token required string API token
id required string ID of the Item to add audio file
preview_audio optional array Array of preview audio files for Item which are shown on item page (first audio file in array set as default)
vend_audio optional array Array of audio files for Item which are only shown upon purchase

Example cURL Request

$ curl -X POST -i https://api.vendbits.com/v1/item/1/audio?api_token=API_TOKEN&PARAMETERS

Example Response

{
    "item_id": AbCdE12345,
    "visibility": "public",
    "url": "https://vendbits.com/item/AbCdE12345",
    "title": "This is the item title",
    "description": "This is the item description",
    "price_usd": "3.50",
    "accept_paypal": true,
    "accept_stripe": true,
    "accept_btc": false,
    "accept_bch": false,
    "category": {
        "category": "Audio",
        "url": "https://vendbits.com/category/audio"
    },
    "tags": [
        {
            "tag": "tag",
            "url": "https://vendbits.com/tag/tag"
        },
        {
            "tag": "tag2",
            "url": "https://vendbits.com/tag/tag2"
        },
        {
            "tag": "tag3",
            "url": "https://vendbits.com/tag/tag3"
        }
    ],
    "reviews_total": 12,
    "reviews_avg": 4.60,
    "seller": {
        "username": "funnyman",
        "url": "https://vendbits.com/funnyman",
        "avatar": "https://vendbits.com/images/no-avatar.png",
        "reviews_total": 24,
        "reviews_avg": 4.80
    },
    "quantity_remaining": "unlimited",
    "expiration": null,
    "vend_message": "Thank you for your purchase. Here are your files...",
    "default_preview_image_thumb": [
        {
            "image_id": 1,
            "src": "https://vendbits.com/images/t_kJDyFTJNnkVk2cv9A1X1sqfMXCct8A.png",
            "width": 222,
            "height": 252,
            "filesize": 62998
        }
    ],
    "preview_images_thumbs": [
        {
            "image_id": 1,
            "src": "https://vendbits.com/images/t_kJDyFTJNnkVk2cv9A1X1sqfMXCct8A.png",
            "width": 222,
            "height": 252,
            "filesize": 62998
        },
        {
            "image_id": 2,
            "src": "https://vendbits.com/images/t_gAiETXTU0YyNsXBvO2bnLPhaceFeFT.jpg",
            "width": 252,
            "height": 189,
            "filesize": 1122239
        }
    ],
    "default_preview_image": [
        {
            "image_id": 1,
            "src": "https://vendbits.com/images/kJDyFTJNnkVk2cv9A1X1sqfMXCct8A.png",
            "width": 510,
            "height": 578,
            "filesize": 62998
        }
    ],
    "preview_images": [
        {
            "image_id": 1,
            "src": "https://vendbits.com/images/kJDyFTJNnkVk2cv9A1X1sqfMXCct8A.png",
            "width": 510,
            "height": 578,
            "filesize": 62998
        },
        {
            "image_id": 2,
            "src": "https://vendbits.com/images/gAiETXTU0YyNsXBvO2bnLPhaceFeFT.jpg",
            "width": 4032,
            "height": 3024,
            "filesize": 1122239
        }
    ],
    "vend_images": [
        {
            "image_id": 3,
            "src": "https://vendbits.com/images/ZjX2jtYAUiF9IUHw442F6uDJdZGI6z.png",
            "width": 1334,
            "height": 750,
            "filesize": 1892782
        }
    ],
    "default_preview_audio": [
        {
            "audio_id": 1,
            "src": "https://vendbits.com/audio/7oQZjiLvzr3mNEeDJYzgGtqfjyrVuR.mp4",
            "duration": 6,
            "filesize": 6451477
        }
    ],
    "preview_audio": [
        {
            "audio_id": 1,
            "src": "https://vendbits.com/audio/7oQZjiLvzr3mNEeDJYzgGtqfjyrVuR.mp4",
            "duration": 6,
            "filesize": 6451477
        }
    ],
    "vend_audio": [
        {
            "audio_id": 2,
            "src": "https://vendbits.com/audio/1VCT9chpclFAQhqkQoPhbk7gYVOGjz.wav",
            "duration": 86,
            "filesize": 16473678
        },
        {
            "audio_id": 3,
            "src": "https://vendbits.com/audio/o6f2sRBC6e5LemV39nXj5Wi2nU7w5w.mp3",
            "duration": 1,
            "filesize": 5616
        }
    ],
    "default_preview_video": [
        {
            "video_id": 1,
            "src": "https://vendbits.com/videos/ilFBF7ICacfBk0n8D2yg4RjpwzhKmf.mov",
            "duration": 8,
            "filesize": 6938057,
            "compat_src": "https://vendbits.com/videos/ilFBF7ICacfBk0n8D2yg4RjpwzhKmf.mp4",
            "compat_filesize": 984765
        }
    ],
    "preview_videos": [
        {
            "video_id": 1,
            "src": "https://vendbits.com/videos/ilFBF7ICacfBk0n8D2yg4RjpwzhKmf.mov",
            "duration": 8,
            "filesize": 6938057,
            "compat_src": "https://vendbits.com/videos/ilFBF7ICacfBk0n8D2yg4RjpwzhKmf.mp4",
            "compat_filesize": 984765
        }
    ],
    "vend_videos": [
        {
            "video_id": 2,
            "src": "https://vendbits.com/videos/7KujavAHpCunAXoAEnAnhcwobUREKI.mp4",
            "duration": 8,
            "filesize": 6938057,
            "compat_src": "https://vendbits.com/videos/7KujavAHpCunAXoAEnAnhcwobUREKI.mp4",
            "compat_filesize": 984765
        }
    ]
}

HTTP Status Response Codes

201 - The item data is returned.
401 - API Token (api_token parameter) incorrect.
404 - Item does not exist.
422 - Data did not validate.
Response Note: The successful response will be the same as the /item/{id} endpoint and return the item data.

PHP Code Example

<?php

$preview_audio 
= array( 
    
'/path/to/file/audio.wav',    
);

$vend_audio = array( 
    
'/path/to/file/premium-audio.wav',   
);

$preview_audio_titles = array(
    
'preview photo title',                                                                                               
);  

$vend_audio_titles = array(
    
'vend photo title',                                                                                               
);  

/* no need to edit below */
$ch curl_init('https://api.vendbits.com/v1/item');
curl_setopt($chCURLOPT_HEADER0);
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_POSTtrue);
curl_setopt($chCURLOPT_TIMEOUT30);

foreach (
$preview_audio as $index => $audio) {
    
$postData['preview_audio[' $index ']'] = curl_file_create(
        
realpath($audio),
        
mime_content_type($audio),
        
basename($audio)
    );
}

foreach (
$vend_audio as $index => $audio) {
    
$postData['vend_audio[' $index ']'] = curl_file_create(
        
realpath($audio),
        
mime_content_type($audio),
        
basename($audio)
    );
}

// media file titles
foreach ($preview_audio_titles as $index => $title) {
    
$postData['preview_audio_titles[' $index ']'] = $title;
}

foreach (
$vend_audio_titles as $index => $title) {
    
$postData['vend_audio_titles[' $index ']'] = $title;
}

curl_setopt($chCURLOPT_POSTFIELDS$postData );
$response curl_exec($ch); ?>