openapi: 3.0.0 info: title: Afrisinc Assets API description: File and asset management service with folder organization, tagging, and support for images, videos, documents, and fonts. version: 1.0.0 contact: name: Afrisinc Support license: name: MIT servers: - url: http://localhost:8080 description: Local development - url: https://assets.afrisinc.com description: Production security: - ApiKeyAuth: [] tags: - name: Health description: Service health checks (no authentication required) - name: Assets description: File upload, retrieval, and management - name: Folders description: Folder organization and management paths: /health/live: get: tags: - Health summary: Liveness probe description: Check if the service is running. Used by Kubernetes/load balancers. security: [] responses: '200': description: Service is alive content: application/json: schema: type: object properties: status: type: string example: up /health/ready: get: tags: - Health summary: Readiness probe description: Check if the service is ready to accept requests. Verifies database connection. security: [] responses: '200': description: Service is ready content: application/json: schema: type: object properties: status: type: string example: healthy db: type: object properties: status: type: string example: up latencyMs: type: integer example: 4 '503': description: Service not ready (database unavailable) content: application/json: schema: type: object properties: status: type: string example: degraded db: type: object properties: status: type: string example: down error: type: string example: "context deadline exceeded" /api/v1/assets: get: tags: - Assets summary: List assets description: Retrieve a paginated list of assets with optional filtering and sorting. parameters: - name: folder_id in: query schema: type: string format: uuid description: Filter by folder ID - name: type in: query schema: type: string enum: [image, video, document, font] description: Filter by asset type - name: search in: query schema: type: string description: Search by filename or tags - name: tags in: query schema: type: string example: "tag1,tag2" description: Comma-separated tags to filter by - name: page in: query schema: type: integer default: 1 minimum: 1 description: Page number for pagination - name: page_size in: query schema: type: integer default: 50 minimum: 1 maximum: 100 description: Items per page - name: sort_by in: query schema: type: string enum: [name, created_at, size] description: Field to sort by - name: sort_dir in: query schema: type: string enum: [asc, desc] description: Sort direction responses: '200': description: List of assets content: application/json: schema: type: object properties: assets: type: array items: $ref: '#/components/schemas/Asset' total: type: integer page: type: integer page_size: type: integer '401': description: Unauthorized (missing or invalid API key) '500': description: Internal server error post: tags: - Assets summary: Upload asset description: Upload a file with optional folder assignment and tags. Supports multipart/form-data. requestBody: required: true content: multipart/form-data: schema: type: object required: - file properties: file: type: string format: binary description: The file to upload (required) folder_id: type: string format: uuid description: Optional folder ID to organize the file tags: type: string example: "important,client-abc,2024" description: Comma-separated tags for categorization examples: basic: summary: Simple file upload value: file: (binary) with_folder: summary: Upload to folder with tags value: file: (binary) folder_id: 123e4567-e89b-12d3-a456-426614174000 tags: "project,urgent" responses: '201': description: Asset uploaded successfully content: application/json: schema: $ref: '#/components/schemas/Asset' '400': description: Bad request (invalid file type or validation error) content: application/json: schema: type: object properties: error: type: string example: "file type \"text/plain\" is not allowed" '413': description: Payload too large '401': description: Unauthorized '500': description: Internal server error delete: tags: - Assets summary: Bulk delete assets description: Delete multiple assets in a single request (max 100 at once). requestBody: required: true content: application/json: schema: type: object required: - ids properties: ids: type: array minItems: 1 maxItems: 100 items: type: string format: uuid example: ["id1", "id2", "id3"] responses: '204': description: All assets deleted successfully '207': description: Partial deletion (some assets failed) content: application/json: schema: type: object properties: deleted: type: integer example: 2 failed: type: array items: type: string example: ["id3"] '400': description: Bad request (invalid IDs or validation error) '401': description: Unauthorized '500': description: Internal server error /api/v1/assets/{id}: get: tags: - Assets summary: Get asset details description: Retrieve metadata for a specific asset by ID. parameters: - name: id in: path required: true schema: type: string format: uuid description: Asset ID responses: '200': description: Asset details content: application/json: schema: $ref: '#/components/schemas/Asset' '401': description: Unauthorized '404': description: Asset not found '500': description: Internal server error delete: tags: - Assets summary: Delete asset description: Delete a single asset by ID. parameters: - name: id in: path required: true schema: type: string format: uuid description: Asset ID responses: '204': description: Asset deleted successfully '401': description: Unauthorized '404': description: Asset not found '500': description: Internal server error /api/v1/assets/{id}/download: get: tags: - Assets summary: Download asset description: Download the raw file. Returns the file with appropriate Content-Type and Content-Disposition headers. parameters: - name: id in: path required: true schema: type: string format: uuid description: Asset ID responses: '200': description: File downloaded successfully content: application/octet-stream: schema: type: string format: binary headers: Content-Disposition: schema: type: string example: 'attachment; filename="image.jpg"' Content-Type: schema: type: string example: "image/jpeg" Content-Length: schema: type: integer Cache-Control: schema: type: string example: "private, max-age=3600" '401': description: Unauthorized '404': description: Asset not found '500': description: Internal server error /api/v1/assets/stats: get: tags: - Assets summary: Get asset statistics description: Retrieve aggregate statistics about all assets. responses: '200': description: Asset statistics content: application/json: schema: type: object properties: total_count: type: integer example: 150 total_size_bytes: type: integer example: 524288000 by_type: type: object example: "image/jpeg": 50 "image/png": 30 "video/mp4": 20 "application/pdf": 50 '401': description: Unauthorized '500': description: Internal server error /api/v1/folders: get: tags: - Folders summary: List folders description: Retrieve all folders. responses: '200': description: List of folders content: application/json: schema: type: object properties: folders: type: array items: $ref: '#/components/schemas/Folder' '401': description: Unauthorized '500': description: Internal server error post: tags: - Folders summary: Create folder description: Create a new folder for organizing assets. requestBody: required: true content: application/json: schema: type: object required: - name properties: name: type: string maxLength: 100 example: "Client Projects" description: Folder name (required) description: type: string maxLength: 500 example: "All assets for client ABC" description: Optional folder description responses: '201': description: Folder created successfully content: application/json: schema: $ref: '#/components/schemas/Folder' '400': description: Bad request (validation error) content: application/json: schema: type: object properties: errors: type: object example: name: "name is required" '401': description: Unauthorized '500': description: Internal server error /api/v1/folders/{id}: get: tags: - Folders summary: Get folder description: Retrieve details for a specific folder. parameters: - name: id in: path required: true schema: type: string format: uuid description: Folder ID responses: '200': description: Folder details content: application/json: schema: $ref: '#/components/schemas/Folder' '401': description: Unauthorized '404': description: Folder not found '500': description: Internal server error delete: tags: - Folders summary: Delete folder description: Delete a folder by ID. parameters: - name: id in: path required: true schema: type: string format: uuid description: Folder ID responses: '204': description: Folder deleted successfully '401': description: Unauthorized '404': description: Folder not found '500': description: Internal server error components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: X-API-Key description: API key for authentication schemas: Asset: type: object properties: id: type: string format: uuid example: "550e8400-e29b-41d4-a716-446655440000" name: type: string example: "550e8400-e29b-41d4-a716-446655440000.jpg" description: Generated unique filename original_name: type: string example: "profile.jpg" description: Original filename mime_type: type: string example: "image/jpeg" size_bytes: type: integer example: 245678 folder_id: type: string format: uuid nullable: true example: "123e4567-e89b-12d3-a456-426614174000" tags: type: array items: type: string example: ["profile", "important"] created_at: type: string format: date-time example: "2026-04-09T10:30:00Z" url: type: string format: uri example: "https://assets.afrisinc.com/550e8400-e29b-41d4-a716-446655440000.jpg" description: Public URL for accessing the asset Folder: type: object properties: id: type: string format: uuid example: "123e4567-e89b-12d3-a456-426614174000" name: type: string example: "Client Projects" description: type: string nullable: true example: "All assets for client ABC" created_at: type: string format: date-time example: "2026-04-09T10:30:00Z" Error: type: object properties: ok: type: boolean example: false error: type: string example: "resource not found"