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
| Code | Description |
|---|---|
200 OK | Request succeeded |
201 Created | Resource created successfully |
204 No Content | Request succeeded, no response body |
Client error codes
| Code | Description | Action |
|---|---|---|
400 Bad Request | Invalid request parameters | Check request body |
401 Unauthorized | Invalid or missing API key | Verify API credentials |
403 Forbidden | Insufficient permissions | Check API key permissions |
404 Not Found | Resource doesn't exist | Verify resource ID |
405 Method Not Allowed | Invalid HTTP method | Check endpoint documentation |
409 Conflict | Idempotency conflict | Request already processed |
422 Unprocessable Entity | Valid request but cannot process | Check business logic |
Server error codes
| Code | Description | Action |
|---|---|---|
500 Internal Server Error | Unexpected server error | Retry with backoff |
502 Bad Gateway | Upstream service error | Retry with backoff |
503 Service Unavailable | Service temporarily down | Retry with backoff |
504 Gateway Timeout | Request timed out | Retry 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);
}
}
}