Skip to main content

Registering and validating customers

Registering your customers in Facturapi allows you to validate their tax information and store it for future invoices.

This step is optional, as it is not necessary to have previously registered your customer in order to create invoices. However, we recommend doing it whenever possible.

Once your customer is registered, you can save the id of the created object and use it to invoice the same recipient without having to send all their tax information again.

When creating an invoice, you can include the recipient's information in 2 different ways:

  1. In the customer field, by sending an object with the customer's tax information.
  2. In the customer field, by sending the id of a previously registered customer.

Both options are valid, and we recommend using the one that best suits your use case.

How to register a customer

In Facturapi, the process of registering the tax information of national and foreign customers is not very different from each other, but it is worth analyzing them separately, as it is different from what the SAT indicates in its technical standard.

National customers (Mexico)

The following example shows how to register a national customer, that is, a customer (person or company) with a Mexican tax ID (RFC).

To learn about other data you can include, refer to the Create Customer API reference.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const customer = await facturapi.customers.create({
legal_name: 'Dunder Mifflin', // Person's name or business legal name
tax_id: 'ABC101010111', // RFC
tax_system: '601', // Fiscal regime
email: 'email@example.com', // Email for sending (optional).
address: {
zip: '85900', // Postal code
}
});
Respuesta: Customer object
{
"id": "590ce6c56d04f840aa8438af",
"created_at": "2017-05-05T20:55:33.468Z",
"organization": "622a33e6f0175a00e01a8e80",
"livemode": false,
"legal_name": "Dunder Mifflin",
"tax_id": "ABC101010111",
"tax_system": "601",
"email": "email@example.com",
"phone": 6474010101,
"address": {
"street": null,
"exterior": null,
"interior": null,
"neighborhood": null,
"city": "Huatabampo",
"municipality": "Huatabampo",
"zip": 86500,
"state": "Sonora",
"country": "MEX"
}
}

Foreign customers

To register a foreign customer, it is necessary to specify the country of origin by sending the ISO country code of the origin country using the country field.

caution

You don't need to use the generic RFC for foreigners from SAT. We will take care of it for you wherever necessary, as long as you send a value other than "MEX" for the country field.

To learn about other data you can include, refer to the Create Customer API reference.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const customer = await facturapi.customers.create({
legal_name: 'Vättenfall, A.B.', // Person's name or business legal name
tax_id: '198912171234', // Tax identification number (optional)
email: 'email@example.com', // Email for sending (optional).
address: {
country: "SWE", // ISO country code.
zip: "17123", // Postal code
city: "Stockholm" // City (optional).
}
});
Respuesta: Customer object
{
"id": "62714bc2d1bfa410df1d98eb",
"created_at": "2022-05-03T15:35:30.034Z",
"organization": "622a33e6f0175a00e01a8e80",
"livemode": false,
"legal_name": "Vättenfall, A.B.",
"tax_id": "198912171234",
"email": "email@example.com",
"address": {
"country": "SWE",
"zip": "17123",
"city": "Stockholm"
},
}