Data Schemas
This document describes all data models and schemas used by the ESFA Backend API. These schemas define the structure of request and response payloads.
Overview
The ESFA Backend API uses JSON for all data exchange. All schemas are defined according to OpenAPI 3.0 specification and follow consistent patterns for data validation and serialization.
Common Patterns
ID Fields: All identifiers are strings (typically UUIDs for matches, simple strings for players)
Timestamps: ISO 8601 format in UTC (e.g.,
2025-09-05T13:31:23.174Z)URLs: Full HTTP/HTTPS URLs for external resources
Error Handling: Consistent error envelope structure across all endpoints
Core Schemas
Player
Represents a player participating in a game match.
Fields
Field | Type | Required | Description |
|---|---|---|---|
| string | ✓ | Unique identifier for the player |
| string | ✓ | Display name of the player |
| string | ✓ | Current status of the player in the match |
| string | URL to the player's avatar image |
Player Status Values
Value | Description |
|---|---|
| Player is actively participating in the match |
| Player has joined but is not yet active |
| Player is temporarily inactive |
| Player has lost connection |
Validation Rules
id: Must be non-empty string, typically alphanumericname: Must be non-empty string, max length varies by implementationstatus: Must be one of the defined status valuesimgAvatarUrl: Must be valid URL if provided
GameMatch
Represents a complete game match with its players.
Fields
Field | Type | Required | Description |
|---|---|---|---|
| string | ✓ | Unique identifier for the match |
| string | ✓ | Code identifying the game type |
| array | ✓ | Array of Player objects |
Game Code Values
Code | Game Type |
|---|---|
| Tic-Tac-Toe |
(others) | Additional games as configured |
Validation Rules
matchId: Must be valid UUID formatgameCode: Must be supported game codeplayers: Must be non-empty array of valid Player objects
Request Schemas
GameMatchFinishRequest
Used to submit final results when completing a match.
Fields
Field | Type | Required | Description |
|---|---|---|---|
| array | ✓ | Array of player result objects |
Player Result Object
Field | Type | Required | Description |
|---|---|---|---|
| string | ✓ | Unique identifier for the player |
| integer | ✓ | Final ranking/position (1st, 2nd, etc.) |
| number | ✓ | Final score achieved by the player |
Validation Rules
results: Must be non-empty arrayplayerId: Must correspond to a player in the matchplace: Must be positive integer starting from 1place: All values must be unique (no ties)place: Must be consecutive sequence (1, 2, 3, ..., n)score: Must be numeric (integer or decimal)
Example Validation
Valid Results Example:
Invalid Examples:
Missing place sequence:
Duplicate places:
MachineTokenRequest
Used to request authentication tokens from the Authentication Service.
Fields
Field | Type | Required | Description |
|---|---|---|---|
| string | ✓ | API key provided by administrator |
| string | ✓ | Secret key provided by administrator |
Validation Rules
apiKey: Must be non-empty stringsecretKey: Must be non-empty stringBoth fields are case-sensitive
Response Schemas
OAuthMachineTokenResponse
Response from the Authentication Service containing a Bearer token.
Fields
Field | Type | Required | Description |
|---|---|---|---|
| object | ✓ | Token data container |
| string | ✓ | JWT Bearer token |
| string | ✓ | Token expiration timestamp (ISO 8601 UTC) |
Usage
ErrorEnvelope
Standardized error response format used across all endpoints.
Fields
Field | Type | Required | Description |
|---|---|---|---|
| array | ✓ | Array of error objects |
Error Object
Field | Type | Required | Description |
|---|---|---|---|
| string | ✓ | Internationalization key for error |
| string | ✓ | Human-readable error message |
| string | ✓ | Error type classification |
Error Types
Type | HTTP Status | Description |
|---|---|---|
| 400 | Invalid request data |
| 401 | Authentication required |
| 403 | Access denied |
| 404 | Resource not found |
| 409 | Resource state conflict |
| 410 | Resource expired/deleted |
| 500 | Internal server error |
Common Error Codes
i18N Key | Description | Typical Cause |
|---|---|---|
| Invalid/missing token | Authentication failure |
| Match doesn't exist | Invalid matchId |
| Match has expired | Match TTL exceeded |
| Match completed | Duplicate finish attempt |
| Invalid match results | Data validation failure |
| Malformed request | JSON/schema validation |
| Wrong API keys | Authentication Service error |
| Internal error | System/network issues |
Schema Extensions
Custom Validation
Some schemas may include additional validation rules beyond the basic type requirements:
Match Results Validation
Player Status Transitions
Field Constraints
String Fields
Maximum lengths: Vary by field and implementation
Character sets: UTF-8 encoding supported
Empty values: Generally not allowed for required fields
Numeric Fields
Precision: Scores support decimal values
Range: Places must be positive integers
Special values: NaN and Infinity not allowed
URL Fields
Protocols: HTTP and HTTPS supported
Validation: Must be valid URL format
Accessibility: Should be publicly accessible
Integration Examples
TypeScript Interfaces
JSON Schema Validation
Python Data Classes
Related Documentation
Get Match: Using GameMatch schema
Finish Match: Using GameMatchFinishRequest schema
Authentication: Using token-related schemas
Error Handling: Using ErrorEnvelope schema