Purchase Virtual Number
This API is used to purchase a virtual number for your account.
Parameters for Purchasing Virtual Number
Headers Parameters
| Parameters | Description |
|---|---|
| Authorization | Please add provided Bearer token - linked to your Cellcast account. Check here |
| Content-Type | application/json |
Request Body Parameters
| Name | Example | Description |
|---|---|---|
card | card_1SQmzoGOdUwLPbU6ll0QwsyH | Required. The card ID for payment. |
product | prod_PFdN753rT3lNFW | Required. The product ID for the virtual number. |
number | 66ea98514f0c1a121c76ec17 | Required. The ID of the virtual number to purchase. |
recurring_time | month | Required. The billing cycle (e.g., month, year). |
resubscribe | false | Optional. Whether to resubscribe automatically. |
Important Note on Product ID
The product parameter must match the recurring_time value:
- For
recurring_time: "month", use themonthlyProductIdfrom the Get Available Virtual Numbers API response - For
recurring_time: "year", use theyearlyProductIdfrom the Get Available Virtual Numbers API response
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 ...."
}