Create a customer
curl --request POST \
--url https://api.example.com/customers \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"legalName": "Dunder Mifflin",
"taxId": "ABC101010111",
"taxSystem": "601",
"email": "email@example.com",
"defaultInvoiceUse": "G01",
"addressStreet": "Blvd. Atardecer",
"addressExterior": "142",
"addressNeighborhood": "Centro",
"addressCity": "Huatabampo",
"addressMunicipality": "Huatabampo",
"addressZip": "86500",
"addressState": "Sonora",
"phone": "6474010101",
"addressInterior": "4",
"addressCountry": "MEX"
}
'import requests
url = "https://api.example.com/customers"
payload = {
"legalName": "Dunder Mifflin",
"taxId": "ABC101010111",
"taxSystem": "601",
"email": "email@example.com",
"defaultInvoiceUse": "G01",
"addressStreet": "Blvd. Atardecer",
"addressExterior": "142",
"addressNeighborhood": "Centro",
"addressCity": "Huatabampo",
"addressMunicipality": "Huatabampo",
"addressZip": "86500",
"addressState": "Sonora",
"phone": "6474010101",
"addressInterior": "4",
"addressCountry": "MEX"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
legalName: 'Dunder Mifflin',
taxId: 'ABC101010111',
taxSystem: '601',
email: 'email@example.com',
defaultInvoiceUse: 'G01',
addressStreet: 'Blvd. Atardecer',
addressExterior: '142',
addressNeighborhood: 'Centro',
addressCity: 'Huatabampo',
addressMunicipality: 'Huatabampo',
addressZip: '86500',
addressState: 'Sonora',
phone: '6474010101',
addressInterior: '4',
addressCountry: 'MEX'
})
};
fetch('https://api.example.com/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.example.com/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([
'legalName' => 'Dunder Mifflin',
'taxId' => 'ABC101010111',
'taxSystem' => '601',
'email' => 'email@example.com',
'defaultInvoiceUse' => 'G01',
'addressStreet' => 'Blvd. Atardecer',
'addressExterior' => '142',
'addressNeighborhood' => 'Centro',
'addressCity' => 'Huatabampo',
'addressMunicipality' => 'Huatabampo',
'addressZip' => '86500',
'addressState' => 'Sonora',
'phone' => '6474010101',
'addressInterior' => '4',
'addressCountry' => 'MEX'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.example.com/customers"
payload := strings.NewReader("{\n \"legalName\": \"Dunder Mifflin\",\n \"taxId\": \"ABC101010111\",\n \"taxSystem\": \"601\",\n \"email\": \"email@example.com\",\n \"defaultInvoiceUse\": \"G01\",\n \"addressStreet\": \"Blvd. Atardecer\",\n \"addressExterior\": \"142\",\n \"addressNeighborhood\": \"Centro\",\n \"addressCity\": \"Huatabampo\",\n \"addressMunicipality\": \"Huatabampo\",\n \"addressZip\": \"86500\",\n \"addressState\": \"Sonora\",\n \"phone\": \"6474010101\",\n \"addressInterior\": \"4\",\n \"addressCountry\": \"MEX\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<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.example.com/customers")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"legalName\": \"Dunder Mifflin\",\n \"taxId\": \"ABC101010111\",\n \"taxSystem\": \"601\",\n \"email\": \"email@example.com\",\n \"defaultInvoiceUse\": \"G01\",\n \"addressStreet\": \"Blvd. Atardecer\",\n \"addressExterior\": \"142\",\n \"addressNeighborhood\": \"Centro\",\n \"addressCity\": \"Huatabampo\",\n \"addressMunicipality\": \"Huatabampo\",\n \"addressZip\": \"86500\",\n \"addressState\": \"Sonora\",\n \"phone\": \"6474010101\",\n \"addressInterior\": \"4\",\n \"addressCountry\": \"MEX\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"legalName\": \"Dunder Mifflin\",\n \"taxId\": \"ABC101010111\",\n \"taxSystem\": \"601\",\n \"email\": \"email@example.com\",\n \"defaultInvoiceUse\": \"G01\",\n \"addressStreet\": \"Blvd. Atardecer\",\n \"addressExterior\": \"142\",\n \"addressNeighborhood\": \"Centro\",\n \"addressCity\": \"Huatabampo\",\n \"addressMunicipality\": \"Huatabampo\",\n \"addressZip\": \"86500\",\n \"addressState\": \"Sonora\",\n \"phone\": \"6474010101\",\n \"addressInterior\": \"4\",\n \"addressCountry\": \"MEX\"\n}"
response = http.request(request)
puts response.read_body{
"id": "590ce6c56d04f840aa8438af",
"organizationId": "org-uuid",
"legalName": "Dunder Mifflin",
"taxId": "ABC101010111",
"taxSystem": "601",
"email": "email@example.com",
"defaultInvoiceUse": "G01",
"address": {
"street": "Blvd. Atardecer",
"exterior": "142",
"neighborhood": "Centro",
"city": "Huatabampo",
"municipality": "Huatabampo",
"zip": "86500",
"state": "Sonora",
"country": "MEX",
"interior": "4"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"phone": "6474010101"
}Customers
Create Customer
POST
/
customers
Create a customer
curl --request POST \
--url https://api.example.com/customers \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"legalName": "Dunder Mifflin",
"taxId": "ABC101010111",
"taxSystem": "601",
"email": "email@example.com",
"defaultInvoiceUse": "G01",
"addressStreet": "Blvd. Atardecer",
"addressExterior": "142",
"addressNeighborhood": "Centro",
"addressCity": "Huatabampo",
"addressMunicipality": "Huatabampo",
"addressZip": "86500",
"addressState": "Sonora",
"phone": "6474010101",
"addressInterior": "4",
"addressCountry": "MEX"
}
'import requests
url = "https://api.example.com/customers"
payload = {
"legalName": "Dunder Mifflin",
"taxId": "ABC101010111",
"taxSystem": "601",
"email": "email@example.com",
"defaultInvoiceUse": "G01",
"addressStreet": "Blvd. Atardecer",
"addressExterior": "142",
"addressNeighborhood": "Centro",
"addressCity": "Huatabampo",
"addressMunicipality": "Huatabampo",
"addressZip": "86500",
"addressState": "Sonora",
"phone": "6474010101",
"addressInterior": "4",
"addressCountry": "MEX"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
legalName: 'Dunder Mifflin',
taxId: 'ABC101010111',
taxSystem: '601',
email: 'email@example.com',
defaultInvoiceUse: 'G01',
addressStreet: 'Blvd. Atardecer',
addressExterior: '142',
addressNeighborhood: 'Centro',
addressCity: 'Huatabampo',
addressMunicipality: 'Huatabampo',
addressZip: '86500',
addressState: 'Sonora',
phone: '6474010101',
addressInterior: '4',
addressCountry: 'MEX'
})
};
fetch('https://api.example.com/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.example.com/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([
'legalName' => 'Dunder Mifflin',
'taxId' => 'ABC101010111',
'taxSystem' => '601',
'email' => 'email@example.com',
'defaultInvoiceUse' => 'G01',
'addressStreet' => 'Blvd. Atardecer',
'addressExterior' => '142',
'addressNeighborhood' => 'Centro',
'addressCity' => 'Huatabampo',
'addressMunicipality' => 'Huatabampo',
'addressZip' => '86500',
'addressState' => 'Sonora',
'phone' => '6474010101',
'addressInterior' => '4',
'addressCountry' => 'MEX'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.example.com/customers"
payload := strings.NewReader("{\n \"legalName\": \"Dunder Mifflin\",\n \"taxId\": \"ABC101010111\",\n \"taxSystem\": \"601\",\n \"email\": \"email@example.com\",\n \"defaultInvoiceUse\": \"G01\",\n \"addressStreet\": \"Blvd. Atardecer\",\n \"addressExterior\": \"142\",\n \"addressNeighborhood\": \"Centro\",\n \"addressCity\": \"Huatabampo\",\n \"addressMunicipality\": \"Huatabampo\",\n \"addressZip\": \"86500\",\n \"addressState\": \"Sonora\",\n \"phone\": \"6474010101\",\n \"addressInterior\": \"4\",\n \"addressCountry\": \"MEX\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<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.example.com/customers")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"legalName\": \"Dunder Mifflin\",\n \"taxId\": \"ABC101010111\",\n \"taxSystem\": \"601\",\n \"email\": \"email@example.com\",\n \"defaultInvoiceUse\": \"G01\",\n \"addressStreet\": \"Blvd. Atardecer\",\n \"addressExterior\": \"142\",\n \"addressNeighborhood\": \"Centro\",\n \"addressCity\": \"Huatabampo\",\n \"addressMunicipality\": \"Huatabampo\",\n \"addressZip\": \"86500\",\n \"addressState\": \"Sonora\",\n \"phone\": \"6474010101\",\n \"addressInterior\": \"4\",\n \"addressCountry\": \"MEX\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"legalName\": \"Dunder Mifflin\",\n \"taxId\": \"ABC101010111\",\n \"taxSystem\": \"601\",\n \"email\": \"email@example.com\",\n \"defaultInvoiceUse\": \"G01\",\n \"addressStreet\": \"Blvd. Atardecer\",\n \"addressExterior\": \"142\",\n \"addressNeighborhood\": \"Centro\",\n \"addressCity\": \"Huatabampo\",\n \"addressMunicipality\": \"Huatabampo\",\n \"addressZip\": \"86500\",\n \"addressState\": \"Sonora\",\n \"phone\": \"6474010101\",\n \"addressInterior\": \"4\",\n \"addressCountry\": \"MEX\"\n}"
response = http.request(request)
puts response.read_body{
"id": "590ce6c56d04f840aa8438af",
"organizationId": "org-uuid",
"legalName": "Dunder Mifflin",
"taxId": "ABC101010111",
"taxSystem": "601",
"email": "email@example.com",
"defaultInvoiceUse": "G01",
"address": {
"street": "Blvd. Atardecer",
"exterior": "142",
"neighborhood": "Centro",
"city": "Huatabampo",
"municipality": "Huatabampo",
"zip": "86500",
"state": "Sonora",
"country": "MEX",
"interior": "4"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"phone": "6474010101"
}Creates a new customer (receptor de facturas) for the organization.
Other examples of fiscal validation errors:
This endpoint takes noorganizationIdin the URL. Authenticate with either a Supabase Bearer session (send theX-Organization-Id: <org-id>header — the user must be a member of that organization) or an API key (the organization resolves automatically from the key; anyX-Organization-Idheader sent alongside an API key is ignored).
Authentication
Accepts either:- A Supabase Bearer session (
Authorization: Bearer <token>) with theX-Organization-Id: <org-id>header — the authenticated user must be a member of that organization. - An API key (
X-API-Key: sk_...) with thewrite:customersscope — the organization is resolved from the key itself.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
legalName | string | Yes | Legal name (Razón Social) |
taxId | string | Yes | RFC del receptor (e.g. ABC101010111) |
taxSystem | string | Yes | SAT tax system code (Régimen Fiscal, e.g. 601) |
email | string | Yes | Customer email |
defaultInvoiceUse | string | Yes | Default CFDI use code (e.g. G01) |
addressStreet | string | Yes | Street name |
addressExterior | string | Yes | Exterior number |
addressNeighborhood | string | Yes | Neighborhood (Colonia) |
addressCity | string | Yes | City |
addressMunicipality | string | Yes | Municipality |
addressZip | string | Yes | 5-digit ZIP code |
addressState | string | Yes | State |
phone | string | No | Phone number |
addressInterior | string | No | Interior number |
addressCountry | string | No | Country code (default: MEX) |
Example Request
curl -X POST https://api.timbrix.mx/customers \
-H "Authorization: Bearer <your_token>" \
-H "X-Organization-Id: 550e8400-e29b-41d4-a716-446655440000" \
-H "Content-Type: application/json" \
-d '{
"legalName": "Dunder Mifflin",
"taxId": "DUM901231AB3",
"taxSystem": "601",
"email": "billing@dundermifflin.com",
"defaultInvoiceUse": "G01",
"addressStreet": "Blvd. Atardecer",
"addressExterior": "142",
"addressNeighborhood": "Centro",
"addressCity": "Huatabampo",
"addressMunicipality": "Huatabampo",
"addressZip": "86500",
"addressState": "Sonora"
}'
import { Timbrix } from "@timbrix/sdk"
const client = new Timbrix({ bearerToken: "<your_token>" })
const customer = await client.customers.create(
{
legalName: "Dunder Mifflin",
taxId: "DUM901231AB3",
taxSystem: "601",
email: "billing@dundermifflin.com",
defaultInvoiceUse: "G01",
addressStreet: "Blvd. Atardecer",
addressExterior: "142",
addressNeighborhood: "Centro",
addressCity: "Huatabampo",
addressMunicipality: "Huatabampo",
addressZip: "86500",
addressState: "Sonora",
},
"550e8400-e29b-41d4-a716-446655440000"
)
console.log(customer)
Example Response
{
"id": "590ce6c56d04f840aa8438af",
"organizationId": "550e8400-e29b-41d4-a716-446655440000",
"legalName": "Dunder Mifflin",
"taxId": "DUM901231AB3",
"taxSystem": "601",
"email": "billing@dundermifflin.com",
"phone": null,
"defaultInvoiceUse": "G01",
"address": {
"street": "Blvd. Atardecer",
"exterior": "142",
"interior": null,
"neighborhood": "Centro",
"city": "Huatabampo",
"municipality": "Huatabampo",
"zip": "86500",
"state": "Sonora",
"country": "MEX"
},
"createdAt": "2025-01-26T10:00:00Z",
"updatedAt": "2025-01-26T10:00:00Z"
}
Common Errors
400 Bad Request
Invalid RFC format, missing required fields, invalid ZIP code, or a missingX-Organization-Id header on a session-authenticated request.
{
"statusCode": 400,
"message": ["Invalid RFC format", "addressZip must be 5 digits"]
}
Fiscal validation error (CFDI 4.0)
WhentaxId, taxSystem, and defaultInvoiceUse are provided, the API validates that the combination is allowed by SAT CFDI 4.0 rules. RFC length determines persona type: 12 characters = persona moral, 13 characters = persona física. The régimen and uso CFDI must both be valid for that persona type, and the (uso, régimen) pair must exist in the SAT compatibility matrix.
{
"statusCode": 400,
"message": "El uso de CFDI \"D01\" no aplica para persona moral (RFC de 12 caracteres)",
"error": "BAD_REQUEST"
}
"El régimen fiscal \"621\" no aplica para persona moral (RFC de 12 caracteres)""El uso de CFDI \"G01\" no es compatible con el régimen fiscal \"605\""
GET /sat/regimenes-fiscales and GET /sat/usos-cfdi to look up valid codes and compatible combinations before creating a customer.
401 Unauthorized
Missing or invalid Bearer token / API key.403 Forbidden
The authenticated user is not a member of the organization sent inX-Organization-Id, or the API key does not have the write:customers scope.Authorizations
apiKeybearer
API Key for authentication (format: sk_...)
Headers
Required for Supabase session auth. Ignored when authenticating with an API key (the organization resolves from the key).
Body
application/json
Customer legal name (Razón Social)
Example:
"Dunder Mifflin"
Mexican RFC (tax identifier)
Example:
"ABC101010111"
SAT tax system code (Régimen Fiscal)
Example:
"601"
Customer email
Example:
"email@example.com"
Default CFDI use code
Example:
"G01"
Street name
Example:
"Blvd. Atardecer"
Exterior number
Example:
"142"
Neighborhood (Colonia)
Example:
"Centro"
City
Example:
"Huatabampo"
Municipality
Example:
"Huatabampo"
ZIP code
Example:
"86500"
State
Example:
"Sonora"
Customer phone number
Example:
"6474010101"
Interior number
Example:
"4"
Country code
Example:
"MEX"
Response
Example:
"590ce6c56d04f840aa8438af"
Example:
"org-uuid"
Example:
"Dunder Mifflin"
Example:
"ABC101010111"
Example:
"601"
Example:
"email@example.com"
Example:
"G01"
Show child attributes
Show child attributes
Example:
"6474010101"