SIM
Create and set an APN for an eSIM subscription
Creates an access point name (APN) from the request body and applies it to the given eSIM subscription. Type, protocol, and roaming protocol default to common values when omitted.
POST
/
devices
/
{deviceId}
/
esim
/
apn
JavaScript
import Mobilerun from '@mobilerun/sdk';
const client = new Mobilerun({
apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
});
await client.devices.esim.apn.set('deviceId', {
apn: 'apn',
mcc: 'mcc',
mnc: 'mnc',
name: 'name',
protocol: 'protocol',
roamingProtocol: 'roamingProtocol',
subId: 0,
type: 'type',
});import os
from mobilerun_sdk import Mobilerun
client = Mobilerun(
api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"), # This is the default and can be omitted
)
client.devices.esim.apn.set(
device_id="deviceId",
apn="apn",
mcc="mcc",
mnc="mnc",
name="name",
protocol="protocol",
roaming_protocol="roamingProtocol",
sub_id=0,
type="type",
)curl --request POST \
--url https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"apn": "<string>",
"mcc": "<string>",
"mnc": "<string>",
"name": "<string>",
"protocol": "<string>",
"roamingProtocol": "<string>",
"subId": 123,
"type": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'apn' => '<string>',
'mcc' => '<string>',
'mnc' => '<string>',
'name' => '<string>',
'protocol' => '<string>',
'roamingProtocol' => '<string>',
'subId' => 123,
'type' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn"
payload := strings.NewReader("{\n \"apn\": \"<string>\",\n \"mcc\": \"<string>\",\n \"mnc\": \"<string>\",\n \"name\": \"<string>\",\n \"protocol\": \"<string>\",\n \"roamingProtocol\": \"<string>\",\n \"subId\": 123,\n \"type\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apn\": \"<string>\",\n \"mcc\": \"<string>\",\n \"mnc\": \"<string>\",\n \"name\": \"<string>\",\n \"protocol\": \"<string>\",\n \"roamingProtocol\": \"<string>\",\n \"subId\": 123,\n \"type\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apn\": \"<string>\",\n \"mcc\": \"<string>\",\n \"mnc\": \"<string>\",\n \"name\": \"<string>\",\n \"protocol\": \"<string>\",\n \"roamingProtocol\": \"<string>\",\n \"subId\": 123,\n \"type\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"$schema": "https://example.com/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}subId comes from list-esim. Defaults when omitted: name takes the apn value; type is default,supl; protocol and roamingProtocol are IPV4V6.
On iOS the new APN becomes active immediately, replacing the previous one. On Android it is only created — and the response doesn’t return its id — so call list-esim-apns to find it, then select-esim-apn to make it preferred.Authorizations
Bearer token via Authorization header
Headers
Required range:
x >= 0Path Parameters
Body
application/json
Response
No Content
Was this page helpful?
⌘I
JavaScript
import Mobilerun from '@mobilerun/sdk';
const client = new Mobilerun({
apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
});
await client.devices.esim.apn.set('deviceId', {
apn: 'apn',
mcc: 'mcc',
mnc: 'mnc',
name: 'name',
protocol: 'protocol',
roamingProtocol: 'roamingProtocol',
subId: 0,
type: 'type',
});import os
from mobilerun_sdk import Mobilerun
client = Mobilerun(
api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"), # This is the default and can be omitted
)
client.devices.esim.apn.set(
device_id="deviceId",
apn="apn",
mcc="mcc",
mnc="mnc",
name="name",
protocol="protocol",
roaming_protocol="roamingProtocol",
sub_id=0,
type="type",
)curl --request POST \
--url https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"apn": "<string>",
"mcc": "<string>",
"mnc": "<string>",
"name": "<string>",
"protocol": "<string>",
"roamingProtocol": "<string>",
"subId": 123,
"type": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'apn' => '<string>',
'mcc' => '<string>',
'mnc' => '<string>',
'name' => '<string>',
'protocol' => '<string>',
'roamingProtocol' => '<string>',
'subId' => 123,
'type' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn"
payload := strings.NewReader("{\n \"apn\": \"<string>\",\n \"mcc\": \"<string>\",\n \"mnc\": \"<string>\",\n \"name\": \"<string>\",\n \"protocol\": \"<string>\",\n \"roamingProtocol\": \"<string>\",\n \"subId\": 123,\n \"type\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apn\": \"<string>\",\n \"mcc\": \"<string>\",\n \"mnc\": \"<string>\",\n \"name\": \"<string>\",\n \"protocol\": \"<string>\",\n \"roamingProtocol\": \"<string>\",\n \"subId\": 123,\n \"type\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mobilerun.ai/v1/devices/{deviceId}/esim/apn")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apn\": \"<string>\",\n \"mcc\": \"<string>\",\n \"mnc\": \"<string>\",\n \"name\": \"<string>\",\n \"protocol\": \"<string>\",\n \"roamingProtocol\": \"<string>\",\n \"subId\": 123,\n \"type\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"$schema": "https://example.com/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}