Create Customer
Create a new customer
curl --request POST \
--url https://billing.example.com/v1/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"gstin": "<string>",
"place_of_supply": "<string>",
"tax_exempt": true,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"line1": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
}
}
'import requests
url = "https://billing.example.com/v1/customers"
payload = {
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"gstin": "<string>",
"place_of_supply": "<string>",
"tax_exempt": True,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"line1": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
}
}
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({
email: 'jsmith@example.com',
name: '<string>',
phone: '<string>',
tax_id: '<string>',
gstin: '<string>',
place_of_supply: '<string>',
tax_exempt: true,
tax_exemption_number: '<string>',
tax_exemption_code: '<string>',
tax_exemption_expires_at: '2023-12-25',
line1: '<string>',
city: '<string>',
state: '<string>',
zip: '<string>',
country: '<string>',
billing_address: {
line1: '<string>',
line2: '<string>',
postal_code: '<string>',
city: '<string>',
state: '<string>',
zip: '<string>',
country: '<string>'
}
})
};
fetch('https://billing.example.com/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://billing.example.com/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([
'email' => 'jsmith@example.com',
'name' => '<string>',
'phone' => '<string>',
'tax_id' => '<string>',
'gstin' => '<string>',
'place_of_supply' => '<string>',
'tax_exempt' => true,
'tax_exemption_number' => '<string>',
'tax_exemption_code' => '<string>',
'tax_exemption_expires_at' => '2023-12-25',
'line1' => '<string>',
'city' => '<string>',
'state' => '<string>',
'zip' => '<string>',
'country' => '<string>',
'billing_address' => [
'line1' => '<string>',
'line2' => '<string>',
'postal_code' => '<string>',
'city' => '<string>',
'state' => '<string>',
'zip' => '<string>',
'country' => '<string>'
]
]),
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://billing.example.com/v1/customers"
payload := strings.NewReader("{\n \"email\": \"jsmith@example.com\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"tax_id\": \"<string>\",\n \"gstin\": \"<string>\",\n \"place_of_supply\": \"<string>\",\n \"tax_exempt\": true,\n \"tax_exemption_number\": \"<string>\",\n \"tax_exemption_code\": \"<string>\",\n \"tax_exemption_expires_at\": \"2023-12-25\",\n \"line1\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\",\n \"billing_address\": {\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\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://billing.example.com/v1/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"jsmith@example.com\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"tax_id\": \"<string>\",\n \"gstin\": \"<string>\",\n \"place_of_supply\": \"<string>\",\n \"tax_exempt\": true,\n \"tax_exemption_number\": \"<string>\",\n \"tax_exemption_code\": \"<string>\",\n \"tax_exemption_expires_at\": \"2023-12-25\",\n \"line1\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\",\n \"billing_address\": {\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/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 \"email\": \"jsmith@example.com\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"tax_id\": \"<string>\",\n \"gstin\": \"<string>\",\n \"place_of_supply\": \"<string>\",\n \"tax_exempt\": true,\n \"tax_exemption_number\": \"<string>\",\n \"tax_exemption_code\": \"<string>\",\n \"tax_exemption_expires_at\": \"2023-12-25\",\n \"line1\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\",\n \"billing_address\": {\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"ledger_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"gstin": "<string>",
"tax_type": "<string>",
"place_of_supply": "<string>",
"tax_exempt": true,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"referral_code": "<string>",
"risk_score": 50,
"risk_factors": {},
"card_brand": "<string>",
"card_last4": "<string>",
"card_exp_month": 123,
"card_exp_year": 123,
"card_token_id": "<string>",
"card_fingerprint": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Customer name |
email | string | Yes | Email address |
phone | string | No | Phone number |
gstin | string | No | GST registration number (India) |
address | object | No | Billing address |
metadata | object | No | Custom key-value data |
Address Object
| Parameter | Type | Description |
|---|---|---|
line1 | string | Street address |
line2 | string | Apartment, suite, etc. |
city | string | City |
state | string | State/province |
postal_code | string | ZIP/postal code |
country | string | Two-letter country code |
Example Request
curl -X POST https://api.recurso.dev/v1/customers \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corporation",
"email": "billing@acme.com",
"phone": "+919876543210",
"gstin": "29ABCDE1234F1Z5",
"address": {
"line1": "123 MG Road",
"city": "Bangalore",
"state": "Karnataka",
"postal_code": "560001",
"country": "IN"
}
}'
Response
{
"id": "cust_abc123",
"object": "customer",
"name": "Acme Corporation",
"email": "billing@acme.com",
"phone": "+919876543210",
"gstin": "29ABCDE1234F1Z5",
"address": {
"line1": "123 MG Road",
"city": "Bangalore",
"state": "Karnataka",
"postal_code": "560001",
"country": "IN"
},
"created_at": "2024-01-15T10:30:00Z"
}
Errors
| Status | Code | When | Fix |
|---|---|---|---|
| 400 | validation_failed | The request body is not valid JSON or fails binding. | Send a well-formed JSON body with the required fields. |
| 400 | validation_failed | tax_exemption_expires_at is not a valid date. | Use an ISO 8601 date (e.g. 2027-01-31). |
| 401 | unauthorized | API key missing or invalid (invalid_api_key), or a live/test mode mismatch (key_mode_mismatch). | Send Authorization: Bearer <api_key> with a key for the right mode. |
| 500 | internal_error | The customer could not be persisted. | Retry; if it persists, contact support with the request timestamp. |
Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Body
Indian GST identification number (B2B customers).
business, consumer Indian state code for GST place of supply.
US sales-tax exemption status (D2). When true, the number and code are passed to the tax provider.
Exemption/resale certificate number on file.
Provider entity-use / customer-usage code (e.g. Avalara "A"); also the exemption reason.
Exemption certificate expiry (YYYY-MM-DD). Honored through this date; past it the buyer is charged tax again. Null = no expiry on file (Inc 2).
ISO 3166-1 alpha-2 code.
2Nested address, accepted as an alias for the flat line1/city/state/ zip/country fields. A flat field wins when both are supplied; postal_code and zip are synonyms.
Show child attributes
Show child attributes
Response
Customer created.
Show child attributes
Show child attributes
0 <= x <= 100curl --request POST \
--url https://billing.example.com/v1/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"gstin": "<string>",
"place_of_supply": "<string>",
"tax_exempt": true,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"line1": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
}
}
'import requests
url = "https://billing.example.com/v1/customers"
payload = {
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"gstin": "<string>",
"place_of_supply": "<string>",
"tax_exempt": True,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"line1": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
}
}
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({
email: 'jsmith@example.com',
name: '<string>',
phone: '<string>',
tax_id: '<string>',
gstin: '<string>',
place_of_supply: '<string>',
tax_exempt: true,
tax_exemption_number: '<string>',
tax_exemption_code: '<string>',
tax_exemption_expires_at: '2023-12-25',
line1: '<string>',
city: '<string>',
state: '<string>',
zip: '<string>',
country: '<string>',
billing_address: {
line1: '<string>',
line2: '<string>',
postal_code: '<string>',
city: '<string>',
state: '<string>',
zip: '<string>',
country: '<string>'
}
})
};
fetch('https://billing.example.com/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://billing.example.com/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([
'email' => 'jsmith@example.com',
'name' => '<string>',
'phone' => '<string>',
'tax_id' => '<string>',
'gstin' => '<string>',
'place_of_supply' => '<string>',
'tax_exempt' => true,
'tax_exemption_number' => '<string>',
'tax_exemption_code' => '<string>',
'tax_exemption_expires_at' => '2023-12-25',
'line1' => '<string>',
'city' => '<string>',
'state' => '<string>',
'zip' => '<string>',
'country' => '<string>',
'billing_address' => [
'line1' => '<string>',
'line2' => '<string>',
'postal_code' => '<string>',
'city' => '<string>',
'state' => '<string>',
'zip' => '<string>',
'country' => '<string>'
]
]),
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://billing.example.com/v1/customers"
payload := strings.NewReader("{\n \"email\": \"jsmith@example.com\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"tax_id\": \"<string>\",\n \"gstin\": \"<string>\",\n \"place_of_supply\": \"<string>\",\n \"tax_exempt\": true,\n \"tax_exemption_number\": \"<string>\",\n \"tax_exemption_code\": \"<string>\",\n \"tax_exemption_expires_at\": \"2023-12-25\",\n \"line1\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\",\n \"billing_address\": {\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\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://billing.example.com/v1/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"jsmith@example.com\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"tax_id\": \"<string>\",\n \"gstin\": \"<string>\",\n \"place_of_supply\": \"<string>\",\n \"tax_exempt\": true,\n \"tax_exemption_number\": \"<string>\",\n \"tax_exemption_code\": \"<string>\",\n \"tax_exemption_expires_at\": \"2023-12-25\",\n \"line1\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\",\n \"billing_address\": {\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/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 \"email\": \"jsmith@example.com\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"tax_id\": \"<string>\",\n \"gstin\": \"<string>\",\n \"place_of_supply\": \"<string>\",\n \"tax_exempt\": true,\n \"tax_exemption_number\": \"<string>\",\n \"tax_exemption_code\": \"<string>\",\n \"tax_exemption_expires_at\": \"2023-12-25\",\n \"line1\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\",\n \"billing_address\": {\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"ledger_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"gstin": "<string>",
"tax_type": "<string>",
"place_of_supply": "<string>",
"tax_exempt": true,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"referral_code": "<string>",
"risk_score": 50,
"risk_factors": {},
"card_brand": "<string>",
"card_last4": "<string>",
"card_exp_month": 123,
"card_exp_year": 123,
"card_token_id": "<string>",
"card_fingerprint": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}