POST
/
api
/
proxy
/
account
/
{accountId}
/
handle-failure
Handle Proxy Failure
curl --request POST \
  --url https://onlyautomator.com/api/proxy/account/{accountId}/handle-failure \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "error": "ECONNRESET",
  "autoReassign": true
}'
{
  "data": {
    "message": "Proxy failure handled. New proxy assigned.",
    "reassigned": true,
    "new_proxy_info": {
      "proxy_id": "ws_proxy_new67890",
      "proxy_address": "93.184.216.34",
      "proxy_port": 8080,
      "proxy_country_code": "GB"
    }
  },
  "error": "No suitable automatic proxy found..."
}

Handle Proxy Failure

This endpoint is used to report that the currently assigned proxy for an account is failing connectivity checks. It can optionally trigger an automatic re-assignment of a new proxy. This is typically called by the backend microservice or potentially the extension (if it detects persistent failures) when attempts to use the assigned proxy fail.

Authentication

This endpoint requires authentication via bearer token representing a valid user session managed by Supabase Auth (cookies). It’s intended for use by trusted backend services or the authenticated extension.Testing Note: Due to the requirement for a live user session, this endpoint cannot be successfully tested directly using the ‘Send’ button in this documentation with a static token.To test:
  1. Simulate a call from a service or extension with a valid user JWT.
  2. Use curl or a similar tool with a valid, current user JWT obtained from your browser’s session after logging in.
Retrieving JWT Token for Testing: To test endpoints requiring a user session with tools like curl, you need the JWT access token stored by Supabase Auth in your browser.
  1. Log in to your application normally in your browser.
  2. Open Developer Tools (usually F12).
  3. Go to the Application tab (it might be called Storage in Firefox).
  4. Under the Storage section, find Cookies and select your application’s domain (e.g., http://localhost:3000 or https://onlyautomator.com).
  5. Look for a cookie named similar to sb-access-token (the exact name might vary slightly based on Supabase configuration).
  6. Copy the entire value of this cookie. This is your Bearer token.
  7. Use this copied value in the Authorization: Bearer <your_copied_token> header for your curl or other API tool requests.
Note: This token has a limited lifetime and you’ll need to copy a fresh one after it expires.

Response Example

{
  "data": {
    "message": "Proxy failure handled. New proxy assigned.",
    "reassigned": true,
    "new_proxy_info": {
      "proxy_id": "ws_proxy_new67890",
      "proxy_address": "93.184.216.34",
      "proxy_port": 8080,
      "proxy_country_code": "GB"
    }
  }
}

Error Codes

This table provides context beyond the basic OpenAPI status codes.
Status CodeDescription
400Missing or invalid accountId.
401Authentication token is missing or invalid.
404The specified accountId does not exist.
500An internal server error occurred during failure logging or the re-assignment process (if attempted). The error message in the response might provide more details.

Code Examples

// Using fetch
const handleProxyFailure = async (accountId, apiToken, failureInfo = {}) => {
  // Default to autoReassign: true if not provided
  const body = { autoReassign: true, ...failureInfo };

  const response = await fetch(`https://onlyautomator.com/api/proxy/account/${accountId}/handle-failure`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${apiToken}`
    },
    body: JSON.stringify(body)
  });
  
  if (!response.ok) {
     const errorData = await response.json();
     // Even for 500 errors related to reassignment, the initial handling might succeed.
     // Check the response data structure if needed, but re-throwing based on status is safe.
     throw new Error(`API Error (${response.status}): ${errorData.error || 'Unknown error'}`);
  }
  return await response.json();
};

// Example usage: Report failure and request auto-reassign (default)
const failureReport = {
  error: "ECONNRESET"
};

handleProxyFailure('acc123', 'your_api_token', failureReport)
  .then(data => console.log('Failure handling result:', data))
  .catch(error => console.error('Error handling failure:', error));

// Example usage: Report failure but DO NOT reassign
const reportOnly = {
  error: "Proxy returned 503",
  autoReassign: false
};

handleProxyFailure('acc456', 'your_api_token', reportOnly)
  .then(data => console.log('Failure report result:', data))
  .catch(error => console.error('Error handling failure report:', error));

Notes

  • If autoReassign is true (the default), this endpoint triggers the proxy assignment logic to find a replacement.
  • The re-assignment process respects the proxy_region_preference if set.
  • If re-assignment fails (e.g., no available proxies), the response will indicate reassigned: false and may include an error message (often in a 500 response).

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Authorization
string
required

Bearer token for authentication (JWT)

Path Parameters

accountId
string<uuid>
required

The unique identifier of the OnlyFans account.

Body

application/json
error
string | null

Optional description of the error encountered.

Example:

"ECONNRESET"

autoReassign
boolean
default:true

If true, attempt to assign a new proxy automatically.

Example:

true

Response

Proxy failure handled (may or may not include reassignment).

data
object
error
string | null
Example:

"No suitable automatic proxy found..."