We can insert Lead record using standard Salesforce REST API.
By doing a POST request to https://{Your Domain}.my.salesforce.com/services/data/v58.0/sobjects/Lead/, we can easily insert Salesforce Lead record with Session Id.
Check the following steps for reference.
1. Create a Connected App in Salesforce.
Callback URL should be https://{Your Domain}.my.salesforce.com/services/oauth2/callback
Example:
https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/callback
2. Get the Access token.
Endpoint URL:
https://test-ec-dev-ed.develop.my.salesforce.com/services/oauth2/token
3. Use the Access Token from Step 2 and make a POST Request to create the Lead record.
Endpoint URL:
https://test-ec-dev-ed.develop.my.salesforce.com/services/data/v58.0/sobjects/Lead/
Sample Body:
{
"FirstName" : "Sample",
"LastName" : "Example",
"Company": "Test Company",
"Email": "[email protected]"
}
Sample Lead created via REST API: