curl --request POST \
--url https://api.trysela.com/api/leads/upsert/ \
--header 'Authorization: Token <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"email": "first_name@trysela.com",
"phone_number": "+18042221111",
"metadata": {
"first_name": "First",
"last_name": "Name",
"timezone": "America/New_York",
"property_address": "123 Main St",
"property_city": "Richmond",
"property_state": "Virginia",
"property_zip": "23219",
"address": "456 2nd St",
"city": "Norfolk",
"state": "Virginia",
"zip": "23510"
},
"external_id": "id_in_your_crm_123",
"lead_source": "USDALoans.com",
"lead_type": 123,
"representative": 456,
"us_state": "VA"
}'import requests
url = "https://api.trysela.com/api/leads/upsert/"
payload = {
"email": "first_name@trysela.com",
"phone_number": "+18042221111",
"metadata": {
"first_name": "First",
"last_name": "Name",
"timezone": "America/New_York",
"property_address": "123 Main St",
"property_city": "Richmond",
"property_state": "Virginia",
"property_zip": "23219",
"address": "456 2nd St",
"city": "Norfolk",
"state": "Virginia",
"zip": "23510"
},
"external_id": "id_in_your_crm_123",
"lead_source": "USDALoans.com",
"lead_type": 123,
"representative": 456,
"us_state": "VA"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email: 'first_name@trysela.com',
phone_number: '+18042221111',
metadata: {
first_name: 'First',
last_name: 'Name',
timezone: 'America/New_York',
property_address: '123 Main St',
property_city: 'Richmond',
property_state: 'Virginia',
property_zip: '23219',
address: '456 2nd St',
city: 'Norfolk',
state: 'Virginia',
zip: '23510'
},
external_id: 'id_in_your_crm_123',
lead_source: 'USDALoans.com',
lead_type: 123,
representative: 456,
us_state: 'VA'
})
};
fetch('https://api.trysela.com/api/leads/upsert/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trysela.com/api/leads/upsert/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => 'first_name@trysela.com',
'phone_number' => '+18042221111',
'metadata' => [
'first_name' => 'First',
'last_name' => 'Name',
'timezone' => 'America/New_York',
'property_address' => '123 Main St',
'property_city' => 'Richmond',
'property_state' => 'Virginia',
'property_zip' => '23219',
'address' => '456 2nd St',
'city' => 'Norfolk',
'state' => 'Virginia',
'zip' => '23510'
],
'external_id' => 'id_in_your_crm_123',
'lead_source' => 'USDALoans.com',
'lead_type' => 123,
'representative' => 456,
'us_state' => 'VA'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trysela.com/api/leads/upsert/"
payload := strings.NewReader("{\n \"email\": \"first_name@trysela.com\",\n \"phone_number\": \"+18042221111\",\n \"metadata\": {\n \"first_name\": \"First\",\n \"last_name\": \"Name\",\n \"timezone\": \"America/New_York\",\n \"property_address\": \"123 Main St\",\n \"property_city\": \"Richmond\",\n \"property_state\": \"Virginia\",\n \"property_zip\": \"23219\",\n \"address\": \"456 2nd St\",\n \"city\": \"Norfolk\",\n \"state\": \"Virginia\",\n \"zip\": \"23510\"\n },\n \"external_id\": \"id_in_your_crm_123\",\n \"lead_source\": \"USDALoans.com\",\n \"lead_type\": 123,\n \"representative\": 456,\n \"us_state\": \"VA\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trysela.com/api/leads/upsert/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"first_name@trysela.com\",\n \"phone_number\": \"+18042221111\",\n \"metadata\": {\n \"first_name\": \"First\",\n \"last_name\": \"Name\",\n \"timezone\": \"America/New_York\",\n \"property_address\": \"123 Main St\",\n \"property_city\": \"Richmond\",\n \"property_state\": \"Virginia\",\n \"property_zip\": \"23219\",\n \"address\": \"456 2nd St\",\n \"city\": \"Norfolk\",\n \"state\": \"Virginia\",\n \"zip\": \"23510\"\n },\n \"external_id\": \"id_in_your_crm_123\",\n \"lead_source\": \"USDALoans.com\",\n \"lead_type\": 123,\n \"representative\": 456,\n \"us_state\": \"VA\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trysela.com/api/leads/upsert/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"first_name@trysela.com\",\n \"phone_number\": \"+18042221111\",\n \"metadata\": {\n \"first_name\": \"First\",\n \"last_name\": \"Name\",\n \"timezone\": \"America/New_York\",\n \"property_address\": \"123 Main St\",\n \"property_city\": \"Richmond\",\n \"property_state\": \"Virginia\",\n \"property_zip\": \"23219\",\n \"address\": \"456 2nd St\",\n \"city\": \"Norfolk\",\n \"state\": \"Virginia\",\n \"zip\": \"23510\"\n },\n \"external_id\": \"id_in_your_crm_123\",\n \"lead_source\": \"USDALoans.com\",\n \"lead_type\": 123,\n \"representative\": 456,\n \"us_state\": \"VA\"\n}"
response = http.request(request)
puts response.read_body{
"id": 28013,
"email": "first_name@trysela.com",
"phone_number": "+18042221111",
"metadata": {
"phone_number": "+18042221111",
"email": "first_name@trysela.com",
"first_name": "First",
"last_name": "Name",
"timezone": "America/New_York",
"created_at": "02/28/2025 15:09",
"property_address": "123 Main St",
"property_city": "Richmond",
"property_state": "Virginia",
"property_zip": "23219",
"address": "456 2nd St",
"city": "Norfolk",
"state": "Virginia",
"zip": "23510",
"lead_source": "USDALoans.com",
"external_id": "id_in_your_crm_123"
},
"modified_time": "2025-02-28T15:09:03.139554-05:00",
"created_time": "2025-02-28T15:09:03.122515-05:00",
"status": "OPEN",
"status_reason": null,
"lead_source": "USDALoans.com",
"lead_type": 123,
"representative": 456,
"next_call_time": "2025-02-28T15:09:03.122515-05:00",
"next_call_time_reason": "FIRST_CALL",
"external_id": "id_in_your_crm_123",
"us_state": "VA",
"received_time": "2025-02-28T15:09:03.122515-05:00",
"reengagements_count": 0,
"last_reengagement_time": null,
"call_schedule_start_time": null,
"sms_dnc": false,
"call_dnc": false
}Create or Update a Lead
Finds an existing lead by external_id, or by phone_number and/or email the same way as PUT /api/leads/update/, and updates it with the request fields. If no lead matches, a new lead is created with the same rules as POST /api/leads/, so phone_number is required in that case. At least one of external_id, phone_number, or email is required.
curl --request POST \
--url https://api.trysela.com/api/leads/upsert/ \
--header 'Authorization: Token <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"email": "first_name@trysela.com",
"phone_number": "+18042221111",
"metadata": {
"first_name": "First",
"last_name": "Name",
"timezone": "America/New_York",
"property_address": "123 Main St",
"property_city": "Richmond",
"property_state": "Virginia",
"property_zip": "23219",
"address": "456 2nd St",
"city": "Norfolk",
"state": "Virginia",
"zip": "23510"
},
"external_id": "id_in_your_crm_123",
"lead_source": "USDALoans.com",
"lead_type": 123,
"representative": 456,
"us_state": "VA"
}'import requests
url = "https://api.trysela.com/api/leads/upsert/"
payload = {
"email": "first_name@trysela.com",
"phone_number": "+18042221111",
"metadata": {
"first_name": "First",
"last_name": "Name",
"timezone": "America/New_York",
"property_address": "123 Main St",
"property_city": "Richmond",
"property_state": "Virginia",
"property_zip": "23219",
"address": "456 2nd St",
"city": "Norfolk",
"state": "Virginia",
"zip": "23510"
},
"external_id": "id_in_your_crm_123",
"lead_source": "USDALoans.com",
"lead_type": 123,
"representative": 456,
"us_state": "VA"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email: 'first_name@trysela.com',
phone_number: '+18042221111',
metadata: {
first_name: 'First',
last_name: 'Name',
timezone: 'America/New_York',
property_address: '123 Main St',
property_city: 'Richmond',
property_state: 'Virginia',
property_zip: '23219',
address: '456 2nd St',
city: 'Norfolk',
state: 'Virginia',
zip: '23510'
},
external_id: 'id_in_your_crm_123',
lead_source: 'USDALoans.com',
lead_type: 123,
representative: 456,
us_state: 'VA'
})
};
fetch('https://api.trysela.com/api/leads/upsert/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trysela.com/api/leads/upsert/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => 'first_name@trysela.com',
'phone_number' => '+18042221111',
'metadata' => [
'first_name' => 'First',
'last_name' => 'Name',
'timezone' => 'America/New_York',
'property_address' => '123 Main St',
'property_city' => 'Richmond',
'property_state' => 'Virginia',
'property_zip' => '23219',
'address' => '456 2nd St',
'city' => 'Norfolk',
'state' => 'Virginia',
'zip' => '23510'
],
'external_id' => 'id_in_your_crm_123',
'lead_source' => 'USDALoans.com',
'lead_type' => 123,
'representative' => 456,
'us_state' => 'VA'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trysela.com/api/leads/upsert/"
payload := strings.NewReader("{\n \"email\": \"first_name@trysela.com\",\n \"phone_number\": \"+18042221111\",\n \"metadata\": {\n \"first_name\": \"First\",\n \"last_name\": \"Name\",\n \"timezone\": \"America/New_York\",\n \"property_address\": \"123 Main St\",\n \"property_city\": \"Richmond\",\n \"property_state\": \"Virginia\",\n \"property_zip\": \"23219\",\n \"address\": \"456 2nd St\",\n \"city\": \"Norfolk\",\n \"state\": \"Virginia\",\n \"zip\": \"23510\"\n },\n \"external_id\": \"id_in_your_crm_123\",\n \"lead_source\": \"USDALoans.com\",\n \"lead_type\": 123,\n \"representative\": 456,\n \"us_state\": \"VA\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trysela.com/api/leads/upsert/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"first_name@trysela.com\",\n \"phone_number\": \"+18042221111\",\n \"metadata\": {\n \"first_name\": \"First\",\n \"last_name\": \"Name\",\n \"timezone\": \"America/New_York\",\n \"property_address\": \"123 Main St\",\n \"property_city\": \"Richmond\",\n \"property_state\": \"Virginia\",\n \"property_zip\": \"23219\",\n \"address\": \"456 2nd St\",\n \"city\": \"Norfolk\",\n \"state\": \"Virginia\",\n \"zip\": \"23510\"\n },\n \"external_id\": \"id_in_your_crm_123\",\n \"lead_source\": \"USDALoans.com\",\n \"lead_type\": 123,\n \"representative\": 456,\n \"us_state\": \"VA\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trysela.com/api/leads/upsert/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"first_name@trysela.com\",\n \"phone_number\": \"+18042221111\",\n \"metadata\": {\n \"first_name\": \"First\",\n \"last_name\": \"Name\",\n \"timezone\": \"America/New_York\",\n \"property_address\": \"123 Main St\",\n \"property_city\": \"Richmond\",\n \"property_state\": \"Virginia\",\n \"property_zip\": \"23219\",\n \"address\": \"456 2nd St\",\n \"city\": \"Norfolk\",\n \"state\": \"Virginia\",\n \"zip\": \"23510\"\n },\n \"external_id\": \"id_in_your_crm_123\",\n \"lead_source\": \"USDALoans.com\",\n \"lead_type\": 123,\n \"representative\": 456,\n \"us_state\": \"VA\"\n}"
response = http.request(request)
puts response.read_body{
"id": 28013,
"email": "first_name@trysela.com",
"phone_number": "+18042221111",
"metadata": {
"phone_number": "+18042221111",
"email": "first_name@trysela.com",
"first_name": "First",
"last_name": "Name",
"timezone": "America/New_York",
"created_at": "02/28/2025 15:09",
"property_address": "123 Main St",
"property_city": "Richmond",
"property_state": "Virginia",
"property_zip": "23219",
"address": "456 2nd St",
"city": "Norfolk",
"state": "Virginia",
"zip": "23510",
"lead_source": "USDALoans.com",
"external_id": "id_in_your_crm_123"
},
"modified_time": "2025-02-28T15:09:03.139554-05:00",
"created_time": "2025-02-28T15:09:03.122515-05:00",
"status": "OPEN",
"status_reason": null,
"lead_source": "USDALoans.com",
"lead_type": 123,
"representative": 456,
"next_call_time": "2025-02-28T15:09:03.122515-05:00",
"next_call_time_reason": "FIRST_CALL",
"external_id": "id_in_your_crm_123",
"us_state": "VA",
"received_time": "2025-02-28T15:09:03.122515-05:00",
"reengagements_count": 0,
"last_reengagement_time": null,
"call_schedule_start_time": null,
"sms_dnc": false,
"call_dnc": false
}Authorizations
Body
Any additional information associated with the lead as json metadata. Any of the values supplied here can be used by the agent in the talk track. Any additional payload fields that are not part of the standard lead fields will be automatically stored in the metadata upon lead creation or update, so lead metadata can also be sent as additional keys in the payload. Common fields to include in the metadata are first_name and last_name.
The status of the lead. This is updated automatically.
UNKNOWN- UnknownNEW- NewOPEN- OpenCALLBACK_TO_TRANSFER- Callback to transferCLOSED- ClosedCLOSED_INCOMPLETE- Closed incompleteLOST- LostSCHEDULE_COMPLETED- Schedule completedOUT_OF_TERRITORY- Out of territoryBAD_NUMBER- Bad numberCANCELLED- Cancelled
UNKNOWN, NEW, OPEN, CALLBACK_TO_TRANSFER, CLOSED, CLOSED_INCOMPLETE, LOST, SCHEDULE_COMPLETED, OUT_OF_TERRITORY, BAD_NUMBER, CANCELLED Sub-type of the status outcome (e.g. blind_transfer, warm_transfer, appointment_booked). This is updated automatically.
blind_transfer- Blind transferwarm_transfer- Warm transferappointment_booked- Appointment bookedlive_handoff_unavailable- Live handoff unavailableescalation- Escalationhas_call_dnc- Has call DNCtcpa_litigator- TCPA litigatorblocked_number- Blocked numberLEAD_ASSIGNED- Lead assignedapplication_link_sms- Application link SMS
blind_transfer, warm_transfer, appointment_booked, live_handoff_unavailable, escalation, has_call_dnc, tcpa_litigator, blocked_number, LEAD_ASSIGNED, application_link_sms The US state of the lead. This is used to determine the timezone of the lead, as well as for compliance with telemarketing regulations.
AL- AlabamaAK- AlaskaAS- American SamoaAZ- ArizonaAR- ArkansasAA- Armed Forces AmericasAE- Armed Forces EuropeAP- Armed Forces PacificCA- CaliforniaCO- ColoradoCT- ConnecticutDE- DelawareDC- District of ColumbiaFL- FloridaGA- GeorgiaGU- GuamHI- HawaiiID- IdahoIL- IllinoisIN- IndianaIA- IowaKS- KansasKY- KentuckyLA- LouisianaME- MaineMD- MarylandMA- MassachusettsMI- MichiganMN- MinnesotaMS- MississippiMO- MissouriMT- MontanaNE- NebraskaNV- NevadaNH- New HampshireNJ- New JerseyNM- New MexicoNY- New YorkNC- North CarolinaND- North DakotaMP- Northern Mariana IslandsOH- OhioOK- OklahomaOR- OregonPA- PennsylvaniaPR- Puerto RicoRI- Rhode IslandSC- South CarolinaSD- South DakotaTN- TennesseeTX- TexasUT- UtahVT- VermontVI- Virgin IslandsVA- VirginiaWA- WashingtonWV- West VirginiaWI- WisconsinWY- Wyoming
AL, AK, AS, AZ, AR, AA, AE, AP, CA, CO, CT, DE, DC, FL, GA, GU, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, MP, OH, OK, OR, PA, PR, RI, SC, SD, TN, TX, UT, VT, VI, VA, WA, WV, WI, WY Response
An existing lead was updated.
Any additional information associated with the lead as json metadata. Any of the values supplied here can be used by the agent in the talk track. Any additional payload fields that are not part of the standard lead fields will be automatically stored in the metadata upon lead creation or update, so lead metadata can also be sent as additional keys in the payload. Common fields to include in the metadata are first_name and last_name.
The status of the lead. This is updated automatically.
UNKNOWN- UnknownNEW- NewOPEN- OpenCALLBACK_TO_TRANSFER- Callback to transferCLOSED- ClosedCLOSED_INCOMPLETE- Closed incompleteLOST- LostSCHEDULE_COMPLETED- Schedule completedOUT_OF_TERRITORY- Out of territoryBAD_NUMBER- Bad numberCANCELLED- Cancelled
UNKNOWN, NEW, OPEN, CALLBACK_TO_TRANSFER, CLOSED, CLOSED_INCOMPLETE, LOST, SCHEDULE_COMPLETED, OUT_OF_TERRITORY, BAD_NUMBER, CANCELLED Sub-type of the status outcome (e.g. blind_transfer, warm_transfer, appointment_booked). This is updated automatically.
blind_transfer- Blind transferwarm_transfer- Warm transferappointment_booked- Appointment bookedlive_handoff_unavailable- Live handoff unavailableescalation- Escalationhas_call_dnc- Has call DNCtcpa_litigator- TCPA litigatorblocked_number- Blocked numberLEAD_ASSIGNED- Lead assignedapplication_link_sms- Application link SMS
blind_transfer, warm_transfer, appointment_booked, live_handoff_unavailable, escalation, has_call_dnc, tcpa_litigator, blocked_number, LEAD_ASSIGNED, application_link_sms The reason for the current status of the lead. This is updated automatically.
UNKNOWN- UnknownWEBHOOK- WebhookMANUAL- ManualCHAT- ChatREENGAGEMENT- Reengagement
UNKNOWN, WEBHOOK, MANUAL, CHAT, REENGAGEMENT The US state of the lead. This is used to determine the timezone of the lead, as well as for compliance with telemarketing regulations.
AL- AlabamaAK- AlaskaAS- American SamoaAZ- ArizonaAR- ArkansasAA- Armed Forces AmericasAE- Armed Forces EuropeAP- Armed Forces PacificCA- CaliforniaCO- ColoradoCT- ConnecticutDE- DelawareDC- District of ColumbiaFL- FloridaGA- GeorgiaGU- GuamHI- HawaiiID- IdahoIL- IllinoisIN- IndianaIA- IowaKS- KansasKY- KentuckyLA- LouisianaME- MaineMD- MarylandMA- MassachusettsMI- MichiganMN- MinnesotaMS- MississippiMO- MissouriMT- MontanaNE- NebraskaNV- NevadaNH- New HampshireNJ- New JerseyNM- New MexicoNY- New YorkNC- North CarolinaND- North DakotaMP- Northern Mariana IslandsOH- OhioOK- OklahomaOR- OregonPA- PennsylvaniaPR- Puerto RicoRI- Rhode IslandSC- South CarolinaSD- South DakotaTN- TennesseeTX- TexasUT- UtahVT- VermontVI- Virgin IslandsVA- VirginiaWA- WashingtonWV- West VirginiaWI- WisconsinWY- Wyoming
AL, AK, AS, AZ, AR, AA, AE, AP, CA, CO, CT, DE, DC, FL, GA, GU, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, MP, OH, OK, OR, PA, PR, RI, SC, SD, TN, TX, UT, VT, VI, VA, WA, WV, WI, WY