Skip to content

Purchase Virtual Number

This API is used to purchase a virtual number for your account.

Parameters for Purchasing Virtual Number

Headers Parameters

ParametersDescription
AuthorizationPlease add provided Bearer token - linked to your Cellcast account. Check here
Content-Typeapplication/json

Request Body Parameters

NameExampleDescription
cardcard_1SQmzoGOdUwLPbU6ll0QwsyHRequired. The card ID for payment.
productprod_PFdN753rT3lNFWRequired. The product ID for the virtual number.
number66ea98514f0c1a121c76ec17Required. The ID of the virtual number to purchase.
recurring_timemonthRequired. The billing cycle (e.g., month, year).
resubscribefalseOptional. Whether to resubscribe automatically.

Important Note on Product ID

The product parameter must match the recurring_time value:

Using the incorrect product ID for the billing cycle will result in a purchase error.

Code Samples

Post https://api.cellcast.com/api/v1/virtual-number/purchase

bash
curl --location 'https://api.cellcast.com/api/v1/apiClient/virtual-number/purchase' \
--header 'authorization: Bearer {{API_KEY}}' \
--header 'content-type: application/json' \
--data '{
    "card": "card_1SQmzoGOdUwLPbU6ll0QwsyH",
    "product": "prod_PFdN753rT3lNFW",
    "number": "66ea98514f0c1a121c76ec17",
    "recurring_time": "month",
    "resubscribe": false
}'
js
const axios = require('axios');

async function purchaseVirtualNumber() {
    const url = 'https://api.cellcast.com/api/v1/apiClient/virtual-number/purchase';
    const apiKey = 'your_api_key_here'; // Replace with your actual API key
    const payload = {
        card: 'card_1SQmzoGOdUwLPbU6ll0QwsyH',
        product: 'prod_PFdN753rT3lNFW',
        number: '66ea98514f0c1a121c76ec17',
        recurring_time: 'month',
        resubscribe: false,
    };

    try {
        const response = await axios.post(url, payload, {
            headers: {
                Authorization: `Bearer ${apiKey}`,
                'Content-Type': 'application/json',
            },
        });

        console.log('Response:', response.data);
    } catch (error) {
        console.error('Error:', error.response ? error.response.data : error.message);
    }
}

purchaseVirtualNumber();

Replace with the actual API key that you own.

Responses

200 Success

json
{
    "app_type": "web",
    "app_version": "1.0",
    "maintainence": 0,
    "new_version": 0,
    "force_update": 0,
    "invalid_token": 0,
    "refresh_token": "",
    "show_message": 1,
    "is_enc": false,
    "status": true,
    "message": "Payment is Successful. Dedicated Number has been assigned you.",
    "message_type": "toast",
    "data": {},
    "error": {}
}

401 Unauthorized

json
{
  "code": 401,
  "message": "Token expired",
  "stack": "APIError: Token expired ...."
}