api-design.md

API Design Specifications

This document outlines the standards for designing and building RESTful APIs at FIBEX.

Principles

Naming Conventions

Versioning

All APIs must be versioned. Versioning should be included in the URL path.

Responses

Status codes: usage guide

Notes on conditionals and caching:

Standard envelope

All APIs should respond with the following envelope. success indicates the result; data contains the resource or collection; error describes failures; meta and links are optional and mainly used for paginated collections.

Success (single resource):

{
  "success": true,
  "data": {
    "userId": "123",
    "name": "John Doe"
  }
}

Success (collection with pagination):

{
  "success": true,
  "data": [
    { "userId": "121", "name": "Jane" },
    { "userId": "122", "name": "Juan" }
  ],
  "meta": {
    "page": 2,
    "pageSize": 20,
    "totalItems": 132,
    "totalPages": 7
  },
  "links": {
    "self": "/api/v1/users?page=2&pageSize=20",
    "first": "/api/v1/users?page=1&pageSize=20",
    "prev": "/api/v1/users?page=1&pageSize=20",
    "next": "/api/v1/users?page=3&pageSize=20",
    "last": "/api/v1/users?page=7&pageSize=20"
  }
}

Error:

{
  "success": false,
  "error": {
    "code": "INVALID_INPUT",
    "message": "The email address is not valid.",
    "details": [
      { "field": "email", "issue": "invalid_format" }
    ],
    "traceId": "b1b6f2c5-2c1c-4a34-9f6e-0b2a5c1a9cdd"
  }
}

Notes:

Recommended status mapping

Authentication

JWT: signing, encryption, and key management

Centralized authentication (external and internal)

Revocation and logout

Pagination

Security

Encryption and sensitive data handling