function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

​How to send leads from our SFO to an API - How would I go about doing this?

My question is in two parts:
In the ideal world - I would also like to send leads to the API based on a filter, i.e. Record Type.
The URL to push the data to is

One thing to note is that the id's of the API are different from our SFO id's for the equivalent field.

The API field ids are:
name (The name of person enquiring)
postcode (The postcode of the person enquiring)
phone (The phone number of the person enquiring)
adCode (The advert code assigned to you, usually something like TPWST)
productRef (The product reference – will be Stairlifts)
email (The email of the person enquiring)

How would I map our field data across to the new fields?
All of the above would be automated, when a lead comes into our SFO via a webform, based on Record Type criteria, it would fire....

This is a very new area for me, any additional reading or assistance would greatly be appreciated recommendations

Thanks in advance!!
To do this, I would write an Apex trigger that uses a callout to your external api [1].  Roughly I would do the following:
  • Ensure that your API endpoint can handle bulk data
  • Write a trigger on insert of a Lead object
    • Iterate over all Leads and find the ones that match your criteria
    • Build up a list of Leads to send
    • Pass the data to you @future method (since we're in a trigger)
    • Make your callout in the @future method
This is not a "simple" thing, but it shouldn't be too difficult, assuming your API endpoint is written well.

[1] (You care about the HTTP (RESTful) Services section)
Cheers pcon - l will have a read of this and see if I can figure it out - everything I do is self taught, so it might take me a while ;)
Sadly pcon - this is beyond my understanding, completely !! :/
What part confuses you?  How can I help clarify?
I think that I have got some of it done in the APex class - as mentioned before - just firing it.
Is there a way within this Apex class to map my field ids with that of the destination field ids?