# Customer tax data

> Check a customer's RFC, name, regime, postal code and CFDI use before stamping, or send them a link so they give it themselves with their constancia.

Almost every SAT rejection comes from the customer's data: a name with «S.A. de C.V.», a postal code that isn't the one on their constancia, a regime that doesn't apply to them. There are two ways to have them right before stamping.

## Check the data you already have

`POST /v1/tax_ids/validate` checks the data without stamping (only comparing it with the constancia at SAT uses timbres, [below](#compare-them-with-the-constancia)), and tells you what's wrong and what value to correct it with:

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/tax_ids/validate \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tax_id": "EKU9003173C9", "legal_name": "Escuela Kemper Urgate, S.A. de C.V.", "tax_system": "601", "zip": "42501", "use": "G03" }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const taxIdValidation = await fiscalisto.taxIds.validate({
  tax_id: "EKU9003173C9",
  legal_name: "Escuela Kemper Urgate, S.A. de C.V.",
  tax_system: "601",
  zip: "42501",
  use: "G03",
});
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

tax_id_validation = fiscalisto.tax_ids.validate({
    "tax_id": "EKU9003173C9",
    "legal_name": "Escuela Kemper Urgate, S.A. de C.V.",
    "tax_system": "601",
    "zip": "42501",
    "use": "G03",
})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$taxIdValidation = $fiscalisto->taxIds->validate([
    'tax_id' => 'EKU9003173C9',
    'legal_name' => 'Escuela Kemper Urgate, S.A. de C.V.',
    'tax_system' => '601',
    'zip' => '42501',
    'use' => 'G03',
]);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	taxIDValidation, err := client.TaxIds.Validate(ctx, &fiscalisto.ValidateTaxIdParams{
		TaxID:     "EKU9003173C9",
		LegalName: fiscalisto.String("Escuela Kemper Urgate, S.A. de C.V."),
		TaxSystem: fiscalisto.String("601"),
		Zip:       fiscalisto.String("42501"),
		Use:       fiscalisto.String("G03"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", *taxIDValidation)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.ValidateTaxIdParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var taxIdValidation = fiscalisto.taxIds().validate(new ValidateTaxIdParams()
        .setTaxId("EKU9003173C9")
        .setLegalName("Escuela Kemper Urgate, S.A. de C.V.")
        .setTaxSystem("601")
        .setZip("42501")
        .setUse("G03"));
System.out.println(taxIdValidation);
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var taxIdValidation = await fiscalisto.TaxIds.ValidateAsync(new ValidateTaxIdParams
{
    TaxId = "EKU9003173C9",
    LegalName = "Escuela Kemper Urgate, S.A. de C.V.",
    TaxSystem = "601",
    Zip = "42501",
    Use = "G03",
});
```

```json
{
  "object": "tax_id_validation",
  "tax_id": "EKU9003173C9",
  "kind": "company",
  "valid": false,
  "checked_with_sat": false,
  "errors": [
    {
      "param": "legal_name",
      "code": "legal_name_capital_regime",
      "message": "Sin «S.A. de C.V.»: en CFDI 4.0 el nombre va sin régimen de capital, como en la constancia.",
      "suggestion": "ESCUELA KEMPER URGATE"
    }
  ],
  "warnings": [],
  "sat_record": null,
  "sat_error": null,
  "sat_lists": { "object": "sat_list_check", "listed": false, "risk": "none" }
}
```

On its own, it checks what can be known without asking SAT: the RFC's format and date, the name, that the regime is a company's or an individual's according to the RFC, that the postal code exists, that the CFDI use fits the regime, the generic RFCs and whether the RFC is on [SAT's lists](https://fiscalisto.com/en/docs/api/listas-del-sat) (that comes in `warnings`). Each problem carries `param`, a stable `code` for your code, a `message` to show your user and, when possible, `suggestion` with the right value.

### Compare them with the constancia

If you also send `cif_id`, the idCIF printed on the constancia de situación fiscal (top right, next to the QR code), Fiscalisto queries SAT's record and compares name, postal code and regime with what you sent. Then `checked_with_sat` is `true` and `sat_record` carries what SAT says:

```json
"sat_record": { "legal_name": "ESCUELA KEMPER URGATE", "zip": "42501", "tax_systems": ["601"] }
```

Each query to SAT counts toward the [daily limit](https://fiscalisto.com/en/docs/api/limites) and, in production, every 10 constancias queried in a month use one timbre (the month's first takes one that covers 10; free in test mode). The same constancia queried twice within 24 hours counts once. If SAT is slow or doesn't answer, the check arrives without it, with the reason in `sat_error`, and you can repeat it later.

## Ask the customer for their data

If you don't have the data, or don't trust what you were given, ask for it with a link. Your customer opens it in Fiscalisto, uploads their constancia (or types their data) and before it's accepted it's checked as above. You get a webhook.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/customer_data_requests \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "reference": "Pedido 1042", "description": "Para facturar su pedido 1042", "expires_in_days": 7 }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const customerDataRequest = await fiscalisto.customerDataRequests.create({
  reference: "Pedido 1042",
  description: "Para facturar su pedido 1042",
  expires_in_days: 7,
});
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

customer_data_request = fiscalisto.customer_data_requests.create({
    "reference": "Pedido 1042",
    "description": "Para facturar su pedido 1042",
    "expires_in_days": 7,
})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$customerDataRequest = $fiscalisto->customerDataRequests->create([
    'reference' => 'Pedido 1042',
    'description' => 'Para facturar su pedido 1042',
    'expires_in_days' => 7,
]);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	customerDataRequest, err := client.CustomerDataRequests.Create(ctx, &fiscalisto.CreateCustomerDataRequestParams{
		Reference:     fiscalisto.String("Pedido 1042"),
		Description:   fiscalisto.String("Para facturar su pedido 1042"),
		ExpiresInDays: fiscalisto.Int64(7),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(customerDataRequest.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.CreateCustomerDataRequestParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var customerDataRequest = fiscalisto.customerDataRequests().create(new CreateCustomerDataRequestParams()
        .setReference("Pedido 1042")
        .setDescription("Para facturar su pedido 1042")
        .setExpiresInDays(7));
System.out.println(customerDataRequest.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var customerDataRequest = await fiscalisto.CustomerDataRequests.CreateAsync(new CreateCustomerDataRequestParams
{
    Reference = "Pedido 1042",
    Description = "Para facturar su pedido 1042",
    ExpiresInDays = 7,
});
```

```json
{
  "id": "cdr_…",
  "object": "customer_data_request",
  "status": "open",
  "url": "https://fiscalisto.com/datos/…",
  "reference": "Pedido 1042",
  "expires_at": "2026-10-31T12:00:00-06:00",
  "submission": null
}
```

Send `url` to your customer however you like: in your email, on your order page or by WhatsApp. You can also show it inside your page, with `fiscalisto.js` or `@fiscalisto/react`, like [self-invoicing](https://fiscalisto.com/en/docs/api/autofactura#on-your-page-with-fiscalistojs). `reference` is your customer or order id and `description` a line on what the data is for; the customer sees both above the form, and `reference` comes back to you in the event. The link works for 60 days unless you say otherwise.

When the customer sends their data, the `customer_data_request.completed` event arrives with the full request. `submission` holds the data and `customer`, the issuer's customer (`cus_…`) you can now invoice:

```json
"submission": {
  "tax_id": "PEPJ800101AB1",
  "legal_name": "JUAN PÉREZ LÓPEZ",
  "tax_system": "612",
  "zip": "06600",
  "use": "G03",
  "email": "juan@correo.mx",
  "source": "constancia",
  "customer": "cus_…",
  "applied": true
}
```

A new customer is saved straight into the issuer's catalog (`applied: true`). If the RFC was already one of its customers and the data changes, it isn't overwritten on its own: `applied` is `false` and you decide whether to update it with `POST /v1/customers/{id}`. That way a link can't change who invoices are sent to.

| Route | What it does |
| --- | --- |
| `POST /v1/customer_data_requests` | Creates a link |
| `GET /v1/customer_data_requests` | The issuer's links, newest to oldest |
| `GET /v1/customer_data_requests/{id}` | One link, with what the customer sent |
| `DELETE /v1/customer_data_requests/{id}` | The link stops working (a completed one can't be cancelled) |

`status` is `open`, `completed`, `expired` or `canceled`; `url` only comes while the link is open.
