Skip to main content

PCR API

Overview

The PCR (Package Configuration and Resources) API provides functionalities for managing package templates, including creating, retrieving, and listing templates with various data and time configurations.

getPackageTemplates

This method returns a paginated list of all available package templates with optional filtering.

Parameters

  • count (optional): Number of items to return (defaults to 100)
  • offset (optional): Number of items to skip (defaults to 0)
  • inventory (optional): Filter by inventory ID

Return Type:

  • GetPackageTemplatesResponse

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the PCR API to fetch package templates:

import { PCRApi, 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: 'your-base-url',
});
const apiInstance = new PCRApi(config);

let count: number = 100; // Number of items to return (optional)
let offset: number = 0; // Number of items to skip (optional)
let inventory: number; // Filter by inventory ID (optional)

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

Response Codes

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

GetPackageTemplatesResponse

The GetPackageTemplatesResponse object contains the following properties:

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

Example

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

const instance: GetPackageTemplatesResponse = {
total: 50,
count: 20,
offset: 0,
package_templates: [{ id: 1, name: "Basic Plan", ... }]
};

getPackageTemplate

This method returns detailed information about a specific package template.

Parameters

  • id (required): Package template ID

Return Type:

  • PackageTemplate

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

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

import { PCRApi, 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: 'your-base-url',
});
const apiInstance = new PCRApi(config);

let id: number = 1; // Package template ID

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

Response Codes

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

createPackageTemplate

This method creates a new package template with specified data, time, and activation configurations.

Parameters

  • createPackageTemplateRequest (required): CreatePackageTemplateRequest object

Return Type:

  • CreatePackageTemplateResponse

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

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

import { PCRApi, Configuration, CreatePackageTemplateRequest } 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: 'your-base-url',
});
const apiInstance = new PCRApi(config);

let createPackageTemplateRequest: CreatePackageTemplateRequest = {
name: "Premium Plan",
supported_countries: ["US", "CA"],
activation_type: "instant",
data_usage_allowance: 5000000000, // 5GB
time_allowance: 30, // 30 days
inventory: 1
};

const { status, data } = await apiInstance.createPackageTemplate(createPackageTemplateRequest);

Response Codes

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

CreatePackageTemplateRequest

The CreatePackageTemplateRequest object contains the following properties:

NameTypeDescriptionNotes
namestringPackage template name[default to undefined]
supported_countriesArray stringArray of supported country ISO3 codes[default to undefined]
activation_typestringPackage activation type[default to undefined]
data_usage_allowancenumberData allowance in bytes[default to undefined]
time_allowanceTimeAllowanceAllowance duration in days[default to undefined]
inventorynumberInventory ID to associate the template with[default to undefined]

Example

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

const instance: CreatePackageTemplateRequest = {
name: "Premium Plan",
supported_countries: ["US", "CA"],
activation_type: "instant",
data_usage_allowance: 5000000000, // 5GB
time_allowance: 30, // 30 days
inventory: 1
};

CreatePackageTemplateResponse

The CreatePackageTemplateResponse object contains the following properties:

NameTypeDescriptionNotes
idnumber......
namestring......
voice_usage_allowancenumberVoice allowance in minutes[default to undefined]
data_usage_allowancenumberData allowance in bytes[default to undefined]
sms_usage_allowancenumberSMS allowance count[default to undefined]
time_allowanceTimeAllowanceTime allowance[default to undefined]
activation_time_allowancenumberTime allowance for activation in seconds[default to undefined]

Example

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

const instance: CreatePackageTemplateResponse = {
id,
name,
voice_usage_allowance,
data_usage_allowance,
sms_usage_allowance,
time_allowance,
activation_time_allowance,
};

PackageTemplate

The PackageTemplate object contains the following properties:

NameTypeDescriptionNotes
idnumber......
namestring......