Skip to main content

Packages API

Overview

The Packages API provides comprehensive functionalities for managing packages, including creating, retrieving, activating, and terminating packages for SIM cards with flexible filtering options.

getPackages

This method returns a paginated and filtered list of packages.

Parameters

  • count (optional): Number of items to return
  • offset (optional): Number of items to skip
  • inventory (optional): Filter by inventory ID
  • packageTemplate (optional): Filter by package template ID
  • sim (optional): Filter by SIM ICCID
  • status (optional): Filter by package status ('NOT_ACTIVE' | 'ACTIVE' | 'SUSPENDED' | 'TERMINATED')

Return Type:

  • GetPackagesResponse

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the Packages API to fetch packages:

import { PackagesApi, Configuration } from '@betatelltd/esim-sdk';

const config = new Configuration({
apiKey: (name: string) => {
if (name === 'x-api-key') return 'your-api-key';
if (name === 'x-user-id') return 'your-user-id';
return '';
},
basePath: 'base-url',
});
const apiInstance = new PackagesApi(configuration);

let count: number; // Number of items to return (optional) (default to undefined)
let offset: number; // Number of items to skip (optional) (default to undefined)
let inventory: number; // Filter by inventory ID (optional) (default to undefined)
let packageTemplate: number; // Filter by package template ID (optional) (default to undefined)
let sim: string; // Filter by SIM ICCID (optional) (default to undefined)
let status: 'NOT_ACTIVE' | 'ACTIVE' | 'SUSPENDED' | 'TERMINATED'; // Filter by package status (optional) (default to undefined)

const { status, data } = await apiInstance.getPackages(
count,
offset,
inventory,
packageTemplate,
sim,
status
);

Response Codes

  • 200: Success
  • 400: Bad Request - Invalid parameters
  • 401: Unauthorized - Invalid or missing API key
  • 500: Internal Server Error

GetPackagesResponse

The GetPackagesResponse object contains the following properties:

NameTypeDescriptionNotes
totalnumberTotal number of packages available[default to undefined]
countnumberNumber of items returned in this response[default to undefined]
offsetnumberNumber of items skipped[default to undefined]
packagesPackage[]Array of package objects[default to undefined]

Example

import { GetPackagesResponse } from '@betatelltd/esim-sdk';

const instance: GetPackagesResponse = {
total,
count,
offset,
packages,
};

getPackage

This method returns detailed information about a specific package.

Parameters

  • id (required): Package ID

Return Type:

  • Package

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the Packages API to fetch a specific package:

import { PackagesApi, Configuration } from '@betatelltd/esim-sdk';

const config = new Configuration({
apiKey: (name: string) => {
if (name === 'x-api-key') return 'your-api-key';
if (name === 'x-user-id') return 'your-user-id';
return '';
},
basePath: 'base-url',
});
const apiInstance = new PackagesApi(configuration);

let id: string; // Package ID (default to undefined)

const { status, data } = await apiInstance.getPackage(id);

Response Codes

  • 200: Success
  • 400: Bad Request - Invalid ID
  • 401: Unauthorized - Invalid or missing API key
  • 404: Not Found - Package not found
  • 500: Internal Server Error

createPackage

This method creates a new package for a specific SIM card.

Parameters

  • createPackageRequest (required): CreatePackageRequest object

Return Type:

  • CreatePackageResponse

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the Packages API to create a package:

import { PackagesApi, Configuration, CreatePackageRequest } from '@betatelltd/esim-sdk';

const config = new Configuration({
apiKey: (name: string) => {
if (name === 'x-api-key') return 'your-api-key';
if (name === 'x-user-id') return 'your-user-id';
return '';
},
basePath: 'base-url',
});
const apiInstance = new PackagesApi(configuration);

let createPackageRequest: CreatePackageRequest; //

const { status, data } = await apiInstance.createPackage(
createPackageRequest
);

