curl --request POST \
--url https://api.lava.so/v1/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reference_id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"phone": "+14155552671",
"metadata": {
"tier": "premium",
"source": "api"
}
}
'import requests
url = "https://api.lava.so/v1/customers"
payload = {
"reference_id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"phone": "+14155552671",
"metadata": {
"tier": "premium",
"source": "api"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
reference_id: 'usr_abc123',
name: 'Jane Smith',
email: 'jane@example.com',
phone: '+14155552671',
metadata: {tier: 'premium', source: 'api'}
})
};
fetch('https://api.lava.so/v1/customers', 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.lava.so/v1/customers",
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([
'reference_id' => 'usr_abc123',
'name' => 'Jane Smith',
'email' => 'jane@example.com',
'phone' => '+14155552671',
'metadata' => [
'tier' => 'premium',
'source' => 'api'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.lava.so/v1/customers"
payload := strings.NewReader("{\n \"reference_id\": \"usr_abc123\",\n \"name\": \"Jane Smith\",\n \"email\": \"jane@example.com\",\n \"phone\": \"+14155552671\",\n \"metadata\": {\n \"tier\": \"premium\",\n \"source\": \"api\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.lava.so/v1/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reference_id\": \"usr_abc123\",\n \"name\": \"Jane Smith\",\n \"email\": \"jane@example.com\",\n \"phone\": \"+14155552671\",\n \"metadata\": {\n \"tier\": \"premium\",\n \"source\": \"api\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reference_id\": \"usr_abc123\",\n \"name\": \"Jane Smith\",\n \"email\": \"jane@example.com\",\n \"phone\": \"+14155552671\",\n \"metadata\": {\n \"tier\": \"premium\",\n \"source\": \"api\"\n }\n}"
response = http.request(request)
puts response.read_body{
"customer_id": "con_test_01EXAMPLE00000000000000001",
"reference_id": "usr_abc123",
"contact": {
"phone": "+14155552671",
"email": "user@example.com",
"first_name": "Jane",
"last_name": "Smith"
},
"subscription": {
"subscription_id": "<string>",
"plan_id": "<string>",
"name": "<string>",
"status": "active"
},
"metadata": {
"plan_tier": "enterprise",
"internal_id": "12345"
},
"created_at": "2023-05-15T08:35:42Z"
}{
"error": {
"message": "Invalid authentication credentials",
"code": "forward_token_json_invalid",
"status": 400,
"issues": [
{
"path": [
"model"
],
"message": "Missing required field: model"
},
{
"path": [
"messages",
"0",
"content"
],
"message": "Invalid message content format"
}
]
}
}Create customer
Create a customer record with merchant-scoped contact info. The customer can be assigned free plans and use the proxy immediately. To link a payment method, direct them through checkout. Idempotent when reference_id is provided (strongly recommended) — returns the existing customer if one matches.
curl --request POST \
--url https://api.lava.so/v1/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reference_id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"phone": "+14155552671",
"metadata": {
"tier": "premium",
"source": "api"
}
}
'import requests
url = "https://api.lava.so/v1/customers"
payload = {
"reference_id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"phone": "+14155552671",
"metadata": {
"tier": "premium",
"source": "api"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
reference_id: 'usr_abc123',
name: 'Jane Smith',
email: 'jane@example.com',
phone: '+14155552671',
metadata: {tier: 'premium', source: 'api'}
})
};
fetch('https://api.lava.so/v1/customers', 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.lava.so/v1/customers",
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([
'reference_id' => 'usr_abc123',
'name' => 'Jane Smith',
'email' => 'jane@example.com',
'phone' => '+14155552671',
'metadata' => [
'tier' => 'premium',
'source' => 'api'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.lava.so/v1/customers"
payload := strings.NewReader("{\n \"reference_id\": \"usr_abc123\",\n \"name\": \"Jane Smith\",\n \"email\": \"jane@example.com\",\n \"phone\": \"+14155552671\",\n \"metadata\": {\n \"tier\": \"premium\",\n \"source\": \"api\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.lava.so/v1/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reference_id\": \"usr_abc123\",\n \"name\": \"Jane Smith\",\n \"email\": \"jane@example.com\",\n \"phone\": \"+14155552671\",\n \"metadata\": {\n \"tier\": \"premium\",\n \"source\": \"api\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reference_id\": \"usr_abc123\",\n \"name\": \"Jane Smith\",\n \"email\": \"jane@example.com\",\n \"phone\": \"+14155552671\",\n \"metadata\": {\n \"tier\": \"premium\",\n \"source\": \"api\"\n }\n}"
response = http.request(request)
puts response.read_body{
"customer_id": "con_test_01EXAMPLE00000000000000001",
"reference_id": "usr_abc123",
"contact": {
"phone": "+14155552671",
"email": "user@example.com",
"first_name": "Jane",
"last_name": "Smith"
},
"subscription": {
"subscription_id": "<string>",
"plan_id": "<string>",
"name": "<string>",
"status": "active"
},
"metadata": {
"plan_tier": "enterprise",
"internal_id": "12345"
},
"created_at": "2023-05-15T08:35:42Z"
}{
"error": {
"message": "Invalid authentication credentials",
"code": "forward_token_json_invalid",
"status": 400,
"issues": [
{
"path": [
"model"
],
"message": "Missing required field: model"
},
{
"path": [
"messages",
"0",
"content"
],
"message": "Invalid message content format"
}
]
}
}Authorizations
Bearer token authentication used for standard API calls. Format: 'Bearer YOUR_API_KEY'
Body
Your external identifier for this customer (strongly recommended). When provided, acts as an idempotency key — creating a customer with the same reference_id returns the existing one. Cannot start with "con_" (reserved prefix). Can be used interchangeably with customer_id in all API endpoints.
255"usr_abc123"
Display name. Used as contact hint until the customer authenticates.
255"Jane Smith"
Email address. Used as contact hint and for checkout pre-population.
"jane@example.com"
Phone number in E.164 format. Used as contact hint and for checkout pre-population.
"+14155552671"
Arbitrary key-value metadata (max 16KB serialized).
{ "tier": "premium", "source": "api" }
Response
Customer created
Unique identifier for the customer
"con_test_01EXAMPLE00000000000000001"
Merchant's external identifier for this customer. Used for idempotent creation — POST with the same reference_id returns the existing customer.
"usr_abc123"
Show child attributes
Show child attributes
Active subscription summary, or null if none
Show child attributes
Show child attributes
Arbitrary key-value metadata stored on the customer. Set via PATCH.
{
"plan_tier": "enterprise",
"internal_id": "12345"
}
ISO 8601 timestamp when the customer was created
"2023-05-15T08:35:42Z"