Create a customer
POST
https://api.ledgerline.dev /v2/customers Creates a new customer object.
Request body application/x-www-form-urlencoded
emailstringCustomer's email address.
namestringThe customer's full name or business name.
phonestringThe customer's phone number.
metadataobjectSet of key-value pairs.
{
"email": "string",
"name": "string",
"phone": "string",
"metadata": {}
}Code samples
cURL
curl -X POST "https://api.ledgerline.dev/v2/customers" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d '{"email":"string","name":"string","phone":"string","metadata":{}}'TypeScript
const res = await fetch('https://api.ledgerline.dev/v2/customers', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify({"email":"string","name":"string","phone":"string","metadata":{}}),
});
const data = await res.json();Python
import requests
res = requests.request(
"POST",
"https://api.ledgerline.dev/v2/customers",
headers={
"Content-Type": "application/x-www-form-urlencoded",
},
json={"email": "string", "name": "string", "phone": "string", "metadata": {}},
)
data = res.json()Go
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, _ := http.NewRequest("POST", "https://api.ledgerline.dev/v2/customers", strings.NewReader(`{"email":"string","name":"string","phone":"string","metadata":{}}`))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.ledgerline.dev/v2/customers');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"email":"string","name":"string","phone":"string","metadata":{}}');
$response = curl_exec($ch);
curl_close($ch);
echo $response;Ruby
require 'net/http'
require 'uri'
uri = URI('https://api.ledgerline.dev/v2/customers')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = '{"email":"string","name":"string","phone":"string","metadata":{}}'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(req)
end
puts res.bodyJava
import java.net.URI;
import java.net.http.*;
import java.net.http.HttpRequest.BodyPublishers;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ledgerline.dev/v2/customers"))
.header("Content-Type", "application/x-www-form-urlencoded")
.method("POST", BodyPublishers.ofString("{\"email\":\"string\",\"name\":\"string\",\"phone\":\"string\",\"metadata\":{}}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());Responses
200 Returns the object if the request succeeded.
{
"id": "cus_Qm8xT2vLp0aZ",
"object": "customer",
"email": "jenny.rosen@example.com",
"name": "Jenny Rosen",
"balance": 0,
"created": 1791787234,
"metadata": {}
}402 The request was valid but failed (for example, the card was declined).
Updated
Was this page helpful?