Ana içeriğe atla

Endpoint

PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/websocket/

Authentication

Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Request Body

Full JSON Body Example

{
  "connectionLostTimeout": 60,
  "reuseAddr": true,
  "connectTimeout": 30,
  "maxRetries": 3,
  "retryDelay": 1000,
  "autoReconnect": true,
  "autoReconnectMaxRetries": 5,
  "autoReconnectRetryDelay": 2000
}

Request Body Fields

FieldTypeRequiredDefaultDescription
connectionLostTimeoutintegerNoSystem defaultTimeout in seconds before a connection is considered lost
reuseAddrbooleanNoSystem defaultEnable socket address reuse (SO_REUSEADDR)
connectTimeoutintegerNoSystem defaultWebSocket connection timeout in seconds
maxRetriesintegerNoSystem defaultMaximum number of initial connection retry attempts
retryDelayintegerNoSystem defaultDelay between initial connection retries in milliseconds
autoReconnectbooleanNoSystem defaultEnable automatic reconnection after connection loss
autoReconnectMaxRetriesintegerNoSystem defaultMaximum number of auto-reconnect attempts
autoReconnectRetryDelayintegerNoSystem defaultDelay between auto-reconnect attempts in milliseconds
Note: All fields are optional. Only provided fields are updated. Default values are inherited from system settings.

Response

Success Response (200 OK)

{
  "success": true
}

Error Response (400 Bad Request)

{
  "error": "bad_request",
  "error_description": "API Proxy type is not WEBSOCKET"
}

Error Response (401 Unauthorized)

{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}

Error Response (404 Not Found)

{
  "error": "not_found",
  "error_description": "ApiProxy (name: MyWebSocketAPI) was not found!"
}

cURL Example

Example 1: Configure Connection and Auto-Reconnect

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyWebSocketAPI/settings/websocket/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionLostTimeout": 120,
    "connectTimeout": 30,
    "autoReconnect": true,
    "autoReconnectMaxRetries": 10,
    "autoReconnectRetryDelay": 3000
  }'

Example 2: Configure Retry Settings

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyWebSocketAPI/settings/websocket/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "maxRetries": 5,
    "retryDelay": 2000,
    "reuseAddr": true
  }'

Example 3: Disable Auto-Reconnect

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyWebSocketAPI/settings/websocket/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "autoReconnect": false
  }'

Notes and Warnings

  • WebSocket Only: This endpoint is only applicable to API Proxies with WebSocket type. Using it on HTTP/REST proxies will result in an error.
  • Connection Lost Timeout: If no data is received within this timeout, the connection is considered lost. Set higher for long-lived idle connections.
  • Initial Retries vs Auto-Reconnect: maxRetries and retryDelay control the initial connection attempt. autoReconnect* settings control reconnection after an established connection is lost.
  • Retry Delay: Both retryDelay and autoReconnectRetryDelay are in milliseconds.
  • Socket Reuse: reuseAddr=true allows reusing the socket address, which is useful in high-connection environments.
  • System Defaults: When a field is not set, the value is inherited from system-level settings.

Permissions

User must have API_MANAGEMENT + MANAGE permission in the project.