openapi: 3.0.3
info:
  title: UniBible API
  version: "1.0"
  description: |
    Public, unauthenticated JSON API powering UniBible — an anonymous Bible reflection
    wall at https://unibible.online. All endpoints are read-only for anonymous clients
    except the rate-limited write endpoints below. No accounts exist.
  contact:
    name: UniBible
    url: https://unibible.online
servers:
  - url: https://unibible.online/api
paths:
  /:
    get:
      summary: Health
      responses:
        "200":
          description: OK
  /config:
    get:
      summary: Get post types, reaction tokens, and character limits.
      responses:
        "200":
          description: OK
  /posts:
    get:
      summary: List posts (newest first, cursor paginated).
      parameters:
        - name: cursor
          in: query
          schema:
            type: string
            format: date-time
        - name: limit
          in: query
          schema:
            type: integer
            default: 15
            maximum: 50
      responses:
        "200":
          description: OK
    post:
      summary: Create an anonymous post.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [type, description, device_id]
              properties:
                type:
                  type: string
                  enum: [idea, thought, aha, question, verse]
                title:
                  type: string
                  maxLength: 100
                subtitle:
                  type: string
                  maxLength: 150
                description:
                  type: string
                  maxLength: 600
                verse_ref:
                  type: string
                  maxLength: 50
                device_id:
                  type: string
      responses:
        "201":
          description: Created
        "400":
          description: Validation or profanity rejection
        "429":
          description: Rate limited
  /posts/{post_id}/react:
    post:
      summary: Add a reaction token to a post (idempotent per device+token).
      parameters:
        - name: post_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [token, device_id]
              properties:
                token:
                  type: string
                  enum: [amen, love, faith, peace, blessed, hope, praise, grace]
                device_id:
                  type: string
  /posts/{post_id}/flag:
    post:
      summary: Flag a post for moderator review. Auto-hide at 5 distinct devices.
      parameters:
        - name: post_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [device_id]
              properties:
                device_id:
                  type: string
