Skip to main content

Standard Response Format

All Fuuffy API responses follow a consistent, predictable structure to ensure easy integration and error handling.


Response Envelope Pattern

Fuuffy API uses the envelope pattern. All responses are wrapped in a standard structure:

  • Success responses — Data wrapped in a data object.
  • Error responses — Errors wrapped in an error object.

This design provides Consistent parsing logic across all endpoints. Clear distinction between success and error. Extensible structure for future metadata. Aligns with common API best practices.


Success Response Format

data
json-string
Response payload. Structure depends on the endpoint (single object, array, or array with pagination).

Example - Single object

{
"data": {
"id": "shp_1234567890",
"status": "pending",
"tracking_number": "FUF123456789",
"created_at": "2024-01-15T10:30:00Z"
}
}

Example - Array or list

{
"data": [
{
"id": "shp_1234567890",
"status": "pending"
},
{
"id": "shp_0987654321",
"status": "delivered"
}
]
}

Example - With pagination

{
"data": [
// ... array of items
],
"pagination": {
"total": 140,
"page": 1,
"per_page": 20,
"total_pages": 8
}
}

Error Response Format

error.code
string
Error code (e.g. numeric or machine-readable).
error.code_reason
string
Developer-readable error identifier.
error.message
string
Human-readable error message.
error.error_trace
json-string | array
Optional. Field-level validation or extra context.

Example - Validation error

{
"error": {
"code": "400000",
"code_reason": "validation_error",
"message": "Invalid request parameters",
"error_trace": {"weight": "Missing required field 'weight'"}
}
}

Example - OAuth error

{
"error": {
"code": "401021",
"code_reason": "invalid_client_id_or_client_secret",
"message": "Invalid client_id, client_secret, or session_key"
}
}

HTTP Status Codes

Fuuffy API uses standard HTTP status codes.

Success codes (2xx)

StatusMeaningUsage
200 OKSuccessStandard successful response
201 CreatedCreatedResource successfully created
204 No ContentSuccess, no dataSuccessful deletion or update with no response body

Client error codes (4xx)

StatusMeaningCommon error codes
400 Bad RequestInvalid requestvalidation_error, invalid_request
401 UnauthorizedAuthentication failedunauthorized, invalid_token
403 ForbiddenPermission deniedforbidden, insufficient_permissions
404 Not FoundResource not foundnot_found, resource_not_found
422 Unprocessable EntityValidation failedvalidation_error, invalid_data
429 Too Many RequestsRate limit exceededrate_limit_exceeded

Server error codes (5xx)

StatusMeaningCommon error codes
500 Internal Server ErrorServer errorinternal_error, server_error
503 Service UnavailableService downservice_unavailable, maintenance

Common Error Codes

Error codeHTTP statusDescription
validation_error400, 422Request validation failed
invalid_request400Malformed request
general_exception400General exception
unauthorized401Authentication required or failed
invalid_token401Access token is invalid or expired
forbidden403Insufficient permissions
not_found404Resource does not exist
rate_limit_exceeded429Too many requests
internal_error500Server-side error

Best Practices for Integration

1. Always check HTTP status first

  • Use the response status code to decide whether to parse data or error.
  • Treat 2xx as success and parse data.
  • For non-2xx, parse error and handle accordingly.

2. Parse the response envelope

  • Check for presence of data or error in the JSON body.
  • Do not assume a 200 response always has data; use the envelope to drive your logic.

3. Handle errors gracefully

  • Map error.code or code_reason to user-facing messages or retry logic.
  • For unauthorized or invalid_token, refresh the token and retry.
  • For validation_error, surface error_trace when present.
  • For rate_limit_exceeded, implement backoff and retry.

Why This Format?

Industry standards

This response format follows patterns used by:

  • JSON:API specification
  • Google Cloud APIs
  • Stripe API
  • GitHub API

Benefits

  • Predictable — Same structure across all endpoints.
  • Type-safe — Easy to type in TypeScript and other languages.
  • Extensible — Metadata can be added without breaking changes.
  • Clear — Obvious distinction between success and error.
  • Standard — Familiar to developers from other APIs.

See Also