API Reference

Complete API documentation

Skin Data API

Endpoints for accessing skin market data and float values

Activate eSIM
POST
Activates an eSIM profile with the specified data plan.
/esims/{esim_id}/activate

Request Format

Request Body
The request body should include the following parameters:
{
  "plan_id": "plan_123456",  // Required: ID of the data plan to activate
  "activation_date": "2023-05-15T00:00:00Z",  // Optional: Schedule activation for a future date
  "auto_renew": true,  // Optional: Whether to auto-renew the plan (default: false)
  "metadata": {  // Optional: Custom metadata for the activation
    "customer_id": "cust_987654",
    "order_id": "order_123456"
  }
}

Response Format

Success Response
A successful response will include the following:
{
  "success": true,
  "data": {
    "esim_id": "esim_123456",
    "status": "active",
    "activation_date": "2023-05-15T00:00:00Z",
    "expiration_date": "2023-06-15T00:00:00Z",
    "plan": {
      "id": "plan_123456",
      "name": "Global 30-Day Unlimited",
      "data_limit": "Unlimited",
      "validity_days": 30
    },
    "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
    "activation_code": "LPA:1$SMDP.ESIM.COM$04386-ACBDE-85792",
    "auto_renew": true
  }
}
Error Response
Possible error responses:
{
  "success": false,
  "error": {
    "code": "invalid_plan",
    "message": "The specified plan_id does not exist or is not available for this eSIM.",
    "details": {
      "plan_id": "plan_123456"
    }
  }
}

Code Examples

Activate an eSIM
Examples of how to activate an eSIM with a data plan:
// Using fetch API
const activateEsim = async (esimId, planId) => {
  const response = await fetch(`https://api.esm.mobi/v1/esims/${esimId}/activate`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      plan_id: planId,
      auto_renew: true
    })
  });

  const data = await response.json();
  
  if (!data.success) {
    throw new Error(`Activation failed: ${data.error.message}`);
  }
  
  return data.data;
};

// Example usage
try {
  const result = await activateEsim('esim_123456', 'plan_789012');
  console.log('eSIM activated successfully:', result);
  
  // Display QR code to user for scanning
  const qrCodeImage = result.qr_code;
  
  // Or display activation code for manual entry
  const activationCode = result.activation_code;
} catch (error) {
  console.error('Error activating eSIM:', error.message);
}

Related Endpoints

Deactivate eSIM
POST
Deactivates an active eSIM profile.
/esims/{esim_id}/deactivate
View detailed documentation
Check eSIM Status
GET
Retrieves the current status of an eSIM profile.
/esims/{esim_id}/status
View detailed documentation