Skip to main content

Bulk Device Setup with Custom Firmware

When creating a device with an uploaded custom firmware, the image is ephemeral and is deleted when the device is created. This can be problematic when you want to create multiple devices with the same custom firmware. To avoid this issue, you can use the AVH API to create multiple devices with the same custom firmware.

When creating multiple virtual devices with the same custom firmware, the best practice is to:

  1. Upload the image once (independent of a particular device)
  2. Create a device from that image
  3. Clone the default snapshot from that device

This method is also faster and more efficient than uploading the image for each device.

To upload an image, you can use the following SDK functions:

<CodeTabs
rest={`await fetch('https://api.corellium.com/api/v1/images', {
method: 'POST',
headers: {
'Authorization': \`Bearer \${CORELLIUM_API_TOKEN}\`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
// image data
})
});`}
javascript="apiInstance.v1CreateImage(type, encoding, opts)"
python="v1_create_image(type, encoding, encapsulated=encapsulated, name=name, project=project, instance=instance, file=file)"
/>

Then, create a device from the uploaded image:

<CodeTabs
rest={`await fetch('https://api.corellium.com/api/v1/instances', {
method: 'POST',
headers: {
'Authorization': \`Bearer {apiToken},
'Content-Type': 'application/json'
},
body: JSON.stringify({
"fwpackage":"{imageId}",
// other device data
})
});`}
javascript={`await api.v1CreateInstance({
"fwpackage":"{imageId}",
// other device data
});`}
python={`await api_instance.v1_create_instance(
fwpackage='{imageId}',
# other device data
)`}
/>

Finally, clone the default snapshot from the created device:

<CodeTabs
rest={`await fetch('https://api.corellium.com/api/v1/instances', {
method: 'POST',
headers: {
'Authorization': \`Bearer {apiToken},
'Content-Type': 'application/json'
},
body: JSON.stringify({
"snapshot":"{snapshotId}",
// other device data
})
});`}
javascript={`await api.v1CreateInstance({
"snapshot":"{snapshotId}",
// other device data
});`}
python={`await api_instance.v1_create_instance(
snapshot='{snapshotId}',
# other device data
)`}
/>