openapi: 3.1.0
info:
  title: DeHeart API
  version: 0.1.0
  description: Small XEL-run heartbeat service API for Sui tasks, with x402 support.
servers:
  - url: https://api.deheart.io/v1
paths:
  /health:
    get:
      summary: Health check
      operationId: getHealth
      responses:
        "200":
          description: Service health
  /discovery:
    get:
      summary: Agent-readable service discovery
      operationId: getDiscovery
      responses:
        "200":
          description: Discovery metadata
  /tasks:
    get:
      summary: List tasks
      operationId: listTasks
      responses:
        "200":
          description: Task list
    post:
      summary: Register a task
      operationId: createTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskCreate"
      responses:
        "402":
          description: x402 payment required
        "201":
          description: Task registered
  /tasks/{taskId}:
    get:
      summary: Get task
      operationId: getTask
      parameters:
        - name: taskId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Task
  /tasks/{taskId}/heartbeat:
    post:
      summary: Poke task heartbeat
      operationId: pokeTaskHeartbeat
      parameters:
        - name: taskId
          in: path
          required: true
          schema:
            type: string
      responses:
        "202":
          description: Heartbeat accepted
        "402":
          description: x402 payment required
  /payments/x402/capability:
    get:
      summary: Get x402 capability metadata
      operationId: getX402Capability
      responses:
        "200":
          description: x402 payment capability
  /payments/x402/attempts:
    post:
      summary: Build x402 payment attempt
      operationId: createX402Attempt
      responses:
        "201":
          description: Unsigned payment attempt
  /payments/x402/receipts:
    post:
      summary: Record x402 settlement receipt
      operationId: createX402Receipt
      responses:
        "201":
          description: Settlement receipt recorded
components:
  schemas:
    TaskCreate:
      type: object
      required: [target, trigger, fees]
      properties:
        target:
          type: object
        trigger:
          type: object
        fees:
          type: object
        privacy:
          type: object
        verification:
          type: object
        x402:
          type: object
