Skip to main content

🔄 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
API Key Replacement Required

Replace c_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your actual REST API integration key from the ChottuLink Dashboard.

Path Parameters​

Path Parameters
ParameterTypeRequiredDescriptionExample
linkIdstringYesThe unique identifier of the link to enable/disableaae848d6-f481-41db-8e5f-b511b5a75669

Request Parameters​

Enable/Disable Guidelines:
  • The is_enabled parameter is required
  • Set to true to enable the link
  • Set to false to disable the link
  • Disabled links will not redirect users and will show an error page
  • The link must belong to your organization
Status Parameters
ParameterTypeRequiredDescriptionValues
is_enabledbooleanYesIndicates whether the link should be enabled or disabledtrue: Enable link
false: Disable link

Example Request​

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
}'
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
FieldTypeDescriptionExample
statusstringResponse status indicating success"success"
messagestringHuman-readable success message"Link enabled/disabled successfully"

Error Responses​

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

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​

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);
}

Best Practices​

Implementation Tips:
  • 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​

  1. Status Checking: Check current status before toggling to avoid unnecessary API calls
  2. Bulk Operations: Implement batch operations for multiple links
  3. Error Recovery: Implement retry logic for network failures
  4. Audit Logging: Log all status changes with timestamps and user information
  5. Status Validation: Validate link status before performing operations

Error Handling Best Practices​

  1. Check HTTP Status Codes: Always verify response status
  2. Handle Validation Errors: Provide meaningful error messages for validation failures
  3. Handle Authorization Errors: Ensure API key is valid and has proper permissions
  4. Handle Not Found Errors: Verify link ID exists and belongs to your organization
  5. 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​

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;
}
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.