- Home
- Skills
- APIs & Backend
- api error handling architect
api error handling architect
Standardize API failure responses with consistent schemas, status codes, and security-first logging contracts.
$5
Works with the AI tools you already use
api error handling architect
Example session with this skill installed
Design an error handling contract for a new FinTech API. It needs to handle failed payments, invalid IBANs, expired sessions, and rate limits. Make sure it follows security best practices.
- Read your context and instructions
- Compiled the api error handling
I have designed a consistent API error-handling contract for the FinTech API. This design ensures that payment failures are actionable, PII is protected, and all errors are traceable via correlation IDs.
API Error Handling Contract
1. Response Schema
{
"error": {
"code": "PAYMENT_INSUFFICIENT_FUNDS",
"message": "The transaction could not be completed. Please check your balance.",
"target": "source_account_id",
"details": [],
"correlationId": "req-7b8c9d0a-1234",
"retryable": false,
"documentationUrl": "https://api.docs.fintech.com/errors/PAYMENT_INSUFFICIENT_FUNDS"
}
}
2. HTTP Status Map
| Failure Class | HTTP Status | Machine Code | Retryable |
|---|---|---|---|
| Payment Declined | 402 Payment Required | PAYMENT_DECLINED | No |
| Invalid IBAN | 422 Unprocessable Entity | VALIDATION_IBAN_INVALID | No |
| Expired Session | 401 Unauthorized | AUTH_SESSION_EXPIRED | No (Re-auth) |
| Rate Limited | 429 Too Many Requests | RATE_LIMIT_EXCEEDED | Yes |
| Internal Error | 500 Internal Server Error | INTERNAL_SERVER_ERROR | Yes |
3. Headers & Logging
Headers: All error responses must include X-Correlation-ID and Content-Type: application/problem+json. 429 errors must include Retry-After.
- Logging: Log at
ERRORlevel for 5xx andWARNfor 4xx. Redactcard_number,cvv, andibanfrom all logs.
4. Test Matrix
| Class | Trigger | Assertion |
|---|---|---|
| Auth | Invalid Token | Status 401, Message is generic "Unauthorized" |
| Validation | Alpha chars in IBAN | Status 422, target is "iban", code is VALIDATION_IBAN_INVALID |
| Security | 500 Error | Assert body does not contain "Exception" or stack trace strings |
Next steps
- Review the machine-readable codes for alignment with your SDK naming conventions.
- Implement the
X-Correlation-IDmiddleware in your gateway. - Apply the PII denylist to your centralized logging configuration.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
The problem
Inconsistent API errors break client integrations and leak sensitive system details. Developers often waste hours debugging production failures because error responses lack correlation IDs, retry guidance, or stable machine-readable codes.
What it does
- Generates a unified JSON error envelope with machine-readable codes and safe messaging.
- Maps failure modes to correct HTTP status codes including 401/403 distinctions and 422 for validation.
- Defines a correlation ID contract for end-to-end request tracing across headers and logs.
- Produces a retry semantics policy with
Retry-Afterheader logic for 429 and 503 errors. - Drafts a test matrix and logging contract with PII redaction rules and severity mapping.
Why this beats prompting it yourself
Generic prompts often miss security nuances, like leaking account existence through auth messages or exposing stack traces in 5xx responses. This skill enforces a strict six-axis validation (Security, Consistency, Debuggability, etc.) that ensures your error handling is production-ready, not just a simple JSON template.
Use cases
- Bootstrapping a new microservice architecture with a shared error contract.
- Standardizing error shapes across multiple legacy services during a migration.
- Designing public-facing API documentation that requires high debuggability for third-party developers.
- Auditing an existing API to remove internal leaks and improve observability.
Known limitations
This skill produces a design contract and architectural documentation. it does not generate runtime middleware code or framework-specific handler implementations.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 9 days ago
- Passed all security checks, Safe to install