Skip to main content
POST
/
auth
/
proxy
/
toggle
curl -X POST https://api.electronhub.ai/v1/auth/proxy/toggle \
  -H "Authorization: Bearer $ELECTRONHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"proxy_key": "ek-proxy-1234567890abcdef"}'
{
  "message": "Proxy key status updated",
  "status": true
}
Toggle the active status of a proxy key you own between enabled and disabled. The proxy key is identified by the proxy_key field in the request body so the URL is static and can be exact-matched at the edge (Cloudflare, etc.), making it immune to path-traversal-append DDoS abuse. The legacy POST /v1/auth/proxy/toggle/{proxy_key} still works for backward compatibility but is discouraged for new integrations.
curl -X POST https://api.electronhub.ai/v1/auth/proxy/toggle \
  -H "Authorization: Bearer $ELECTRONHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"proxy_key": "ek-proxy-1234567890abcdef"}'
{
  "message": "Proxy key status updated",
  "status": true
}

Request Body

proxy_key
string
required
The proxy key to toggle (starts with ek-proxy-). Must be a string between 1 and 256 characters and must be a proxy key you own — cross-account toggles return 403 Forbidden.

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

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 are not returned to the main balance.

Example Workflow

Python - Automated Key Management
import httpx
import time

def toggle_proxy_key(api_key: str, proxy_key: str) -> bool:
    """Toggle proxy key status and return the new status."""
    response = httpx.post(
        "https://api.electronhub.ai/v1/auth/proxy/toggle",
        headers={
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json",
        },
        json={"proxy_key": proxy_key},
    )
    return response.json()["status"]

proxy_key = "ek-proxy-1234567890abcdef"

new_status = toggle_proxy_key(api_key, proxy_key)
print(f"Key disabled: {not new_status}")

time.sleep(60)

new_status = toggle_proxy_key(api_key, proxy_key)
print(f"Key re-enabled: {new_status}")

Error Codes

401
error
Unauthorized — missing, malformed, or invalid Authorization header. JWT tokens are not accepted on this endpoint.
403
error
Forbidden — the proxy key exists but is owned by a different account.
404
error
Not Found — no proxy key with that value exists.
422
error
Unprocessable Entity — the request body is missing proxy_key or violates the length constraint (1 <= len <= 256).
429
error
Rate Limited — too many requests, please slow down.

Notes

  • Requires an API key (ek-...) in the Authorization header. JWT tokens are intentionally rejected.
  • Proxy keys themselves (ek-proxy-...) cannot call this endpoint — only the parent account that owns the proxy key can toggle it.

Authorizations

Authorization
string
header
required

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

Body

application/json
proxy_key
string
required

The proxy key to look up / toggle / delete (must be one you own)

Required string length: 1 - 256
Example:

"ek-proxy-1234567890abcdef"

Response

Proxy key status updated

message
string
Example:

"Proxy key status updated"

status
boolean

New status of the proxy key