Skip to content

Create API Token for Sub-Client

This API allows you to create an API token for a sub-client account. The token can be used by the sub-client to authenticate API requests.

Headers

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

Request Body Parameters

NameTypeExampleDescription
nameStringProduction APIRequired. A descriptive name for the API token.
subAccountIdString6877a383d68781beb3b14110Required. The ID of the sub-client account.

Code Sample

POST https://api.cellcast.com/api/v1/apiClient/token

bash
curl --location 'https://api.cellcast.com/api/v1/apiClient/token' \
--header 'authorization: Bearer {{API_KEY}}' \
--header 'content-type: application/json' \
--data '{
    "name": "Production API",
    "subAccountId": "6877a383d68781beb3b14110"
}'
javascript
const response = await fetch(
  "https://api.cellcast.com/api/v1/apiClient/token",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer {{API_KEY}}",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      name: "Production API",
      subAccountId: "6877a383d68781beb3b14110"
    })
  }
);

const data = await response.json();
console.log(data);
php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => 'https://api.cellcast.com/api/v1/apiClient/token',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer {{API_KEY}}',
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'name' => 'Production API',
        'subAccountId' => '6877a383d68781beb3b14110'
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
?>
python
import requests

url = "https://api.cellcast.com/api/v1/apiClient/token"

headers = {
    "Authorization": "Bearer {{API_KEY}}",
    "Content-Type": "application/json"
}

payload = {
    "name": "Production API",
    "subAccountId": "6877a383d68781beb3b14110"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

Replace with the actual API key that you own.

Responses

201 Success

json
{
  "app_type": "web",
  "app_version": "1.0",
  "maintainence": 0,
  "new_version": 0,
  "force_update": 0,
  "invalid_token": 0,
  "refresh_token": "",
  "show_message": 0,
  "is_enc": false,
  "status": true,
  "message": "API token created successfully",
  "message_type": "toast",
  "data": {
    "_id": "6877b1234567890abcdef123",
    "name": "Production API",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "status": "active",
    "subAccountId": "6877a383d68781beb3b14110",
    "createdAt": "2024-01-15T10:30:00.000Z"
  },
  "error": {}
}

Important

The full token is only returned once upon creation. Make sure to save it securely. Subsequent API calls will only return a masked version of the token.

400 Bad Request - Missing Name

json
{
  "status": false,
  "message": "Validation error",
  "message_type": "toast",
  "data": {},
  "error": {
    "message": "API name is required"
  }
}

400 Bad Request - Missing Sub Account ID

json
{
  "status": false,
  "message": "Validation error",
  "message_type": "toast",
  "data": {},
  "error": {
    "message": "Sub account ID is required"
  }
}

400 Bad Request - Duplicate Token Name

json
{
  "status": false,
  "message": "Validation error",
  "message_type": "toast",
  "data": {},
  "error": {
    "message": "Token name already exists for this sub-account"
  }
}

403 Forbidden - Invalid Sub Account

json
{
  "status": false,
  "message": "Forbidden",
  "message_type": "toast",
  "data": {},
  "error": {
    "message": "Sub account does not belong to you or does not exist"
  }
}

401 Unauthorized

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

See Also