{
  "info": {
    "name": "StayEasy Booking API (sample)",
    "description": "Postman collection for the fictional StayEasy Booking API. Set the `api_key` variable to your sandbox key before sending requests.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      { "key": "token", "value": "{{api_key}}", "type": "string" }
    ]
  },
  "variable": [
    { "key": "base_url", "value": "https://sandbox.stayeasy.example.com/v1" },
    { "key": "api_key", "value": "sk_test_EXAMPLE_KEY" },
    { "key": "room_id", "value": "rm_1042" },
    { "key": "booking_id", "value": "bk_88213" }
  ],
  "item": [
    {
      "name": "Rooms",
      "item": [
        {
          "name": "List available rooms",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/rooms?check_in=2026-11-10&check_out=2026-11-12&guests=2",
              "host": ["{{base_url}}"],
              "path": ["rooms"],
              "query": [
                { "key": "check_in", "value": "2026-11-10" },
                { "key": "check_out", "value": "2026-11-12" },
                { "key": "guests", "value": "2" }
              ]
            },
            "description": "Returns rooms available for the dates and number of guests."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Response has a data array', function () {",
                  "  pm.expect(pm.response.json().data).to.be.an('array');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "Retrieve a room",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/rooms/{{room_id}}",
              "host": ["{{base_url}}"],
              "path": ["rooms", "{{room_id}}"]
            },
            "description": "Returns a single room by ID."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Bookings",
      "item": [
        {
          "name": "Create a booking",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Idempotency-Key", "value": "{{$guid}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"room_id\": \"{{room_id}}\",\n  \"check_in\": \"2026-11-10\",\n  \"check_out\": \"2026-11-12\",\n  \"guests\": 2,\n  \"guest\": {\n    \"name\": \"Priya Raman\",\n    \"email\": \"priya.raman@example.com\"\n  }\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/bookings",
              "host": ["{{base_url}}"],
              "path": ["bookings"]
            },
            "description": "Reserves a room. The Idempotency-Key header uses a new GUID for each send."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 201', function () {",
                  "  pm.response.to.have.status(201);",
                  "});",
                  "var booking = pm.response.json();",
                  "pm.test('Booking is confirmed', function () {",
                  "  pm.expect(booking.status).to.eql('confirmed');",
                  "});",
                  "pm.collectionVariables.set('booking_id', booking.id);"
                ]
              }
            }
          ]
        },
        {
          "name": "Retrieve a booking",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/bookings/{{booking_id}}",
              "host": ["{{base_url}}"],
              "path": ["bookings", "{{booking_id}}"]
            },
            "description": "Returns a single booking by ID."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "Cancel a booking",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/bookings/{{booking_id}}",
              "host": ["{{base_url}}"],
              "path": ["bookings", "{{booking_id}}"]
            },
            "description": "Cancels a booking. Its status changes to cancelled."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Booking is cancelled', function () {",
                  "  pm.expect(pm.response.json().status).to.eql('cancelled');",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
