The `crdca` CLI exposes four commands and no more: `enroll`, `sign`, `renew` and `instance`. There is no
`verify` command and no alias. Every command accepts `--json`; without it, it prints one line per fact,
and with it, an object with `ok`, `comando` and the data.
```bash
pip install crdca
crdca --version
# crdca 1.0.0
```
The private key is read from `--clave <path>`, `--clave -` (standard input), `--clave-env <VAR>` or
`CRDCA_CLAVE` (path or PEM). It is not printed, not written and not sent in any request. `--nueva-clave`
generates an ephemeral key in memory for that invocation.

## enroll
Opens the ACME account, creates or takes the key and requests the profile order.
```bash
crdca enroll --card-url <url> [--perfil agentcard|delegator] [--nueva-clave]
             [--publicar-token <token>] --servidor <directory> [--clave ...] [--json]
```
`--card-url` is the exact URL and becomes the SAN URI; `--perfil` accepts `agentcard` or `delegator`;
`--publicar-token` publishes the card-01 token and completes issuance; `--servidor` is also read from
`CRDCA_SERVIDOR`.
```bash
crdca enroll \
  --card-url https://example.com/agents/invoices/agent-card.json \
  --clave clave.pem --servidor https://acme.crdca.org/directory
```
Expected output with the challenge unresolved:
```bash
# alta: https://example.com/agents/invoices/agent-card.json
# perfil: agentcard
# cuenta: https://acme.crdca.org/account/7Q2
# orden: https://acme.crdca.org/order/9f3 (pending)
# finalize: pendiente de validación
# clave: operador
# csr: 288 bytes
```
With `--publicar-token` the order completes and the chain arrives in `certificado` when you use
`--json`; normal output adds `token` and `certificado`.

## sign
Signs the card with a detached JWS over JCS. The inclusion proof goes in `crdca_inclusion` inside the
protected header.
```bash
crdca sign --card <path> --cadena <path> [--inclusion <b64url>] [--log <url>]
           [--clave ...] [--json]
```
`--card` is the JSON card; `--cadena` the PEM chain with leaf and intermediate; `--inclusion` the proof
you already have; `--log` requests the proof from `GET <log>/inclusion/<sha256>`.
```bash
crdca sign --card agent-card.json --cadena cadena.pem --clave clave.pem \
  --log https://cdn.crdca.org
```
Expected output:
```bash
# firma: EdDSA sobre JCS(card sin signatures)
# kid: 33Jexv_GITRJ9XRmMLK5Y3n6uXWt80mbWv-YTDu0fgg
# inclusión: crdca_inclusion en el encabezado protegido; en payload 0
# tarjeta: 1 firma(s), 2140 bytes
```
With `--json`, the signed card travels in the `tarjeta` key. The client writes no files.

## renew
Queries ARI and decides whether it is time to renew. Without `--ari` the command exits with `E_USO`.
```bash
crdca renew --ari --cert <path> --servidor <directory> [--ahora <ISO8601>] [--clave ...] [--json]
```
```bash
crdca renew --ari --cert hoja.pem --clave clave.pem \
  --servidor https://acme.crdca.org/directory
```
Expected output once half life has passed:
```bash
# ari: <certID>
# edad: 320000 s · vida 604800 s · media vida 302400 s
# ventana: 2026-11-18T00:00:00Z → 2026-11-20T00:00:00Z
# retry-after: 3600 s
# decisión: renueva
# orden: https://acme.crdca.org/order/ab12 (replaces <certID>)
```
Before half life, `decisión` is `espera` and no order is requested. `--ahora` is a test clock, not a
production option.

## instance
Issues one JWT credential per replica and verifies it before returning it.
```bash
crdca instance --replicas <n> --card-url <url> --cadena <path> [--vida-s <s>]
               [--jwt] [--ahora <ISO8601>] [--clave ...] [--json]
```
`--replicas` defaults to 1; `--vida-s` has a maximum of 86400 s; `--jwt` prints each replica's token;
`--card-url` is the class AgentID.
```bash
crdca instance --replicas 2 --card-url https://example.com/agents/invoices/agent-card.json \
  --cadena cadena.pem --clave clave.pem --jwt
```
Expected output:
```bash
# instancia: 2 credenciales · vida 86400 s · verificadas 2
# réplica r1: sub https://example.com/agents/invoices/agent-card.json#r1 exp 1798761600
# réplica r2: sub https://example.com/agents/invoices/agent-card.json#r2 exp 1798761600
# jwt r1: eyJhbGciOiJFZERTQSIsImtpZCI6...
# jwt r2: eyJhbGciOiJFZERTQSIsImtpZCI6...
```

## Exit codes
| Code | Name | When |
| --- | --- | --- |
| 0 | `OK` | command completed |
| 2 | `E_USO` | missing argument, unknown profile or `renew` without `--ari` |
| 3 | `E_ENTRADA` | unreadable file, card that is not JSON or invalid URL |
| 4 | `E_SERVIDOR` | the ACME directory or the order fails |
| 5 | `E_INCLUSION` | no proof and no log to provide one |
| 6 | `E_CADENA` | chain with fewer than two certificates or unexpected material |
| 7 | `E_FIRMA` | the JWS or JCS cannot be built |
| 8 | `E_INSTANCIA` | replicas or lifetime outside the profile |
| 9 | `E_CLAVE` | missing key or PEM that is not Ed25519 PKCS#8 |
| 1 | `E_INTERNO` | unclassified error |
A script tells the failure family by the code. Messages go to standard error as `crdca: E_CLAVE: ...`.

## Next step
The CLI does not verify cards: that decision lives in the middleware run by whoever receives the call.
See [Verify a card](/en/use/verify) for the nine steps and the `R01` to `R15` codes.
