SterlingridAPI guide

How the onboarding API works

Sterlingrid runs dealer onboarding for lenders that fund car dealers' stock: it collects each dealer's documents, reads them, checks them against public registers and scores them. The API lets a partner's computer system do the same steps a lender's staff do on screen, by sending written requests instead of clicking, for the lenders its client is allowed to act for. This page explains each step. If you have a client, you can send every example for real and watch what happens.

At a glance

The shape of it

Your system talks to one host. It trades a signed request for a token that lasts five minutes, then sends GraphQL with that token and a fresh proof each time. Sterlingrid tells you what happened by signed webhooks. Each request acts for one of the lenders your client is allowed.

Your systemclient_id lpc_…Sterlingrid API hostPOST /oauth/tokenPOST /graphqlPUT /uploads/<link>GET /.well-known/…A lender it may act forlender: sterlingAnother it may act forlender: acmeNot grantedFORBIDDENtoken, then GraphQLsigned webhooks
Before you start

A client: who is asking, step by step

Every system that connects is a client. A platform administrator at Sterlingrid registers it on the admin portal's API access page, with key ①'s public half, what it may do (its scopes) and which lenders it may act for. It holds two keys of its own. With key ①, the client key, it signs a client assertion saying who it is, and gets an access token that lasts five minutes and allows only what its scopes allow. With key ②, the DPoP key, it makes a fresh DPoP proof for every call; the token is bound to that key, so a copied token is useless. Sterlingrid holds only key ①'s public half, so nothing on our side can be stolen to pretend to be you, and an administrator can narrow the client or switch it off at any moment. Go through it below with a test client: every step is a real request.

Read dealers

See the dealers of the lenders it acts for: what each sent, what was read from it, the checks and the score.

read
Search Companies House

Look companies up on the public register, before they are dealers.

register
Add dealers

Add a dealer to a lender, choose what to collect, invite them, send the lender's own files.

onboard
Create lenders

Create a lender, which the client then acts for too, and invite its first admin.

lenders
  1. Make key ①, the signing key

    A pair of keys that belong together: a private half that signs and never leaves your system, and a public half that can only check signatures, which Sterlingrid registers. Make one here for a test client, or paste the private key of one you already have.

    Key ①
    EC P-256, made by your browser's own cryptography.
  2. Have Sterlingrid register the public half

    Make or paste key ① first.

  3. Make key ②, the proof key

    A second, unrelated pair of keys. Your system makes it itself, usually when it starts, and never registers or sends it. Its public half travels inside every DPoP proof, and the access token will carry its thumbprint (cnf.jkt), so only this key can use the token.

  4. Getting a token, then calling the API

    One form-encoded POST to /oauth/token. The body proves who you are (the client assertion, signed with key ①); the DPoP header proves which key the token will be bound to (a proof signed with key ②). Then every call to /graphql carries the token and a new proof. Step through it: each step is done for real.

    Your systemSterlingrid API host1 · sign client assertion (key ①)2 · sign DPoP proof (key ②)3 · POST /oauth/tokenclient_assertion=eyJ… · DPoP: eyJ…4 · checks: signature, iss, aud, jti, exp, proof5 · 200 · token_type DPoP · expires_in 3006 · POST /graphqlAuthorization: DPoP eyJ… · DPoP: eyJ… (ath)Signed in your browser with key ①: who you are, for this issuer, once.
  5. Try to break it

    Each of these sends a real request that should be refused. The answer is the server's own, word for word.

    • Like a token copied from a log: the server needs a DPoP proof made with key ②.
    • A DPoP-bound token is never accepted without a proof from the key it is bound to.
    • A proof works once: its jti has been seen.
    • A proof names one address; this one was made for /oauth/token.
    • The token's cnf.jkt names key ②; a proof from any other key has a different thumbprint.
    • A client assertion works once: its jti has been seen.

    Call the API in step 4 first: these use its token and proof.

The keys stay in this page while it is open. Nothing is saved unless you save it, and the page signs only requests to https://api.sandbox.sterlingrid.com. Use a test client, not the one your production system uses.
Step 1

What the API is

A request is a short piece of text that says what you want, sent to one address. The answer comes back as text too. Your system reads the answer and carries on. Nothing is installed, and nobody has to be there to answer.

For each lender your client acts for, the API sees what that lender's staff would see and nothing more, under the same rules. If the screens would refuse something, the API refuses it too, and says why.

Step 2

Choosing the lender

Your client acts for the lenders Sterlingrid allowed it: some chosen lenders, or every lender, including ones added later. A request about a lender's dealers says which lender it is for, as lender (its short name or id); a client that acts for only one may leave it out. A request about one dealer, by its id, acts for that dealer's lender, and searching the register needs no lender at all.

