POST
/
auth
/
proxy
/
toggle
/
{proxy_key}
curl -X POST https://api.electronhub.ai/v1/auth/proxy/toggle/ek-proxy-1234567890abcdef \
  -H "Authorization: Bearer $ELECTRONHUB_API_KEY"
{
  "message": "Proxy key status updated",
  "status": true
}
curl -X POST https://api.electronhub.ai/v1/auth/proxy/toggle/ek-proxy-1234567890abcdef \
  -H "Authorization: Bearer $ELECTRONHUB_API_KEY"
{
  "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

proxy_key
string
required
The proxy key ID to toggle (starts with ek-proxy-)

Response Fields

message
string
Confirmation message that the status was updated
status
boolean
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

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

401
error
Unauthorized - Invalid or missing API key
403
error
Forbidden - You don’t have permission to modify this proxy key
404
error
Not Found - Proxy key doesn’t exist
429
error
Rate Limited - Too many requests, please slow down

Authorizations

Authorization
string
header
required

Enter your API key (starts with 'ek-')

Path Parameters

proxy_key
string
required

Proxy key ID

Response

200 - application/json

Proxy key status updated

The response is of type object.