Creating a webhook

To setup a webhook you will need to create a subscription through the YouLend Notification API. As part of this request you will send us the URL of your endpoint and the list of events you want to be notified about. This sets you up a subscription to those events. Whenever those events occur in our system you will now be notified about them via a POST request to your endpoint. To see the events that are available for subscribing to, please see the section below.

Example request to create a subscription

curl -X POST 'https://partners.staging-youlendapi.com/notification/webhooksubscription' \
      -H 'authorization: Bearer ACCESS_TOKEN' \
      -H 'Content-Type: application/json' \
      -d '{
           "eventCodes": ["ONB10001","ONB10002","ONB10003","ONB10004","LOA10013"],
           "webhookUrl": "https://your_url.com"
          }'
EnvironmentURL
EU (staging)https://partners.staging-youlendapi.com/notification/webhooksubscription
EU (production)https://youlendapi.com/notification/webhooksubscription
USA (staging)https://uspartners.staging-youlendapi.com/notification/webhooksubscription
USA (production)https://youlendapi.us/notification/webhooksubscription

Now that you have created the subscription, YouLend will send a notification to the provided URL when any of the events that you subscribed to occur. For help with triggering events on our test environment please get in touch with your account manager.

📘

Good to know

If you do not want to use the same endpoint for every event you can create multiple subscriptions with us providing different URLs and events. Events will be sent to the corresponding endpoint

Example response of a notification that we will send to your URL

{
    "EventCode": "ONB10011",
    "Message": "Offers Provided",
    "EventProperties": {
        "LeadId": "f3c23809-9850-4546-bd08-650068aa55f6",
          "Offers": [
              {
                "OfferId": "d08292ef-b034-4b64-a4c6-ad2babd46dbd",
                "YouWillGet": "1000.0",
                "YouWillRepay": "1200.0",
                "CurrencyISOCode": "GBP",
                "Sweep": "20.0"
              }
           ]
     }
}

🚧

Be aware

It is important your endpoint sends back a 2xx status code in a timely manner so that we know you have successfully received the notification. If we do not receive a 2xx code back within 100 seconds we will attempt to send the request again. We will try again 2 more times over a period of 2 minutes

You will also notice in the response to the create subscription request there is a secret key, this is unique to each subscription. This is used to verify the request is coming from YouLend. More information about how to verify requests can be found here.