Purchase eSIMs
Purchases and registers the specified amount of eSIMs to the current user’s account.
If sim_card_group_id is provided, the eSIMs will be associated with that group. Otherwise, the default group for the current user will be used.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const purchase = await client.actions.purchase.create({ amount: 10 });
console.log(purchase.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
purchase = client.actions.purchase.create(
amount=10,
)
print(purchase.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
purchase, err := client.Actions.Purchase.New(context.TODO(), telnyx.ActionPurchaseNewParams{
Amount: 10,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", purchase.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.actions.purchase.PurchaseCreateParams;
import com.telnyx.sdk.models.actions.purchase.PurchaseCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
PurchaseCreateParams params = PurchaseCreateParams.builder()
.amount(10L)
.build();
PurchaseCreateResponse purchase = client.actions().purchase().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
purchase = telnyx.actions.purchase.create(amount: 10)
puts(purchase)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$purchase = $client->actions->purchase->create(
amount: 10,
product: 'whitelabel',
simCardGroupID: '6a09cdc3-8948-47f0-aa62-74ac943d6c58',
status: 'standby',
tags: ['personal', 'customers', 'active-customers'],
whitelabelName: 'Custom SPN',
);
var_dump($purchase);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx actions:purchase create \
--api-key 'My API Key' \
--amount 10curl --request POST \
--url https://api.telnyx.com/v2/actions/purchase/esims \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 10,
"sim_card_group_id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"tags": [
"personal",
"customers",
"active-customers"
],
"product": "whitelabel",
"whitelabel_name": "Custom SPN",
"status": "standby"
}
'{
"data": [
{
"id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"record_type": "sim_card",
"status": {
"value": "enabled",
"reason": "The SIM card is active, ready to connect to networks and consume data."
},
"type": "physical",
"iccid": "89310410106543789301",
"imsi": "081932214823362973",
"msisdn": "+13109976224",
"sim_card_group_id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"tags": [
"personal",
"customers",
"active-customers"
],
"data_limit": {
"amount": "2048.0",
"unit": "MB"
},
"current_billing_period_consumed_data": {
"amount": "2049.0",
"unit": "MB"
},
"actions_in_progress": true,
"created_at": "2018-02-02T22:25:27.521Z",
"updated_at": "2018-02-02T22:25:27.521Z",
"esim_installation_status": "released",
"version": "4.3",
"resources_with_in_progress_actions": [],
"eid": null,
"authorized_imeis": [
"106516771852751",
"534051870479563",
"508821468377961"
],
"voice_enabled": false
}
],
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request."
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The amount of eSIMs to be purchased.
x >= 110
The group SIMCardGroup identification. This attribute can be null when it's present in an associated resource.
"6a09cdc3-8948-47f0-aa62-74ac943d6c58"
Searchable tags associated with the SIM cards
["personal", "customers", "active-customers"]
Type of product to be purchased, specify "whitelabel" to use a custom SPN
"whitelabel"
Service Provider Name (SPN) for the Whitelabel eSIM product. It will be displayed as the mobile service name by operating systems of smartphones. This parameter must only contain letters, numbers and whitespaces.
"Custom SPN"
Status on which the SIM cards will be set after being successfully registered.
enabled, disabled, standby "standby"
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const purchase = await client.actions.purchase.create({ amount: 10 });
console.log(purchase.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
purchase = client.actions.purchase.create(
amount=10,
)
print(purchase.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
purchase, err := client.Actions.Purchase.New(context.TODO(), telnyx.ActionPurchaseNewParams{
Amount: 10,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", purchase.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.actions.purchase.PurchaseCreateParams;
import com.telnyx.sdk.models.actions.purchase.PurchaseCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
PurchaseCreateParams params = PurchaseCreateParams.builder()
.amount(10L)
.build();
PurchaseCreateResponse purchase = client.actions().purchase().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
purchase = telnyx.actions.purchase.create(amount: 10)
puts(purchase)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$purchase = $client->actions->purchase->create(
amount: 10,
product: 'whitelabel',
simCardGroupID: '6a09cdc3-8948-47f0-aa62-74ac943d6c58',
status: 'standby',
tags: ['personal', 'customers', 'active-customers'],
whitelabelName: 'Custom SPN',
);
var_dump($purchase);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx actions:purchase create \
--api-key 'My API Key' \
--amount 10curl --request POST \
--url https://api.telnyx.com/v2/actions/purchase/esims \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 10,
"sim_card_group_id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"tags": [
"personal",
"customers",
"active-customers"
],
"product": "whitelabel",
"whitelabel_name": "Custom SPN",
"status": "standby"
}
'{
"data": [
{
"id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"record_type": "sim_card",
"status": {
"value": "enabled",
"reason": "The SIM card is active, ready to connect to networks and consume data."
},
"type": "physical",
"iccid": "89310410106543789301",
"imsi": "081932214823362973",
"msisdn": "+13109976224",
"sim_card_group_id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"tags": [
"personal",
"customers",
"active-customers"
],
"data_limit": {
"amount": "2048.0",
"unit": "MB"
},
"current_billing_period_consumed_data": {
"amount": "2049.0",
"unit": "MB"
},
"actions_in_progress": true,
"created_at": "2018-02-02T22:25:27.521Z",
"updated_at": "2018-02-02T22:25:27.521Z",
"esim_installation_status": "released",
"version": "4.3",
"resources_with_in_progress_actions": [],
"eid": null,
"authorized_imeis": [
"106516771852751",
"534051870479563",
"508821468377961"
],
"voice_enabled": false
}
],
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request."
}
]
}