Retrieve leads

This tutorial shows how to save leads generated in Aurora to other applications in your IT ecosystem in real-time.

How It Works


When a potential customer submits contact information in Lead Capture AI, Aurora creates a lead object in your tenant and triggers lead_created webhook event. On the webhook receipt, you’ll retrieve lead information from Aurora using Retrieve Lead API and save the data to your target system.

Getting Started


To complete this tutorial, you will need:

  • your Aurora tenant to be on the Custom or Business plan,
  • your Aurora tenant to use the current API version,
  • your Aurora bearer token,
  • your Aurora tenant_id,
  • URL to deliver Aurora webhooks to.

You or any Administrator for your Aurora tenant can retrieve the token and tenant id from the API Settings page.

Step 1. Subscribe to lead_created webhook event.


Subscribe tolead_created webhook event and point the webhooks to your application that will process them. The event will trigger when a new lead is created in Aurora, providing you with lead_id.

//POST https://api-sandbox.aurorasolar.com/tenants/{tenant_id}/webhooks

  {
  "webhook": {
    "description": "Lead Created",
    "event": "lead_created",
    "url_template": "https://www.yourcomany.com/lead_created_webhooks?lead_id=<LEAD_ID>",
    "enabled": true
  }
}

Step 2. Retrieve lead details and store them in our target system.


On the webhook receipt, lookup lead details using Retrieve Lead API and store the data in our target system.

/Webhook query string payload
?lead_id=3fa85f64-5717-4562-b3fc-2c963f66afa6

//GET https://api-sandbox.aurorasolar.com/tenants/{tenant_id}/leads/{lead_id}

//HTTP 200 response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "address": "434 Brannan St, San Francisco, CA, 94107",
  "project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "latitude": 37.77960043,
  "longitude": -122.39530086,
  "customer": {
    "customer_address": "434 Brannan St, San Francisco, CA, USA",
    "customer_email": "[email protected]",
    "customer_first_name": "Jane",
    "customer_last_name": "Doe",
    "customer_phone": "(555) 111-5151"
  },
  "monthly_average_bill": 0,
  "system_size_stc": 0,
  "annual_production": 0,
  "module_count": 0,
  "sunlight_hours": 0,
  "pct_utility_bill_offset": 0,
  "created_at": "2022-07-07T21:16:20.411Z",
  "updated_at": "2022-07-07T21:16:20.411Z"
}

Considerations


  • Consider using a webhook test site like https://webhook.site to verify that your webhook subscription is live.
  • Your users might modify select lead attributes in Aurora. To keep your application in sync with lead changes as well, complete the steps above with lead_changed webhook event.