How to rename SIMs using the REST API
You can set device names programmatically using the Devices endpoint. Below are two approaches: upload a CSV of ICCIDs and names, or apply a sequential prefix across a list of device IDs.Note: You can also rename SIMs in your dashboard.
Update device names using a CSV
1
Prepare a CSV with Name and ICCID columns
First we need to make the CSV. This is a simple document with two columns: one for the Name we want to give the SIMs, and the other with an ICCID from the SIM we want to receive this new name.
For smaller batches, you can also use Dashboard bulk actions to rename SIMs.
| Name | ICCID |
|---|---|
| New Name 1 | 8901000000000000001 |
| New Name 2 | 8901000000000000002 |
| New Name 3 | 8901000000000000003 |
2
Use a helper script to perform updates
Now we move on to the code. Use the code below in your favorite text editor or Python’s IDLE.
3
Run the program
Run the program and when prompted enter your API Key.
Note: Always test with a few devices before applying bulk changes.
Add sequential names with a shared prefix
1
Use a helper script to add sequential names with a shared prefix
Use the code below in your favorite text editor or Python’s IDLE.
2
Enter your new name prefix
Replace the green
Prefix text with the prefix you’d like to add, but make sure to leave the " on either side. A -# will be appended to the prefix text starting at 1 and increasing by 1 for every device that is run through this script.3
Enter the list of device IDs to update
Replace
DEVICE_1,DEVICE_2,DEVICE_N with a comma separated list of device IDs you want to rename. An easy way to get a list of devices is using the CSV export tool at the bottom left-hand side of the Dashboard’s Devices section.4
Enter your API Key
Replace the green
YOUR_API_KEY text with your API Key, make sure to leave the " on either side.5
Run the script
Run the script to rename the devices.