PlexySDK DOCS

HTTP Status Codes

HTTP response codes returned by the Plexy API

HTTP Status Codes

The Plexy API uses standard HTTP status codes to indicate request outcomes.

Success codes

CodeDescription
200 OKRequest succeeded
201 CreatedResource created successfully
204 No ContentRequest succeeded, no response body

Client error codes

CodeDescriptionAction
400 Bad RequestInvalid request parametersCheck request body
401 UnauthorizedInvalid or missing API keyVerify API credentials
403 ForbiddenInsufficient permissionsCheck API key permissions
404 Not FoundResource doesn't existVerify resource ID
405 Method Not AllowedInvalid HTTP methodCheck endpoint documentation
409 ConflictIdempotency conflictRequest already processed
422 Unprocessable EntityValid request but cannot processCheck business logic

Server error codes

CodeDescriptionAction
500 Internal Server ErrorUnexpected server errorRetry with backoff
502 Bad GatewayUpstream service errorRetry with backoff
503 Service UnavailableService temporarily downRetry with backoff
504 Gateway TimeoutRequest timed outRetry with backoff

Handling responses

try {
  const payment = await plexy.payments.create({ /* ... */ });
  // Success - process payment
} catch (error) {
  switch (error.statusCode) {
    case 400:
      // Bad request - check parameters
      console.log('Invalid parameters:', error.message);
      break;
    case 401:
      // Authentication error
      console.log('Invalid API key');
      break;
    case 500:
    case 502:
    case 503:
      // Server error - retry with backoff
      await retryWithBackoff(createPayment);
      break;
  }
}

Retry strategy

Implement exponential backoff for server errors:

async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (error.statusCode < 500 || i === maxRetries - 1) {
        throw error;
      }
      const delay = Math.pow(2, i) * 1000; // 1s, 2s, 4s
      await sleep(delay);
    }
  }
}

See also

Осы бетте