openapi: 3.0.3 info: title: Agora Backend API description: | REST API for the Agora events platform. All successful responses are wrapped in a standard envelope: `{ "success": true, "data": ..., "message": "..." }`. version: 1.0.0 servers: - url: http://localhost:3001 description: Local development server tags: - name: Health description: Service health and readiness probes - name: Events description: Event discovery and event-scoped resources paths: /api/v1/webhooks/failures: get: tags: [Webhooks] summary: List webhook delivery failures parameters: - name: endpoint_id in: query required: false description: Filter by webhook endpoint ID. schema: type: string format: uuid - name: organizer_id in: query required: false description: Filter by organizer ID. schema: type: string format: uuid - name: limit in: query required: false description: Number of failures to return (default 50, maximum 200). schema: type: integer minimum: 1 maximum: 200 default: 50 - name: cursor in: query required: false description: Opaque cursor from pagination.next_cursor on the previous page. schema: type: string responses: '200': description: Paginated webhook delivery failures content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - type: object properties: data: $ref: '#/components/schemas/WebhookFailurePage' /api/v1/health: get: tags: [Health] summary: Liveness check description: Returns 200 when the API process is up. responses: '200': description: API process is up content: application/json: schema: $ref: '#/components/schemas/ApiResponse' /api/v1/health/blockchain: get: tags: [Health] summary: Blockchain connectivity check description: Verifies the Soroban RPC endpoint is reachable. responses: '200': description: Soroban RPC endpoint is reachable content: application/json: schema: $ref: '#/components/schemas/ApiResponse' /api/v1/health/db: get: tags: [Health] summary: Database connectivity check responses: '200': description: Database connection is working content: application/json: schema: $ref: '#/components/schemas/ApiResponse' /api/v1/health/redis: get: tags: [Health] summary: Redis connectivity check responses: '200': description: Redis connection is working content: application/json: schema: $ref: '#/components/schemas/ApiResponse' /api/v1/health/ready: get: tags: [Health] summary: Readiness check description: Returns 200 once the service is ready to serve requests. responses: '200': description: Service is ready content: application/json: schema: $ref: '#/components/schemas/ApiResponse' /api/v1/events: get: tags: [Events] summary: List upcoming events description: | Returns a cursor-paginated list of upcoming (not-ended, not-flagged) events. The response `data` object includes `items`, cursor `pagination`, and a compact `meta` object with `total`, `page_size`, and `has_more`. Pass `count=false` to skip the extra COUNT(*) query; `meta.total` is then omitted. `sort` is an allow-listed ORDER BY. Unrecognised values return 400 with `VALIDATION_FAILED`. Default is `starts_at_asc`. A secondary `id` tiebreaker keeps pagination stable. operationId: listEvents parameters: - name: limit in: query required: false description: Items per page (default 20, max 100). schema: type: integer default: 20 minimum: 1 maximum: 100 - name: cursor in: query required: false description: Opaque cursor from a previous page's `pagination.next_cursor`. schema: type: string - name: count in: query required: false description: When false, skip COUNT(*) and omit `meta.total`. schema: type: boolean default: true - name: sort in: query required: false description: | Ordering. Allow-listed values only; never interpolated into SQL. schema: type: string enum: - starts_at_asc - starts_at_desc - price_asc - price_desc - popularity_desc default: starts_at_asc responses: '200': description: Paginated list of upcoming events content: application/json: schema: $ref: '#/components/schemas/EventListResponse' '400': description: Invalid query parameter (for example an unrecognised `sort` value) content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /api/v1/events/map: get: tags: [Events] summary: Find events near a geographic coordinate description: | Returns upcoming events within a given radius (in kilometres) of a latitude/longitude coordinate, sorted by distance ascending. Events without coordinates are excluded. The distance is computed using the haversine formula and included as `distance_km` on each result. operationId: getEventsMap parameters: - name: latitude in: query required: true description: Center latitude in decimal degrees (-90 to 90). schema: type: number format: double - name: longitude in: query required: true description: Center longitude in decimal degrees (-180 to 180). schema: type: number format: double - name: radius in: query required: false description: Search radius in kilometres (default 50, max 500). schema: type: number format: double default: 50 - name: limit in: query required: false description: Maximum results (default 50, max 200). schema: type: integer default: 50 responses: '200': description: List of nearby events ordered by distance content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - type: object properties: data: type: array items: $ref: '#/components/schemas/MapEvent' '400': description: Invalid coordinates (out of range) or radius/limit out of bounds content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /api/v1/events/{id}: get: tags: [Events] summary: Get a single event by id parameters: - $ref: '#/components/parameters/EventId' responses: '200': description: The event content: application/json: schema: $ref: '#/components/schemas/ApiResponse' '404': $ref: '#/components/responses/NotFound' /api/v1/events/{id}/social-proof: get: tags: [Events] summary: Get social proof signals for an event description: | Returns social proof signals for an event: number of ticket purchases in the last 24 hours, average rating, waitlist count, and tickets remaining. No authentication is required and the endpoint takes no query parameters. The response is cached in Redis for 60 seconds. Flagged or non-existent events return 404. operationId: getEventSocialProof parameters: - $ref: '#/components/parameters/EventId' responses: '200': description: Social proof signals for the event content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - type: object properties: data: $ref: '#/components/schemas/EventSocialProof' example: success: true message: Social proof retrieved successfully data: recent_purchases: 12 average_rating: 4.5 waitlist_count: 8 tickets_remaining: 43 '404': $ref: '#/components/responses/NotFound' /api/v1/events/{id}/attendees/count: get: tags: [Events] summary: Get attendee count for an event parameters: - $ref: '#/components/parameters/EventId' responses: '200': description: Attendee count and total ticket supply content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - type: object properties: data: $ref: '#/components/schemas/AttendeeCount' '404': $ref: '#/components/responses/NotFound' /api/v1/events/{id}/share-link: get: tags: [Events] summary: Get a canonical share URL for an event description: | Returns a canonical share URL for an event along with the event's title and a truncated description (max 160 characters). parameters: - $ref: '#/components/parameters/EventId' responses: '200': description: Share link details content: application/json: schema: $ref: '#/components/schemas/ApiResponse' '404': $ref: '#/components/responses/NotFound' components: securitySchemes: bearerAuth: type: http scheme: bearer responses: Unauthorized: description: Authentication is required or the credential is invalid content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' parameters: EventId: name: id in: path required: true description: Event UUID schema: type: string format: uuid responses: NotFound: description: The requested resource was not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' schemas: CreateWebhookRequest: type: object properties: url: type: string format: uri secret: type: string events: type: array items: type: string required: [url, secret, events] ApiResponse: type: object description: Standard success envelope wrapping all API responses. properties: success: type: boolean example: true message: type: string data: nullable: true required: [success] ErrorResponse: type: object description: Flat error body returned by every failed request. properties: code: type: string description: Stable machine-readable error code (SCREAMING_SNAKE_CASE). enum: - VALIDATION_FAILED - UNAUTHORIZED - FORBIDDEN - NOT_FOUND - CONFLICT - RATE_LIMITED - INTERNAL_ERROR - SERVICE_UNAVAILABLE example: NOT_FOUND message: type: string description: Human-readable error message safe to show to end users. required: [code, message] WebhookFailurePage: type: object properties: items: type: array items: $ref: '#/components/schemas/WebhookDeliveryFailure' pagination: type: object properties: page_size: type: integer has_more: type: boolean next_cursor: type: string nullable: true required: [page_size, has_more] meta: type: object properties: page_size: type: integer has_more: type: boolean total: type: integer nullable: true required: [page_size, has_more] required: [items, pagination, meta] WebhookDeliveryFailure: type: object properties: id: type: string format: uuid endpoint_id: type: string format: uuid event: type: string payload: type: object additionalProperties: true attempts: type: integer last_status_code: type: integer nullable: true last_error: type: string nullable: true failed_at: type: string format: date-time retried_at: type: string format: date-time nullable: true retry_status: type: string nullable: true required: [id, endpoint_id, event, payload, attempts, failed_at] ListMeta: type: object description: Compact pagination metadata for list UIs ("Showing 12 of 340"). properties: total: type: integer format: int64 description: COUNT(*) of matching rows. Omitted when `count=false`. page_size: type: integer description: Requested page size. has_more: type: boolean description: Whether another page of results exists. required: [page_size, has_more] CursorPagination: type: object properties: page_size: type: integer has_more: type: boolean next_cursor: type: string nullable: true required: [page_size, has_more] EventListData: type: object properties: items: type: array items: $ref: '#/components/schemas/Event' pagination: $ref: '#/components/schemas/CursorPagination' meta: $ref: '#/components/schemas/ListMeta' required: [items, pagination, meta] EventListResponse: allOf: - $ref: '#/components/schemas/ApiResponse' - type: object properties: data: $ref: '#/components/schemas/EventListData' EventSocialProof: type: object description: Social proof signals for an event. properties: recent_purchases: type: integer format: int64 description: Ticket purchases in the last 24 hours. average_rating: type: number format: float description: Average event rating. waitlist_count: type: integer format: int64 description: Number of users on the event waitlist. tickets_remaining: type: integer format: int64 description: Number of tickets still available. required: - recent_purchases - average_rating - waitlist_count - tickets_remaining MapEvent: type: object description: An event with computed distance from the query coordinate. allOf: - $ref: '#/components/schemas/Event' - type: object properties: distance_km: type: number format: double description: Distance from the query point in kilometres. required: [distance_km] Event: type: object description: Core event fields returned by the API. properties: id: type: string format: uuid organizer_id: type: string format: uuid title: type: string description: type: string nullable: true location: type: string latitude: type: number format: double nullable: true longitude: type: number format: double nullable: true start_time: type: string format: date-time end_time: type: string format: date-time nullable: true is_flagged: type: boolean is_featured: type: boolean sum_of_ratings: type: integer format: int64 count_of_ratings: type: integer format: int32 created_at: type: string format: date-time updated_at: type: string format: date-time image_url: type: string format: uri nullable: true is_free: type: boolean average_rating: type: number format: float nullable: true AttendeeCount: type: object properties: count: type: integer format: int64 total_tickets: type: integer format: int64 required: [count, total_tickets]