{
  "info": {
    "name": "HobbiHopp Developer API",
    "description": "Manage classes, read bookings, message students, and manage webhooks.\n\nSetup: create an API key on the HobbiHopp host website, then set the `apiKey` collection variable (Variables tab). All requests inherit Bearer auth from the collection.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{"key": "token", "value": "{{apiKey}}", "type": "string"}]
  },
  "variable": [
    {"key": "baseUrl", "value": "https://hobbihopp-api.web.app/v1"},
    {"key": "apiKey", "value": "hh_live_REPLACE_ME"},
    {"key": "classId", "value": ""},
    {"key": "studentId", "value": ""},
    {"key": "webhookId", "value": ""}
  ],
  "item": [
    {
      "name": "Test Connection (GET /me)",
      "request": {
        "method": "GET",
        "url": {"raw": "{{baseUrl}}/me", "host": ["{{baseUrl}}"], "path": ["me"]}
      }
    },
    {
      "name": "Classes",
      "item": [
        {
          "name": "List Classes",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/classes?status=active&limit=20",
              "host": ["{{baseUrl}}"], "path": ["classes"],
              "query": [
                {"key": "status", "value": "active", "description": "active | past", "disabled": true},
                {"key": "from", "value": "2026-07-01T00:00:00Z", "disabled": true},
                {"key": "to", "value": "2026-12-31T23:59:59Z", "disabled": true},
                {"key": "limit", "value": "20", "disabled": true},
                {"key": "startAfter", "value": "", "description": "id of last class from previous page", "disabled": true}
              ]
            }
          }
        },
        {
          "name": "Get Class",
          "request": {
            "method": "GET",
            "url": {"raw": "{{baseUrl}}/classes/{{classId}}", "host": ["{{baseUrl}}"], "path": ["classes", "{{classId}}"]}
          }
        },
        {
          "name": "Create Class",
          "request": {
            "method": "POST",
            "header": [{"key": "Content-Type", "value": "application/json"}],
            "url": {"raw": "{{baseUrl}}/classes", "host": ["{{baseUrl}}"], "path": ["classes"]},
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Pottery for Beginners\",\n  \"description\": \"Learn to throw your first pot on the wheel. All materials included.\",\n  \"category\": \"Arts & Crafts\",\n  \"price\": 45,\n  \"maxStudents\": 10,\n  \"dateTime\": \"2026-09-01T18:00:00Z\",\n  \"duration\": 2,\n  \"location\": \"12 Kiln Street, Wellington\",\n  \"tags\": [\"beginner-friendly\", \"materials-included\"],\n  \"includedItems\": [\"All materials and tools\", \"Expert instruction\"]\n}"
            }
          }
        },
        {
          "name": "Update Class",
          "request": {
            "method": "PATCH",
            "header": [{"key": "Content-Type", "value": "application/json"}],
            "url": {"raw": "{{baseUrl}}/classes/{{classId}}", "host": ["{{baseUrl}}"], "path": ["classes", "{{classId}}"]},
            "body": {
              "mode": "raw",
              "raw": "{\n  \"maxStudents\": 15,\n  \"price\": 50\n}"
            }
          }
        },
        {
          "name": "Cancel Class",
          "request": {
            "method": "DELETE",
            "url": {"raw": "{{baseUrl}}/classes/{{classId}}", "host": ["{{baseUrl}}"], "path": ["classes", "{{classId}}"]}
          }
        },
        {
          "name": "List Class Bookings",
          "request": {
            "method": "GET",
            "url": {"raw": "{{baseUrl}}/classes/{{classId}}/bookings", "host": ["{{baseUrl}}"], "path": ["classes", "{{classId}}", "bookings"]}
          }
        },
        {
          "name": "Message All Class Students",
          "request": {
            "method": "POST",
            "header": [{"key": "Content-Type", "value": "application/json"}],
            "url": {"raw": "{{baseUrl}}/classes/{{classId}}/message", "host": ["{{baseUrl}}"], "path": ["classes", "{{classId}}", "message"]},
            "body": {
              "mode": "raw",
              "raw": "{\n  \"text\": \"Hi everyone! Quick reminder that class starts at 6pm sharp. See you there!\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Bookings",
      "item": [
        {
          "name": "List Bookings",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/bookings?limit=20",
              "host": ["{{baseUrl}}"], "path": ["bookings"],
              "query": [
                {"key": "status", "value": "confirmed", "description": "confirmed | completed | cancelled", "disabled": true},
                {"key": "classId", "value": "", "disabled": true},
                {"key": "from", "value": "", "disabled": true},
                {"key": "to", "value": "", "disabled": true},
                {"key": "limit", "value": "20", "disabled": true},
                {"key": "startAfter", "value": "", "disabled": true}
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Messages",
      "item": [
        {
          "name": "Message a Student",
          "request": {
            "method": "POST",
            "header": [{"key": "Content-Type", "value": "application/json"}],
            "url": {"raw": "{{baseUrl}}/messages", "host": ["{{baseUrl}}"], "path": ["messages"]},
            "body": {
              "mode": "raw",
              "raw": "{\n  \"studentId\": \"{{studentId}}\",\n  \"text\": \"Hi! Just confirming your booking for Saturday.\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "List Webhooks",
          "request": {
            "method": "GET",
            "url": {"raw": "{{baseUrl}}/webhooks", "host": ["{{baseUrl}}"], "path": ["webhooks"]}
          }
        },
        {
          "name": "Create Webhook",
          "request": {
            "method": "POST",
            "header": [{"key": "Content-Type", "value": "application/json"}],
            "url": {"raw": "{{baseUrl}}/webhooks", "host": ["{{baseUrl}}"], "path": ["webhooks"]},
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://example.com/hobbihopp-events\",\n  \"events\": [\"booking.created\", \"booking.cancelled\"]\n}"
            },
            "description": "The response contains the signing `secret` exactly once — save it. Deliveries carry X-HobbiHopp-Signature: sha256=<HMAC-SHA256 of raw body>."
          }
        },
        {
          "name": "Delete Webhook",
          "request": {
            "method": "DELETE",
            "url": {"raw": "{{baseUrl}}/webhooks/{{webhookId}}", "host": ["{{baseUrl}}"], "path": ["webhooks", "{{webhookId}}"]}
          }
        }
      ]
    },
    {
      "name": "Reports & earnings",
      "item": [
        {
          "name": "Summary (overview)",
          "request": {
            "method": "GET",
            "url": {"raw": "{{baseUrl}}/reports/summary", "host": ["{{baseUrl}}"], "path": ["reports", "summary"]},
            "description": "Headline numbers: classes, students, bookings, attendance, rating, and revenue."
          },
          "response": [
            {
              "name": "Example",
              "originalRequest": {"method": "GET", "url": {"raw": "{{baseUrl}}/reports/summary", "host": ["{{baseUrl}}"], "path": ["reports", "summary"]}},
              "status": "OK", "code": 200, "header": [{"key": "Content-Type", "value": "application/json"}],
              "body": "{\n  \"data\": {\n    \"classes\": { \"total\": 24, \"active\": 5, \"past\": 19 },\n    \"students\": { \"total\": 138, \"active\": 42 },\n    \"bookings\": { \"total\": 310, \"confirmed\": 47, \"completed\": 250, \"cancelled\": 13 },\n    \"attendance\": { \"attended\": 236, \"rate\": 94.4 },\n    \"rating\": { \"average\": 4.8, \"reviewCount\": 96 },\n    \"revenue\": { \"earned\": 11250.50, \"available\": 8400.00, \"pending\": 2850.50, \"currency\": \"USD\" }\n  }\n}"
            }
          ]
        },
        {
          "name": "Revenue (earnings)",
          "request": {
            "method": "GET",
            "url": {"raw": "{{baseUrl}}/reports/revenue", "host": ["{{baseUrl}}"], "path": ["reports", "revenue"]},
            "description": "Detailed earnings — matches the app's Earnings screen exactly."
          },
          "response": [
            {
              "name": "Example",
              "originalRequest": {"method": "GET", "url": {"raw": "{{baseUrl}}/reports/revenue", "host": ["{{baseUrl}}"], "path": ["reports", "revenue"]}},
              "status": "OK", "code": 200, "header": [{"key": "Content-Type", "value": "application/json"}],
              "body": "{\n  \"data\": {\n    \"totalEarnings\": 11250.50,\n    \"availableBalance\": 8400.00,\n    \"pendingBalance\": 2850.50,\n    \"totalPaidOut\": 6000.00,\n    \"totalBookings\": 250,\n    \"totalClassesTaught\": 19,\n    \"lastPayoutDate\": \"2026-06-20T00:00:00.000Z\",\n    \"earningsByMonth\": { \"2026-05\": 3200.00, \"2026-06\": 4100.50 },\n    \"lastUpdated\": \"2026-07-03T08:00:00.000Z\",\n    \"currency\": \"USD\"\n  }\n}"
            }
          ]
        },
        {
          "name": "Payouts",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/reports/payouts",
              "host": ["{{baseUrl}}"], "path": ["reports", "payouts"],
              "query": [{"key": "status", "value": "completed", "disabled": true}]
            },
            "description": "Withdrawal history with status and dates."
          },
          "response": [
            {
              "name": "Example",
              "originalRequest": {"method": "GET", "url": {"raw": "{{baseUrl}}/reports/payouts", "host": ["{{baseUrl}}"], "path": ["reports", "payouts"]}},
              "status": "OK", "code": 200, "header": [{"key": "Content-Type", "value": "application/json"}],
              "body": "{\n  \"data\": [\n    {\n      \"id\": \"po_1\",\n      \"amount\": 6000.00,\n      \"currency\": \"USD\",\n      \"status\": \"completed\",\n      \"payoutMethod\": \"bank_transfer\",\n      \"bankAccountLast4\": \"4242\",\n      \"requestedAt\": \"2026-06-18T00:00:00.000Z\",\n      \"completedAt\": \"2026-06-20T00:00:00.000Z\"\n    }\n  ],\n  \"nextCursor\": null\n}"
            }
          ]
        },
        {
          "name": "Per-class breakdown",
          "request": {
            "method": "GET",
            "url": {"raw": "{{baseUrl}}/reports/classes", "host": ["{{baseUrl}}"], "path": ["reports", "classes"]},
            "description": "A row per class: fill rate, bookings, attendance, revenue, rating."
          },
          "response": [
            {
              "name": "Example",
              "originalRequest": {"method": "GET", "url": {"raw": "{{baseUrl}}/reports/classes", "host": ["{{baseUrl}}"], "path": ["reports", "classes"]}},
              "status": "OK", "code": 200, "header": [{"key": "Content-Type", "value": "application/json"}],
              "body": "{\n  \"data\": [\n    {\n      \"classId\": \"cls_pottery\",\n      \"title\": \"Pottery for Beginners\",\n      \"dateTime\": \"2026-09-15T18:00:00.000Z\",\n      \"isActive\": true,\n      \"maxStudents\": 10,\n      \"enrolledStudents\": 8,\n      \"fillRate\": 80,\n      \"bookings\": { \"confirmed\": 8, \"cancelled\": 1 },\n      \"attendance\": { \"attended\": 7, \"rate\": 87.5 },\n      \"revenue\": 360.00,\n      \"rating\": 4.8,\n      \"reviewCount\": 12\n    }\n  ]\n}"
            }
          ]
        }
      ]
    }
  ]
}
