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_idandclient_secretfrom 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.
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
- Get an access token.
- Make your first call.
- 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 Modify your code:Result:
/v1, and the token it returns works on v2 requests.Sample request
- Replace
CLIENT_IDandCLIENT_SECRETwith your sandbox credentials. - Set
scopeto 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
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.Modify your code:Result:
Sample request
- Replace
ACCESS_TOKENwith the token from Step 1.
Sample response (trimmed)
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-Signatureheader on every delivery before you act on it, using your endpoint’s signing secret. The steps are on Webhooks & Events. - Respond with a
2xxstatus. - Use the event
idto skip a delivery you’ve already handled.
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.Related
- Environments and testing: how sandbox and production differ, and what sandbox simulates
- Move objects and trigger events in sandbox: the two sandbox-only calls, their rules, and their errors
- Authentication: the token endpoint, every scope, and the IP allowlist limits
- Webhooks & Events: how to verify a signature, retries, the v2 event body, and the event list
- Program launch: the milestones from kickoff through sandbox testing to go-live, and when you get credentials

