{
  "format": "jsonpage-zap-template",
  "version": 1,
  "name": "Jsonpage - Complete a new row (name, VAT, address)",
  "description": "A new row in Google Sheets (or a new HubSpot contact) is completed with the official name, SIREN, VAT number and address, and written back.",
  "importable": false,
  "importNote": "Zapier cannot import a Zap from a file: create the Zap with the steps below, in order. Each step lists the app, the action and the exact settings. {{...}} marks a field to map from a previous step.",
  "apiKeyPlaceholder": "PASTE_YOUR_JSONPAGE_API_KEY",
  "trigger": {
    "app": "Google Sheets",
    "event": "New Spreadsheet Row",
    "alternative": {
      "app": "HubSpot",
      "event": "New Contact",
      "note": "Map {{trigger.Entreprise}} to the company name property and write back with HubSpot Update Contact."
    },
    "fields": {
      "Entreprise": "column A: company name, SIREN, SIRET or VAT number"
    }
  },
  "steps": [
    {
      "order": 1,
      "title": "Search the company",
      "app": "Webhooks by Zapier",
      "action": "Custom Request",
      "method": "GET",
      "url": "https://api.jsonpage.com/v2/autocomplete",
      "headers": {
        "X-API-Key": "PASTE_YOUR_JSONPAGE_API_KEY"
      },
      "query": {
        "q": "{{trigger.Entreprise}}",
        "limit": "1"
      }
    },
    {
      "order": 2,
      "title": "Continue only if a company was found",
      "app": "Filter by Zapier",
      "action": "Only continue if",
      "condition": "{{step1.data__0__id}} exists"
    },
    {
      "order": 3,
      "title": "Get the company record",
      "app": "Webhooks by Zapier",
      "action": "Custom Request",
      "method": "GET",
      "url": "https://api.jsonpage.com/v2/companies/{{step1.data__0__id}}",
      "headers": {
        "X-API-Key": "PASTE_YOUR_JSONPAGE_API_KEY"
      },
      "query": {
        "include": "address,vat"
      }
    },
    {
      "order": 4,
      "title": "Write the result back",
      "app": "Google Sheets",
      "action": "Update Spreadsheet Row",
      "fields": {
        "Row": "{{trigger.row_number}}",
        "Official name": "{{step3.data__name}}",
        "SIREN": "{{step3.data__registry_id}}",
        "Status": "{{step3.data__status}}",
        "VAT number": "{{step3.data__vat__number}}",
        "VAT status": "{{step3.data__vat__status}}",
        "Address": "{{step3.data__address__formatted}}"
      }
    }
  ],
  "notes": [
    "Zapier flattens the JSON of a response: data.0.id becomes data__0__id.",
    "Each run uses two requests of your plan.",
    "A SIREN or SIRET works in the Entreprise column as well as a name."
  ]
}
