Skip to content

Create Customer

Required scope: customer:create

customFields is keyed by the DataField name returned by ListDataFields. HeyX stores canonical DataField IDs internally, but this public endpoint deliberately accepts and returns names for compatibility. Unknown names are preserved.

Set isProspect to make a prospect: a customer that has not bought yet. It enters by a run of the workspace’s create prospect flow, like the flow’s own prospects, and can carry where it came from (prospectSourceId, from List Prospect Sources) and the opt-in the person answered on your own form (prospectOptIn, with the statement and terms link they read). Both need isProspect.

A prospect’s email address or phone number that already belongs to a customer or prospect makes no second record. When the API key may edit that record, it gets a new prospect next to its others and comes back with created: false and 200 OK; its title and fields are left as they are (use Patch Customer Data Fields to change them). When the key may not edit it, the request is refused with already_exists (409) and nothing is created. Follow a customer’s prospects with List Customer Prospects. This operation is not idempotent.

Generated Reference
POST /public-api/publicapi.v1.Customer/CreateCustomer

Creates a customer, or a prospect with is_prospect, from the supplied fields. A prospect's email address or phone number that belongs to an existing customer or prospect the API key may edit makes no new record: that record gets a new prospect and is returned with created false, its fields left unchanged (use PatchCustomerDataFields); one the key may not edit is refused (409). Contacts are not a public API resource. This operation is not idempotent.

Request CreateCustomerRequest
Response CreateCustomerResponse

CreateCustomerRequest

Field Type Description
title string
custom_fields map<string, string> Keys are DataField names from ListDataFields. The public API maps these to canonical internal IDs and continues returning names for compatibility.
expected_close_date optional int64
customer_name optional string
email optional string
phone optional string Accepts an international number or a local number when phone_country is set.
phone_country optional string ISO 3166-1 alpha-2 country code used to normalize a local phone number.
is_prospect bool Make the record a prospect: a customer that has not bought yet. It enters by a run of the workspace's create prospect flow, as the flow's own prospects do.
prospect_source_id optional string Where the prospect comes from: an active source from ListProspectSources. Only with is_prospect.
prospect_opt_in ProspectOptInInput The opt-in the person answered on your own form. Only with is_prospect.
prospect_fields map<string, string> The new prospect's own data fields (ListDataFields with entity_type "prospect"), keyed by data field name like custom_fields. Only with is_prospect. They are stored on the prospect this call opens, also when the contact details belong to an existing customer, whose own fields stay as they are.

CreateCustomerResponse

Field Type Description
customer Customer
created bool False when the contact details matched an existing record, which got the new prospect instead.
prospect_id string The prospect the request opened; empty without is_prospect.
{
"title": "Solar installation lead",
"customerName": "Alex Jansen",
"email": "[email protected]",
"phone": "0612345678",
"phoneCountry": "NL",
"customFields": {
"lead_source": "website"
}
}
Terminal window
curl https://portal.heyx.app/public-api/publicapi.v1.Customer/CreateCustomer \
-H "Authorization: Bearer hx_sk_..." \
-H "Content-Type: application/json" \
-d '{
"title": "Solar installation lead",
"customerName": "Alex Jansen",
"email": "[email protected]",
"phone": "0612345678",
"phoneCountry": "NL",
"customFields": {
"lead_source": "website"
}
}'

Successful requests return 201 Created with the created customer.

{
"customer": {
"id": "be85f4d1-b680-4964-bf62-9828fdf4ce04",
"title": "Solar installation lead",
"customFields": {
"customer_name": "Alex Jansen",
"email": "[email protected]"
},
"referenceNumber": "P-000456",
"kind": "customer"
},
"created": true
}
{
"title": "Alex Jansen",
"email": "[email protected]",
"phone": "+31612345678",
"isProspect": true,
"prospectSourceId": "a6d3c1f0-2b8e-4f7a-9c11-5e4d3b2a1f00",
"prospectOptIn": {
"agreed": true,
"statement": "Yes, keep me posted about offers from Example Solar.",
"termsUrl": "https://example.com/privacy"
},
"customFields": {
"lead_source": "website"
}
}
{
"customer": {
"id": "be85f4d1-b680-4964-bf62-9828fdf4ce04",
"title": "Alex Jansen",
"kind": "prospect",
"contactAttemptCount": 0
},
"created": true,
"prospectId": "5b2e0c9a-6d1f-4a3b-8e7c-2f9a1b0c3d4e"
}
CodeHTTPWhen
invalid_request400A field is invalid, the phone number cannot be read, prospectSourceId is unknown or archived, or prospect details come without isProspect
already_exists409A prospect’s contact details belong to a record the API key may not edit
failed_precondition412A prospect’s contact details belong to a customer on hold (the message names the reason)