{
  "info": {
    "name": "NearbyAssist Integrations",
    "description": "Companion collection for NearbyAssist integration onboarding.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://www.nearbyassist.com" },
    { "key": "bearer_token", "value": "" },
    { "key": "integration_api_key", "value": "" },
    { "key": "business_id", "value": "" },
    { "key": "account_id", "value": "" },
    { "key": "booking_id", "value": "" },
    { "key": "hold_token", "value": "" },
    { "key": "user_uuid", "value": "" }
  ],
  "item": [
    {
      "name": "1 - Create API Key",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{bearer_token}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{base_url}}/api/integrations/business/{{business_id}}/api-keys",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"label\": \"Postman Connector\",\n  \"scopes\": [\"availability:read\", \"bookings:read\", \"bookings:write\", \"webhooks:read\", \"webhooks:write\"]\n}"
        }
      }
    },
    {
      "name": "2 - Partner Me",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-Integration-Api-Key", "value": "{{integration_api_key}}" }
        ],
        "url": "{{base_url}}/api/integrations/partner/me"
      }
    },
    {
      "name": "3 - Availability",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-Integration-Api-Key", "value": "{{integration_api_key}}" }
        ],
        "url": "{{base_url}}/api/integrations/partner/availability?date_from=2026-02-25T00:00:00.000Z&date_to=2026-02-25T23:59:59.999Z"
      }
    },
    {
      "name": "4 - Slot Hold",
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-Integration-Api-Key", "value": "{{integration_api_key}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{base_url}}/api/integrations/partner/slot-holds",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"customer_user_id\": \"{{user_uuid}}\",\n  \"starts_at\": \"2026-02-25T10:00:00.000Z\",\n  \"ends_at\": \"2026-02-25T10:30:00.000Z\",\n  \"ttl_minutes\": 10\n}"
        }
      }
    },
    {
      "name": "5 - Create Booking",
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-Integration-Api-Key", "value": "{{integration_api_key}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{base_url}}/api/integrations/partner/bookings",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"customer_user_id\": \"{{user_uuid}}\",\n  \"start_time\": \"2026-02-25T10:00:00.000Z\",\n  \"end_time\": \"2026-02-25T10:30:00.000Z\",\n  \"hold_token\": \"{{hold_token}}\",\n  \"notes\": \"Booked via Postman\"\n}"
        }
      }
    },
    {
      "name": "6 - Create Integration Account",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{bearer_token}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{base_url}}/api/integrations/business/{{business_id}}/accounts",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"provider\": \"google_calendar\",\n  \"connection_type\": \"oauth\"\n}"
        }
      }
    },
    {
      "name": "7 - Start OAuth",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{bearer_token}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{base_url}}/api/integrations/business/{{business_id}}/accounts/{{account_id}}/oauth/start",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"redirect_uri\": \"https://www.nearbyassist.com/integrations/oauth/callback\"\n}"
        }
      }
    },
    {
      "name": "8 - Create Webhook Subscription",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{bearer_token}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{base_url}}/api/integrations/business/{{business_id}}/webhook-subscriptions",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"provider\": \"generic_webhook\",\n  \"target_url\": \"https://your-system.example/webhooks/nearbyassist\",\n  \"event_types\": [\"booking.created\", \"booking.updated\", \"booking.cancelled\", \"booking.completed\"]\n}"
        }
      }
    }
  ]
}
