Skip to content

Update API Token

This API allows you to update an existing API token for a sub-client account. You can update the token name or status.

Headers

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

Path Parameters

NameTypeExampleDescription
idString6877b1234567890abcdef123Required. The ID of the token.

Request Body Parameters

NameTypeExampleDescription
nameStringUpdated NameOptional. New name for the API token.
statusStringinactiveOptional. New status: active or inactive.

Code Sample

PUT https://api.cellcast.com/api/v1/apiClient/token/:id

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

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/6877b1234567890abcdef123',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer {{API_KEY}}',
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'name' => 'Updated API Name',
        'status' => 'inactive'
    ])
]);

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

echo $response;
?>
python
import requests

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

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

payload = {
    "name": "Updated API Name",
    "status": "inactive"
}

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

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": 0,
  "is_enc": false,
  "status": true,
  "message": "API token updated successfully",
  "message_type": "toast",
  "data": {
    "_id": "6877b1234567890abcdef123",
    "name": "Updated API Name",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "status": "inactive",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "subAccount": {
      "_id": "6877a383d68781beb3b14110",
      "name": "Sub Client Name",
      "email": "[email protected]",
      "companyName": "Sub Client Company"
    }
  },
  "error": {}
}

400 Bad Request - No Valid Fields

json
{
  "status": false,
  "message": "Validation error",
  "message_type": "toast",
  "data": {},
  "error": {
    "message": "No valid fields to update"
  }
}

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"
  }
}

404 Not Found

json
{
  "status": false,
  "message": "Not found",
  "message_type": "toast",
  "data": {},
  "error": {
    "message": "API token not found"
  }
}

401 Unauthorized

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

Token Status

StatusDescription
activeToken is active and can be used for API authentication.
inactiveToken is disabled and cannot be used for API authentication.

Disabling Tokens

Setting a token's status to inactive is useful when you want to temporarily disable API access without permanently deleting the token. You can reactivate it later by setting the status back to active.

See Also