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 Corellium 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:
- Upload the image once (independent of a particular device)
- Create a device from that image
- 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:
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
})
});
Then, create a device from the uploaded image:
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
})
});
Finally, clone the default snapshot from the created device:
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
})
});