{
  "name": "Gaplessly - check booking availability",
  "active": false,
  "nodes": [
    {
      "id": "start",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 0],
      "parameters": {}
    },
    {
      "id": "inputs",
      "name": "Inputs",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [220, 0],
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\"date\":\"\",\"partySize\":2,\"serviceId\":\"\",\"providerId\":\"\"}"
      },
      "notesInFlow": true,
      "notes": "Set date to YYYY-MM-DD or leave blank for today in the business timezone. Restaurants: set partySize. Appointments: set serviceId and optionally providerId. No secrets here."
    },
    {
      "id": "organization",
      "name": "Read organization",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0],
      "parameters": {
        "url": "https://gaplessly.com/api/v1/organization",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": { "timeout": 15000 }
      },
      "notesInFlow": true,
      "notes": "Choose Header Auth credentials: name Authorization, value Bearer followed by your Gaplessly API key. Use the same credential on Check availability. Scopes: organization:read and availability:read. Start with a sandbox key."
    },
    {
      "id": "availability",
      "name": "Check availability",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [660, 0],
      "parameters": {
        "url": "https://gaplessly.com/api/v1/availability",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "specifyQuery": "json",
        "jsonQuery": "={{ { date: $('Inputs').first().json.date || $now.setZone($json.data.timezone).toFormat('yyyy-MM-dd'), ...($json.data.businessType === 'hospitality' ? { partySize: $('Inputs').first().json.partySize } : { serviceId: $('Inputs').first().json.serviceId, ...($('Inputs').first().json.providerId ? { providerId: $('Inputs').first().json.providerId } : {}) }) } }}",
        "options": { "timeout": 15000 }
      },
      "notesInFlow": true,
      "notes": "Select the same Header Auth credential. Successful output is data.businessType and data.days (slots and unavailability reasons). Errors stop the workflow; no bookings are created."
    }
  ],
  "connections": {
    "Run manually": { "main": [[{ "node": "Inputs", "type": "main", "index": 0 }]] },
    "Inputs": { "main": [[{ "node": "Read organization", "type": "main", "index": 0 }]] },
    "Read organization": { "main": [[{ "node": "Check availability", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {},
  "tags": []
}
