{
    "schemes": [],
    "swagger": "2.0",
    "info": {
        "description": "Activity audit trail service for Banknote Tracker",
        "title": "BNT Activity Service API",
        "contact": {},
        "version": "1.0"
    },
    "host": "localhost:9010",
    "basePath": "/",
    "paths": {
        "/activities": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "List activities with pagination and filters",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "activities"
                ],
                "summary": "List activities",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "Page number",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Sort field",
                        "name": "sort_by",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Sort order (asc or desc)",
                        "name": "sort_order",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by category",
                        "name": "category",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by action",
                        "name": "action",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by entity reference",
                        "name": "entity_reference",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by identity reference",
                        "name": "identity_reference",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by event source",
                        "name": "event_source",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter from date (RFC3339)",
                        "name": "from",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter to date (RFC3339)",
                        "name": "to",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/dto.PaginatedActivitiesDTO"
                        }
                    }
                }
            }
        },
        "/activities/entity/{reference}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Full chronological activity history for a single entity (case, prefix, invoice, user, …) by its reference. Works for BULK operations too — each record is fanned out with its own entity_reference — so a case's complete history (including batched moves) is retrievable here.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "activities"
                ],
                "summary": "Get an entity's activity timeline",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Entity reference",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Page number",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Sort order (asc or desc; default desc)",
                        "name": "sort_order",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter from date (RFC3339)",
                        "name": "from",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter to date (RFC3339)",
                        "name": "to",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/dto.PaginatedActivitiesDTO"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/activities/health": {
            "get": {
                "description": "Returns service health status",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "health"
                ],
                "summary": "Health check",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.HealthResponse"
                        }
                    }
                }
            }
        },
        "/activities/summary": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Get activity summary with counts by category, action, and source",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "activities"
                ],
                "summary": "Get activity summary",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Filter by category",
                        "name": "category",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by event source",
                        "name": "event_source",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter from date (RFC3339)",
                        "name": "from",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter to date (RFC3339)",
                        "name": "to",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/dto.ActivitySummaryDTO"
                        }
                    }
                }
            }
        },
        "/activities/{reference}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Retrieves a single activity by its reference",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "activities"
                ],
                "summary": "Get activity by reference",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Activity reference",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/dto.ActivityDTO"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "dto.ActionCount": {
            "type": "object",
            "properties": {
                "action": {
                    "type": "string"
                },
                "count": {
                    "type": "integer"
                }
            }
        },
        "dto.ActivityDTO": {
            "type": "object",
            "properties": {
                "action": {
                    "type": "string"
                },
                "category": {
                    "type": "string"
                },
                "created_at": {
                    "type": "string"
                },
                "department_name": {
                    "type": "string"
                },
                "department_reference": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                },
                "entity_reference": {
                    "type": "string"
                },
                "event_date": {
                    "type": "string"
                },
                "event_name": {
                    "type": "string"
                },
                "event_reference": {
                    "type": "string"
                },
                "event_source": {
                    "type": "string"
                },
                "event_type": {
                    "type": "string"
                },
                "expires_at": {
                    "type": "string"
                },
                "full_name": {
                    "type": "string"
                },
                "identity_reference": {
                    "type": "string"
                },
                "metadata": {
                    "type": "string"
                },
                "organisation_name": {
                    "type": "string"
                },
                "organisation_reference": {
                    "type": "string"
                },
                "photo_url": {
                    "type": "string"
                },
                "reference": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "dto.ActivitySummaryDTO": {
            "type": "object",
            "properties": {
                "by_action": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/dto.ActionCount"
                    }
                },
                "by_category": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/dto.CategoryCount"
                    }
                },
                "by_source": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/dto.SourceCount"
                    }
                },
                "total_activities": {
                    "type": "integer"
                }
            }
        },
        "dto.CategoryCount": {
            "type": "object",
            "properties": {
                "category": {
                    "type": "string"
                },
                "count": {
                    "type": "integer"
                }
            }
        },
        "dto.PaginatedActivitiesDTO": {
            "type": "object",
            "properties": {
                "has_next": {
                    "type": "boolean"
                },
                "has_previous": {
                    "type": "boolean"
                },
                "items": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/dto.ActivityDTO"
                    }
                },
                "page": {
                    "type": "integer"
                },
                "pages": {
                    "type": "integer"
                },
                "size": {
                    "type": "integer"
                },
                "total": {
                    "type": "integer"
                }
            }
        },
        "dto.SourceCount": {
            "type": "object",
            "properties": {
                "count": {
                    "type": "integer"
                },
                "source": {
                    "type": "string"
                }
            }
        },
        "schemas.HealthResponse": {
            "type": "object",
            "properties": {
                "message": {
                    "type": "string"
                }
            }
        },
        "shared.ApplicationError": {
            "type": "object",
            "properties": {
                "error_reference": {
                    "type": "string"
                },
                "error_type": {
                    "$ref": "#/definitions/shared.ErrorType"
                },
                "errors": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "status_code": {
                    "type": "integer"
                },
                "timestamp": {
                    "type": "string"
                }
            }
        },
        "shared.ErrorType": {
            "type": "string",
            "enum": [
                "VALIDATION_ERROR",
                "NOT_FOUND_ERROR",
                "CONFLICT_ERROR",
                "UNAUTHORIZED_ERROR",
                "AUTHENTICATION_ERROR",
                "FORBIDDEN_ERROR",
                "BAD_REQUEST_ERROR",
                "SERVER_ERROR",
                "REDIS_ERROR",
                "MONGO_DB_ERROR",
                "CREATE_ERROR",
                "UPDATE_ERROR",
                "INVALID_RESOURCE_ERROR",
                "TIMEOUT",
                "METHOD_NOT_ALLOWED",
                "RATE_LIMIT_EXCEEDED",
                "PAYLOAD_TOO_LARGE",
                "UNPROCESSABLE_ENTITY",
                "INTERNAL_ERROR"
            ],
            "x-enum-varnames": [
                "ValidationError",
                "NotFoundError",
                "ConflictError",
                "UnauthorizedError",
                "AuthenticationError",
                "ForbiddenError",
                "BadRequestError",
                "ServerError",
                "RedisError",
                "MongoDBError",
                "CreateError",
                "UpdateError",
                "InvalidResourceError",
                "TimeoutError",
                "MethodNotAllowedError",
                "RateLimitExceededError",
                "PayloadTooLargeError",
                "UnprocessableEntityError",
                "InternalError"
            ]
        }
    },
    "securityDefinitions": {
        "BearerAuth": {
            "type": "apiKey",
            "name": "Authorization",
            "in": "header"
        }
    }
}