Skip to main content
Sandbox is Lead’s test system, and this page takes you from your credentials to your first v2 call there. To see how sandbox differs from production, read Environments and testing. The steps before and after sandbox testing are on Program launch.

Before you start

Your Technical Account Manager sets up your sandbox after you and Lead have agreed on your funds flow and how your activity maps to Lead’s objects. Program launch has the full sequence. Then:
  • Send your Technical Account Manager the HTTPS URL where you want to receive webhooks. If you restrict API access by IP address, send the IPv4 subnets your calls come from too. See IP allowlist for the limits.
  • Get your sandbox client_id and client_secret from your Technical Account Manager, and store them where only your servers can read them.
  • Get your webhook endpoint’s signing secret from your Technical Account Manager. You need it in Step 3.
Those two values are your sandbox credentials. The client_id says which program is calling. The client_secret proves the call really comes from you, so treat it like a password. You don’t send either one on every request. In Step 1, you trade them for an access token, and the token is what goes on each call after that. Both work only with https://api.sandbox.lead.bank. Production has its own pair. A program is one product or set of products you run with Lead, and each program gets its own credentials. See Programs and partners.

What you’ll do

  1. Get an access token.
  2. Make your first call.
  3. Set up your webhook handler.

Steps

1

Get an access token

Exchange your credentials for an access token. Request only the scopes you need. Its path starts with /v1, and the token it returns works on v2 requests.
Sample request
Modify your code:
  • Replace CLIENT_ID and CLIENT_SECRET with your sandbox credentials.
  • Set scope to the scopes you need, separated by spaces. This example asks for one. Each scope is listed on Authentication.
  • Reuse the token until it expires. Don’t request a new token for each call.
Sample response
Result: 200. Store access_token as ACCESS_TOKEN for Step 2. The token is valid for expires_in seconds, which is 24 hours by default.
2

Make your first call

List your program’s core accounts, the accounts Lead opened for your program. The call needs no request body, so it tests your token and base URL before you create anything.
Sample request
Modify your code:
  • Replace ACCESS_TOKEN with the token from Step 1.
Sample response (trimmed)
Result: 200 with a list of core accounts. Your token and base URL work.
3

Set up your webhook handler

A webhook is how Lead tells you something changed without you having to ask. When a funding (your instruction to Lead to send loan principal) reaches posted, for example, Lead sends an HTTPS request to the URL you gave your Technical Account Manager. Your webhook handler is the code at that URL that receives it. Set it up before you run Originate your first loan. The funding that quickstart creates can send your first event, and a broken signature check is better found in sandbox than in production.If your endpoint is behind a firewall, allow the sandbox webhook address listed on Webhooks & Events. Lead retries a delivery that doesn’t get a 2xx response, and the same event can arrive more than once. The schedule is on the same page.Modify your code:
  • Verify the Lead-Signature header on every delivery before you act on it, using your endpoint’s signing secret. The steps are on Webhooks & Events.
  • Respond with a 2xx status.
  • Use the event id to skip a delivery you’ve already handled.
Result: Your handler verifies the signature, returns 2xx, and ignores a repeated id. The first event arrives when an object in your program changes to a status that sends one. Not every status change does. Webhooks & Events lists the v2 events and the fields in an event body.

What happens next

Nothing on this page creates an object or sends a webhook. Originate your first loan creates a borrower, a loan, and a funding. If funding events are enabled for your program, the posted funding sends your first event. Your Technical Account Manager can tell you whether they are.

Common errors

These are the errors you’re most likely to see on this page: The other v2 errors are on Errors.

Test in sandbox

Every step on this page runs in sandbox. For the test run that follows, see Test and go live with fundings.

Next step

Originate your first loan in sandbox, from a token to a posted funding.