Via API, you have the possibility to change the status (activate or suspend) multiple SIMs at once. To do so, the SIM cards first need to be registered in the EUI (step 1), you then need to know their SIM ID (step 2) and you can finally activate or suspend them (step 3). By using an API software like Postman, you can do so for several SIMs at once (step 4).
To understand this article, you need to be able to authenticate using an "Application Token".
1. Register the SIM (if not already done) using its BIC
Before we can do any actions on SIM cards, we need to register them.
You can do it via the EUI , as explained here, or run the following API. In the example below, the BIC is ABCD1234EFGH6789
API call:
GET https://cdn.emnify.net/api/v1/sim_batch/bic/ABCD1234EFGH6789
Header:
Content-type: application/json
Authorization: Bearer {{auth_token}}
Response: 200 OK
2. Find the SIM ID of your SIM cards
This information can be found in the EUI in the "SIMs" tab. Simply copy and paste the ID of all the SIM cards the status of which you want to change.
You can also go to the "SIM database" dashboard under "Stats->Data analytics" and download a .csv file containing all your SIM card data.
3. Activate or suspend one SIM card based on its ID
3.1 Status info
A SIM card can have 4 different status:
- 0: "Issued" - initial state after the SIM has been registered to an account. This status can only be updated to the status 1 "activated".
- 1: "Activated" - The SIM can now be used and the hosting fee will be charged each month. This status can be updated to 2 "suspended".
- 2: "Suspended" - The SIM has been suspended, it will not work anymore and no monthly fee will be charged. It can be activated again. This status can be updated to 1 "activated".
- 3: "Deleted" - The SIM has been erased from the system. It cannot be registered again and will never work again. This status is permanent.
3.2 Running the API
Here is how the API looks like for an issued SIM card with the ID "231231".
API call:
PATCH https://cdn.emnify.net/api/v1/sim/231231
Header:
Content-type: application/json
Authorization: Bearer {{auth_token}}
Body:
|
4. Activate or suspend multiple SIM cards in Postman
If you wish to change the status of several SIM cards at once, you can run a compilation in Postman.
4.1 Create a CSV file with the SIM ID
sim_id |
234790 |
234791 |
234792 |
234793 |
You can use excel but it sometimes is messy when using .csv files. Notepad++ can be better.
4.2 Update your Patch API
Postman will use the info within your .csv file. We need to update it as follow:
API call:
PATCH https://cdn.emnify.net/api/v1/sim/{{sim_id}}
Header:
Content-type: application/json
Authorization: Bearer {{auth_token}}
Body:
|
Pre-request Script:
console.log("sim_id" + data.sim_id)
4.3 Run a collection in Postman to change the status of several SIM cards.
In Postman, run the collection containing the above API. Click on Runner, choose the right collection and environment and select the .csv file containing your sim_id information. The "Iterations" field should update and show the number of rows within this file. You can preview it to make sure the format fits. It should look as follow:
When you are ready, click on "Run...". The status of the SIM cards should update.
Comments
0 comments
Please sign in to leave a comment.