> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cufea.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Partners

> Provision client companies as tenants with a partner key.

A partner (a reseller that bills its own clients) provisions each client company as a Cufea
tenant of its own: the tenant is the client's NIT and, later, the client's certificate. The
partner acts on the client's **written authorization**, which Cufea stores when the tenant is
created; the partner keeps the signed copy and answers for it. The operator issues the
partner key (`cufea_partner_...`). It works only under `/v1/partner`: it creates no documents,
reads no configuration and no secrets. Everything else is done with the tenant's own keys.

```sh theme={null}
curl -X POST https://api.cufea.com/v1/partner/tenants \
  -H "Authorization: Bearer $CUFEA_PARTNER_KEY" -H "Content-Type: application/json" \
  -d '{
    "nit": "900123456", "check_digit": "8",
    "legal_name": "Ferreteria El Tornillo S.A.S.",
    "contact_email": "contabilidad@eltornillo.co",
    "authorization": {
      "authorized_at": "2026-11-20T15:04:00-05:00",
      "text_version": "fhyra-mandato-fe-v1",
      "evidence_ref": "fhyra:company/8812/consents/31"
    },
    "issue_keys": ["sandbox", "test"]
  }'
```

* **One tenant per NIT and partner.** The call is idempotent by NIT: repeating it with the
  same company data answers `200` with `created: false` and the same `tenant_id`, so a retry
  after a lost answer is safe. Other data for the same NIT answers `409 tenant_nit_conflict`.
* **Keys are shown once.** `api_keys` of the `201` answer carries the plaintext of each key
  asked in `issue_keys` (sandbox and test only: a new tenant is in the DIAN test stage). A
  repeated call issues none; if a key was lost, issue another with
  `POST /v1/partner/tenants/{tenant_id}/api-keys` `{"stage": "test"}` and revoke the old one
  with `DELETE .../api-keys/{key_id}`. A `production` key answers `409 stage_closed` until the
  tenant is promoted.
* **The check digit is checked** with the DIAN modulo-11 rule (`422 tenant_invalid`).
* **The NIT is locked.** The tenant has no issuer yet: set it with the tenant's test key
  (`PUT /v1/tenant/issuer`). Its identification must be that NIT (type `31`, same number);
  another one answers `409 issuer_nit_locked`, and the database refuses it as well.
* **Only your tenants exist for you.** `GET /v1/partner/tenants` lists them (filter with
  `nit`, page with `limit` and `next_cursor`); any other tenant id answers
  `404 tenant_not_found`.
* Every create, authorization and key operation is recorded in the tenant's audit log with
  the partner as the actor.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.