Response Codes

  • 201: Package created successfully
  • 400: Bad Request - Invalid input parameters
  • 401: Unauthorized - Invalid or missing API key
  • 409: Conflict - Package already exists for this SIM
  • 500: Internal Server Error

CreatePackageRequest

The CreatePackageRequest object contains the following properties:

NameTypeDescriptionNotes
simstringThe ICCID of the SIM card[default to undefined]
package_templatenumberThe package template ID[default to undefined]
time_allowancenumberOptional time allowance in seconds[optional] [default to undefined]

Example

import { CreatePackageRequest } from '@betatelltd/esim-sdk';

const instance: CreatePackageRequest = {
sim,
package_template,
time_allowance,
};

CreatePackageResponse

The CreatePackageResponse object contains the following properties:

NameTypeDescriptionNotes
idstringCreated package ID[default to undefined]
simstringSIM ICCID[default to undefined]
created_datenumberUnix timestamp of package creation[default to undefined]
expiry_datenumberUnix timestamp of package expiry[default to undefined]
activated_datenumberUnix timestamp when package was activated (0 if not activated)[default to undefined]
terminated_datenumberUnix timestamp when package was terminated (0 if not terminated)[default to undefined]
window_activation_startnumberUnix timestamp of activation window start[default to undefined]
window_activation_endnumberUnix timestamp of activation window end[default to undefined]
statusstringCurrent package status[default to undefined]
voice_usage_remainingnumberRemaining voice minutes[default to undefined]
data_usage_remainingnumberRemaining data in bytes[default to undefined]
sms_usage_remainingnumberRemaining SMS count[default to undefined]
time_allowancenumberTime allowance in seconds[default to undefined]
package_templateobjectPackage template details[default to undefined]
apnstringAccess Point Name[default to undefined]

Example

import { CreatePackageResponse } from '@betatelltd/esim-sdk';

const instance: CreatePackageResponse = {
id,
sim,
created_date,
expiry_date,
activated_date,
terminated_date,
window_activation_start,
window_activation_end,
status,
voice_usage_remaining,
data_usage_remaining,
sms_usage_remaining,
time_allowance,
package_template,
apn,
};

activatePackage

This method activates a specific package for use.

Parameters

  • id (required): Package ID to activate

Return Type:

  • boolean

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the Packages API to activate a package:

import { PackagesApi, Configuration } from '@betatelltd/esim-sdk';

const config = new Configuration({
apiKey: (name: string) => {
if (name === 'x-api-key') return 'your-api-key';
if (name === 'x-user-id') return 'your-user-id';
return '';
},
basePath: 'base-url',
});
const apiInstance = new PackagesApi(configuration);

let id: string; // Package ID to activate (default to undefined)

const { status, data } = await apiInstance.activatePackage(id);

Response Codes

  • 204: Package activated successfully (no content)
  • 400: Bad Request - Invalid ID or package cannot be activated
  • 401: Unauthorized - Invalid or missing API key
  • 404: Not Found - Package not found
  • 500: Internal Server Error

terminatePackage

This method terminates an active package.

Parameters

  • id (required): Package ID to terminate

Return Type:

  • boolean

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the Packages API to terminate a package:

import { PackagesApi, Configuration } from '@betatelltd/esim-sdk';

const config = new Configuration({
apiKey: (name: string) => {
if (name === 'x-api-key') return 'your-api-key';
if (name === 'x-user-id') return 'your-user-id';
return '';
},
basePath: 'base-url',
});
const apiInstance = new PackagesApi(configuration);

let id: string; // Package ID to terminate (default to undefined)

const { status, data } = await apiInstance.terminatePackage(id);

Response Codes

  • 204: Package terminated successfully (no content)
  • 400: Bad Request - Invalid ID or package cannot be terminated
  • 401: Unauthorized - Invalid or missing API key
  • 404: Not Found - Package not found
  • 500: Internal Server Error