Skip to main content
POST
Create a customer
Creates a new customer (receptor de facturas) for the organization.
This endpoint takes no organizationId in the URL. Authenticate with either a Supabase Bearer session (send the X-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; any X-Organization-Id header sent alongside an API key is ignored).

Authentication

Accepts either:
  • A Supabase Bearer session (Authorization: Bearer <token>) with the X-Organization-Id: <org-id> header — the authenticated user must be a member of that organization.
  • An API key (X-API-Key: sk_...) with the write:customers scope — the organization is resolved from the key itself.

Request Body

Example Request

Example Response

Common Errors

400 Bad Request

Invalid RFC format, missing required fields, invalid ZIP code, or a missing X-Organization-Id header on a session-authenticated request.

Fiscal validation error (CFDI 4.0)

When taxId, 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.
Other examples of fiscal validation errors:
  • "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\""
Use 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 in X-Organization-Id, or the API key does not have the write:customers scope.

Authorizations

X-API-Key
string
header
required

API Key for authentication (format: sk_...)

Headers

X-Organization-Id
string

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"

taxId
string
required

Mexican RFC (tax identifier)

Example:

"ABC101010111"

taxSystem
string
required

SAT tax system code (Régimen Fiscal)

Example:

"601"

email
string
required

Customer email

Example:

"email@example.com"

defaultInvoiceUse
string
required

Default CFDI use code

Example:

"G01"

addressStreet
string
required

Street name

Example:

"Blvd. Atardecer"

addressExterior
string
required

Exterior number

Example:

"142"

addressNeighborhood
string
required

Neighborhood (Colonia)

Example:

"Centro"

addressCity
string
required

City

Example:

"Huatabampo"

addressMunicipality
string
required

Municipality

Example:

"Huatabampo"

addressZip
string
required

ZIP code

Example:

"86500"

addressState
string
required

State

Example:

"Sonora"

phone
string

Customer phone number

Example:

"6474010101"

addressInterior
string

Interior number

Example:

"4"

addressCountry
string
default:MEX

Country code

Example:

"MEX"

Response

id
string
required
Example:

"590ce6c56d04f840aa8438af"

organizationId
string
required
Example:

"org-uuid"

Example:

"Dunder Mifflin"

taxId
string
required
Example:

"ABC101010111"

taxSystem
string
required
Example:

"601"

email
string
required
Example:

"email@example.com"

defaultInvoiceUse
string
required
Example:

"G01"

address
object
required
createdAt
string<date-time>
required
updatedAt
string<date-time>
required
phone
object
Example:

"6474010101"