🔄 Enable/Disable Dynamic Link via REST API
Use ChottuLink's REST API to enable or disable existing dynamic links in your account. This endpoint allows you to quickly activate or deactivate links without deleting them, making it perfect for campaign management, temporary link suspension, or maintenance operations.
Endpoint​
PATCH https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/{linkId}
Authentication​
Include your API key in the request header:
API-KEY: c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Replace c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your actual REST API integration key from
the ChottuLink Dashboard.
Path Parameters​
Path Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| linkId | string | Yes | The unique identifier of the link to enable/disable | aae848d6-f481-41db-8e5f-b511b5a75669 |
Request Parameters​
- The
is_enabledparameter is required - Set to
trueto enable the link - Set to
falseto disable the link - Disabled links will not redirect users and will show an error page
- The link must belong to your organization
Status Parameters
| Parameter | Type | Required | Description | Values |
|---|---|---|---|---|
| is_enabled | boolean | Yes | Indicates whether the link should be enabled or disabled | true: Enable linkfalse: Disable link |
Example Request​
Enable Link​
curl --location --request PATCH 'https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/aae848d6-f481-41db-8e5f-b511b5a75669' \
--header 'API-KEY: c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"is_enabled": true
}'
Disable Link​
curl --location --request PATCH 'https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/aae848d6-f481-41db-8e5f-b511b5a75669' \
--header 'API-KEY: c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"is_enabled": false
}'
Response​
Success Response​
Status Code: 200 OK
{
"message": "Link enabled/disabled successfully",
"status": "success"
}
Response Fields​
Success Response Fields
| Field | Type | Description | Example |
|---|---|---|---|
| status | string | Response status indicating success | "success" |
| message | string | Human-readable success message | "Link enabled/disabled successfully" |
Error Responses​
Invalid Link ID​
Status Code: 400 Bad Request
{
"code": 101,
"errorMessage": "There was one or more validation error(s)",
"error": {
"errorMessage": "Invalid linkId! LinkId is not valid for the organization!",
"fieldName": "INVALID_VALUE"
}
}
Unauthorized Access​
Status Code: 401 Unauthorized
{
"code": 130,
"errorMessage": "Authorization Failed!",
"error": {
"errorMessage": "Invalid Api Key",
"fieldName": "UNAUTHORIZED_ACCESS"
}
}
Link Not Found​
Status Code: 404 Not Found
{
"code": 103,
"errorMessage": "The requested entity could not be found",
"error": {
"errorMessage": "Link not found or does not belong to your organization",
"fieldName": "LINK_NOT_FOUND"
}
}
Missing Required Field​
Status Code: 400 Bad Request
{
"code": 101,
"errorMessage": "There was one or more validation error(s)",
"error": {
"errorMessage": "is_enabled field is required",
"fieldName": "REQUIRED_FIELD_MISSING"
}
}
Usage Examples​
- JavaScript
- Python
- PHP
- Node.js
- cURL
const axios = require('axios');
async function toggleLinkStatus(linkId, isEnabled) {
try {
const response = await axios.patch(
`https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/${linkId}`,
{ is_enabled: isEnabled },
{
headers: {
'API-KEY': 'c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}
}
);
return response.data;
} catch (error) {
console.error('Error toggling link status:', error.response?.data || error.message);
throw error;
}
}
// Usage examples
// Enable a link
await toggleLinkStatus('aae848d6-f481-41db-8e5f-b511b5a75669', true);
// Disable a link
await toggleLinkStatus('aae848d6-f481-41db-8e5f-b511b5a75669', false);
// Toggle link status
async function toggleLink(linkId) {
// First get current status (you'd need to implement this)
const currentStatus = await getLinkStatus(linkId);
return await toggleLinkStatus(linkId, !currentStatus);
}
import requests
def toggle_link_status(link_id, is_enabled):
url = f"https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/{link_id}"
headers = {
'API-KEY': 'c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}
payload = {
'is_enabled': is_enabled
}
try:
response = requests.patch(url, headers=headers, json=payload)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error toggling link status: {e}")
raise
# Usage examples
# Enable a link
toggle_link_status('aae848d6-f481-41db-8e5f-b511b5a75669', True)
# Disable a link
toggle_link_status('aae848d6-f481-41db-8e5f-b511b5a75669', False)
# Toggle link status
def toggle_link(link_id):
# First get current status (you'd need to implement this)
current_status = get_link_status(link_id)
return toggle_link_status(link_id, not current_status)
<?php
function toggleLinkStatus($linkId, $isEnabled) {
$url = "https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/{$linkId}";
$headers = [
'API-KEY: c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type: application/json'
];
$payload = [
'is_enabled' => $isEnabled
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
return json_decode($response, true);
} else {
throw new Exception("Error toggling link status: HTTP {$httpCode}");
}
}
// Usage examples
// Enable a link
toggleLinkStatus('aae848d6-f481-41db-8e5f-b511b5a75669', true);
// Disable a link
toggleLinkStatus('aae848d6-f481-41db-8e5f-b511b5a75669', false);
// Toggle link status
function toggleLink($linkId) {
// First get current status (you'd need to implement this)
$currentStatus = getLinkStatus($linkId);
return toggleLinkStatus($linkId, !$currentStatus);
}
?>
const axios = require('axios');
async function toggleLinkStatus(linkId, isEnabled) {
try {
const response = await axios.patch(
`https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/${linkId}`,
{ is_enabled: isEnabled },
{
headers: {
'API-KEY': 'c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}
}
);
return response.data;
} catch (error) {
console.error('Error toggling link status:', error.response?.data || error.message);
throw error;
}
}
// Usage
toggleLinkStatus('aae848d6-f481-41db-8e5f-b511b5a75669', false).then(data => {
console.log('Link status updated:', data);
});
# Enable a link
curl --location --request PATCH 'https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/aae848d6-f481-41db-8e5f-b511b5a75669' \
--header 'API-KEY: c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"is_enabled": true
}'
# Disable a link
curl --location --request PATCH 'https://api2.chottulink.com/chotuCore/pa/v1/links/change-status/aae848d6-f481-41db-8e5f-b511b5a75669' \
--header 'API-KEY: c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"is_enabled": false
}'
Best Practices​
- Status Verification: Always verify the current link status before toggling
- Error Handling: Implement proper error handling for all response codes
- Link Ownership: Verify the link belongs to your organization before modifying
- Bulk Operations: Consider implementing bulk enable/disable for multiple links
- Logging: Log status changes for audit purposes
Enable/Disable Best Practices​
- Status Checking: Check current status before toggling to avoid unnecessary API calls
- Bulk Operations: Implement batch operations for multiple links
- Error Recovery: Implement retry logic for network failures
- Audit Logging: Log all status changes with timestamps and user information
- Status Validation: Validate link status before performing operations
Error Handling Best Practices​
- Check HTTP Status Codes: Always verify response status
- Handle Validation Errors: Provide meaningful error messages for validation failures
- Handle Authorization Errors: Ensure API key is valid and has proper permissions
- Handle Not Found Errors: Verify link ID exists and belongs to your organization
- Log Errors: Log API errors for debugging purposes
Use Cases​
Campaign Management​
Enable/disable links based on campaign status:
// Enable links for active campaign
await toggleLinkStatus('campaign-link-id', true);
// Disable links when campaign ends
await toggleLinkStatus('campaign-link-id', false);
Maintenance Operations​
Temporarily disable links during maintenance:
// Disable all links during maintenance
const maintenanceLinks = ['link1', 'link2', 'link3'];
for (const linkId of maintenanceLinks) {
await toggleLinkStatus(linkId, false);
}
// Re-enable after maintenance
for (const linkId of maintenanceLinks) {
await toggleLinkStatus(linkId, true);
}
A/B Testing​
Enable/disable links for different test groups:
// Enable version A links
await toggleLinkStatus('version-a-link', true);
await toggleLinkStatus('version-b-link', false);
// Switch to version B
await toggleLinkStatus('version-a-link', false);
await toggleLinkStatus('version-b-link', true);
Emergency Response​
Quickly disable problematic links:
// Emergency disable
await toggleLinkStatus('problematic-link-id', false);
Bulk Operations​
Enable Multiple Links​
async function enableMultipleLinks(linkIds) {
const results = [];
for (const linkId of linkIds) {
try {
const result = await toggleLinkStatus(linkId, true);
results.push({ linkId, success: true, result });
} catch (error) {
results.push({ linkId, success: false, error: error.message });
}
}
return results;
}
Disable Multiple Links​
async function disableMultipleLinks(linkIds) {
const results = [];
for (const linkId of linkIds) {
try {
const result = await toggleLinkStatus(linkId, false);
results.push({ linkId, success: true, result });
} catch (error) {
results.push({ linkId, success: false, error: error.message });
}
}
return results;
}
Rate Limits​
The API is subject to rate limiting. Please contact support for specific rate limit information.