Try itList the lenders this client acts forOnly reads
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

{
  lenders { id slug name }
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Answercomes back to you
Step 3

Creating a lender

A client allowed to create lenders can add a new lender to Sterlingrid. The new lender joins the lenders the client acts for at once, and its first admin is emailed an invitation to the lender portal: a link that works once, for 72 hours. The lender is created even if the email fails or its delivery is unknown. A platform administrator can check or replace the invitation from the existing lender's admin page.

Try itCreate a lenderChanges real dataneeds the client to allow “lenders”
Request numberb20bfcba…
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)
Idempotency-Key: b20bfcba-ece3-4119-9341-fa01e5a3ea40

mutation Create($input: CreateLenderInput!) {
  createLender(input: $input) {
    lender { id slug name }
    invitation { id email sent failure }
    userErrors { code message field }
  }
}

{
  "input": {
    "name": "",
    "slug": "",
    "firstAdmin": {
      "name": "",
      "email": ""
    }
  }
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Lender createdcomes back to you
Step 4

Asking a question: find a company and read its record

Before a company can be a dealer, you find it on the Companies House register. This request asks the register at that moment and passes on what it says, for no lender in particular. The answer also says when Companies House answered, and Sterlingrid keeps a copy of what it said. Anyone can later check where a value came from.

Try it1 · Search the registerOnly readsneeds the client to allow “register”
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

query Find($q: String!) {
  companies(search: $q) {
    companies { number name status active town }
    source { fetchedAt }
  }
}

{
  "q": "Motor"
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Companies Houseasked at that moment
  5. Answercomes back to you

A search gives only a line per company. The next request asks for one company's whole record, by its number. To answer it, the API asks Companies House five separate questions at once: the company's profile, its officers, the people who control it, the loans secured on it, and the accounts it has filed. That counts as 5 of the 60 Companies House questions a client may ask each minute.

Try it2 · Read one company's recordOnly readsneeds the client to allow “register”
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

query Company($n: String!) {
  company(number: $n) {
    number name type status active incorporatedOn activity
    registeredOffice lastAccountsMadeUpTo
    officers { name role since }
    peopleWithSignificantControl { name control }
    charges { holder description createdOn outstanding }
    accountsFilings { filedOn madeUpTo kind }
    sources { provider operation fetchedAt sha256 }
  }
}

{
  "n": ""
}
Connect a client at the top of the page to send this.
  1. Your systemsends the number
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Companies Houseasked five things at once
  5. The recordcomes back to you
Step 5

Reading what is on record

Once a company is a dealer of a lender, everything about it is on record: what it sent, what was read from each document, the register checks, and the score. Every value carries where it came from: a page of a document, an answer from a register, or something the lender entered.

Try itList the lender's newest dealersOnly readsneeds the client to allow “read”
Lendernot named, from step 2
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

query Dealers($lender: String) {
  dealers(lender: $lender, first: 5) { id name companyNumber stage }
}

{}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Answercomes back to you
Step 6

Changing something: adding a dealer

Some requests change things. Adding a dealer reads the company from the register, adds it to the chosen lender's list with the amount it is asking for, and starts the register checks. The change is recorded as made by the client's own name, so it is always clear who did it.

  • Every reason at once. If the request cannot be done, the answer lists every reason together, each pointing at the field it is about, and nothing is changed. Try a company number like abc to see it.
  • Sending twice does no harm. Each request carries a request number. If the connection drops and your system sends the same request again, it gets the first answer back instead of adding a second dealer. Press “Send it” twice to see it.
Try itAdd a dealerChanges real dataneeds the client to allow “onboard”
Lendernot named, from step 2Request number328497bd…
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)
Idempotency-Key: 328497bd-9a1c-4180-8801-5ae1c0342b39

mutation Add($input: CreateDealerInput!) {
  createDealer(input: $input) {
    dealer { id name companyNumber applicationReference }
    userErrors { code message field }
  }
}

{
  "input": {
    "companyNumber": "",
    "facility": {
      "totalPence": "50000000"
    }
  }
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Companies Houseasked at that moment
  5. Dealer addedcomes back to you
Step 7

Following progress

Some work takes longer than one request: the register checks run in the background after a dealer is added. Each check goes through the same stages, and the API says which stage each one is at, with the reason if it failed.

QUEUED→RUNNING→DONEor FAILED, with the reason

Press play to watch one check.

Try itWhere a dealer's checks areOnly readsneeds the client to allow “read”
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

query Checks($id: ID!) {
  dealer(id: $id) { name checks { name label state error } }
}

{
  "id": ""
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Answercomes back to you
Step 8

Choosing what to collect

The data room is the list of what the lender needs from a dealer: bank statements, accounts, photo ID, answers about the business. Each item can come from somewhere: the dealer sends it, the dealer types an answer, it is read from Companies House, or the lender adds it itself. Saving a data room records that list; nobody is contacted yet.

Try itSee what a data room can collectOnly reads
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

{
  dataRoomItems { key label sources always byDefault }
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Answercomes back to you
Try itSave a data roomChanges real dataneeds the client to allow “onboard”
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

mutation Save($input: SaveDataRoomInput!) {
  saveDataRoom(input: $input) { planId userErrors { code message field } }
}

{
  "input": {
    "dealerId": "",
    "items": [
      {
        "key": "business-details",
        "sources": [
          "DECLARATION"
        ],
        "preferred": "DECLARATION"
      },
      {
        "key": "photo-id",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "vat-returns",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "stock-report",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "management-accounts",
        "sources": [
          "UPLOAD",
          "LENDER"
        ],
        "preferred": "LENDER"
      },
      {
        "key": "bank-statements",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "insurance-schedule",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "franchise-agreement",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "statutory-accounts-latest",
        "sources": [
          "COMPANIES_HOUSE",
          "UPLOAD"
        ],
        "preferred": "COMPANIES_HOUSE"
      },
      {
        "key": "statutory-accounts-prior",
        "sources": [
          "COMPANIES_HOUSE",
          "UPLOAD"
        ],
        "preferred": "COMPANIES_HOUSE"
      },
      {
        "key": "credit-bureau-report",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "overdraft-facility-letter",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "stocking-facility-statement",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "business-plan",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "retail-sales-targets",
        "sources": [
          "UPLOAD"
        ],
        "preferred": "UPLOAD"
      },
      {
        "key": "organisation-succession",
        "sources": [
          "UPLOAD",
          "LENDER"
        ],
        "preferred": "LENDER"
      }
    ],
    "contactName": "",
    "contactEmail": ""
  }
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Data room savedcomes back to you

The next step, inviting the dealer, emails the dealer's contact a link to their portal, where they send what is asked for. It is left out of this page because it emails a real person; the reference shows how (inviteDealer).

Step 9

Sending a file

Files are not sent inside a request. Your system asks for a link that takes one file for one item of the data room, and sends the file to that link. The link works for 15 minutes and once only, so a link that leaks is of little use to anyone else. The file is then kept and read exactly like a file the lender adds by hand.

Only the items the lender may add itself can be sent this way (management accounts, and the organisation and succession plan), and only once the data room takes them from the lender, as the one saved in step 8 does. Bank statements, VAT returns and photo ID come from the dealer, through their invitation.

Try it1 · Ask for a linkOnly readsneeds the client to allow “onboard”
What is sent
POST /graphql
Authorization: DPoP (a token for your client)
DPoP: (a new proof for this request)

mutation Up($input: CreateUploadInput!) {
  createUpload(input: $input) {
    upload { url expiresAt }
    userErrors { code message }
  }
}

{
  "input": {
    "dealerId": "",
    "item": "management-accounts",
    "filename": "file.pdf"
  }
}
Connect a client at the top of the page to send this.
  1. Your systemsends the request
  2. Token checkedours, current, and allowed?
  3. Lender's recordssame rules as the screens
  4. Link madecomes back to you
Try it2 · Send the file to the linkChanges real data
Ask for a link first.
  1. Your systemsends the file
  2. Link checkedin time, unused?
  3. Keptstored, its type read
  4. Queued to be readlike the lender's own
Step 10

Being told when something happens

Instead of asking again and again whether anything changed, your system can be told. When a check finishes, a dealer sends something, a document is read or the score is recorded, Sterlingrid sends a short message to an address you choose. The message says what happened and which dealer; your system then asks for the details. If your address does not answer, the message is sent again, with longer waits, for about four hours. One address hears about the dealers of every lender your client acts for.

How do you know a message really came from Sterlingrid? Each one carries a code worked out from the message and a secret that only you and Sterlingrid hold. Your system works the code out again and compares. Change a single character below and see.

What we send
{"type":"item.submitted","data":{"item":"bank-statements"}}
with the code made from it and the secret:
…
What you receive (edit it)
the code you work out from them:
…

The codes differ: do not trust this message.

For now Sterlingrid sets the address for your client and gives you the secret once; setting it will move to the admin portal's API access page, with the rest of your client.

Step 11

What is recorded

  • Every request is recorded, refused ones included: which client, when, what was asked, which lender it was for, and which dealers' information the answer contained.
  • Every change a client makes is in that lender's audit log under the client's own name.
  • Every message sent to your address, and every retry, is recorded with how it ended.
  • None of these records can be edited or deleted.

The full reference, for the people building your side, is the API reference (docs/api.md) and the schema, which also opens at https://api.sandbox.sterlingrid.com/graphql in a browser.