Skip to content
Back to skills

Api Error Patterns

ASecurity

API error response format -- machine-readable codes, human-readable reasons, status code rules.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 6, 2026
ai-agentsgoapifrontend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 6, 2026

npx -y skills add Jartan-LLC/grimoire --skill api-error-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Error Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Error Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jartan-llc-api-error-patterns/badge)](https://www.skillsdirectory.com/skills/jartan-llc-api-error-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-error-patterns
description: API error response format -- machine-readable codes, human-readable reasons, status code rules.
when_to_use: Writing API error handling, choosing HTTP status codes, designing error response shapes.
user-invocable: false
---

# API Error Conventions

## Response Format

All API error responses use a consistent format:

```json
{
  "detail": {
    "code": "UPPER_SNAKE_CASE_CODE",
    "reason": "Human-readable message."
  }
}
```

- **`code`**: Machine-readable identifier. Frontend uses this for branching logic (redirect to verification, show specific field errors).
- **`reason`**: User-facing message. Frontend can display directly. Always a complete sentence ending with a period.

## Status Code Rules

| Status | When to Use |
|--------|-------------|
| 200 | Successful operation that returns data |
| 201 | Resource created |
| 204 | Success with no body (logout, delete, disable) |
| 400 | Client sent bad data (invalid input, bad credentials) |
| 403 | Authenticated but forbidden (wrong password, disabled feature, insufficient role) |
| 404 | Resource not found |
| 409 | Conflict (duplicate resource) |
| 429 | Too many requests (rate limit exceeded) |
| 500 | Unexpected server error (never intentional except for genuine internal failures) |

## Adding New Error Codes

1. Use the `{"code": "...", "reason": "..."}` format
2. Reuse an existing code if the error is semantically identical
3. Use `UPPER_SNAKE_CASE` for codes
4. Write reasons as complete sentences the frontend can show to users
5. Use appropriate HTTP status codes per the table above

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.