curl -X POST https://api.electronhub.ai/v1/auth/proxy/toggle/ek-proxy-1234567890abcdef \
-H "Authorization: Bearer $ELECTRONHUB_API_KEY "
Enable Response
Disable Response
{
"message" : "Proxy key status updated" ,
"status" : true
}
Overview
Toggle the active status of a proxy key between enabled and disabled states. This provides a non-destructive way to temporarily revoke access without losing the key’s configuration.
Path Parameters
The proxy key ID to toggle (starts with ek-proxy-)
Response Fields
Confirmation message that the status was updated
The new status of the proxy key (true = active, false = inactive)
Behavior
The toggle endpoint switches the proxy key between two states:
Active (true) : The proxy key can be used for API requests
Inactive (false) : The proxy key is rejected with authentication errors
Use Cases
Temporary Suspension Quickly disable access during maintenance or investigations
Conditional Access Enable/disable keys based on business logic or schedules
Security Response Immediately block suspicious activity without permanent deletion
Testing Safely test key revocation and restoration workflows
Advantages Over Deletion
All key settings (name, expiration, credits, restrictions) are preserved
Can be quickly re-enabled without reconfiguring settings
Key history and usage statistics remain intact
Allocated credits stay with the key and aren’t returned to main balance
Example Workflow
Python - Automated Key Management
import httpx
import time
def toggle_proxy_key ( api_key : str , proxy_key_id : str ) -> bool :
"""Toggle proxy key status and return new status"""
client = httpx.Client()
response = client.post(
f "https://api.electronhub.ai/v1/auth/proxy/toggle/ { proxy_key_id } " ,
headers = { "Authorization" : f "Bearer { api_key } " }
)
result = response.json()
return result[ "status" ]
# Disable key during maintenance window
proxy_key_id = "ek-proxy-1234567890abcdef"
new_status = toggle_proxy_key(api_key, proxy_key_id)
print ( f "Key disabled: {not new_status } " )
# Perform maintenance...
time.sleep( 60 )
# Re-enable key after maintenance
new_status = toggle_proxy_key(api_key, proxy_key_id)
print ( f "Key re-enabled: { new_status } " )
Error Codes
Unauthorized - Invalid or missing API key
Forbidden - You don’t have permission to modify this proxy key
Not Found - Proxy key doesn’t exist
Rate Limited - Too many requests, please slow down
Enter your API key (starts with 'ek-')
Example: "Proxy key status updated"
New status of the proxy key