By the end you will have an AgentCard published at its exact URL, a class certificate that binds it to
that URL, and a JWS signature carrying the chain and the log inclusion proof. Nobody asks you for an
account: the identity is your card URL and the proof that you control its key.

## What you need
- A domain with HTTPS and a public path for the card, for example
  `https://example.com/agents/invoices/agent-card.json`.
- Python 3.11 or later and `openssl` available.
- The agent private key in your custody. CRDCA never receives it, never prints it and never writes it.

::: limite
The private key stays on your side. If you use `--nueva-clave`, the CLI generates it in memory for that
one invocation and does not store it: it is good for trying the enrollment, not for signing later. For
the complete walkthrough, supply your own key with `--clave` or from your KMS.
:::

## Step 1: install the CLI
```bash
pip install crdca
crdca --version
# crdca 1.0.0
```

## Step 2: prepare the card and its URL
The card URL is the agent identifier and is copied byte for byte into the certificate. It must be
`https`, with a lowercase host, an absolute path and no `query` or `fragment`. Publish a JSON document
like this at that exact path:
```json
{
  "name": "Invoices",
  "description": "Issues and queries the customer's invoices.",
  "url": "https://example.com/agents/invoices/agent-card.json",
  "version": "1.0.0",
  "capabilities": {"streaming": false},
  "skills": [
    {"id": "invoices", "name": "Invoices", "description": "Issues and queries invoices.", "tags": ["billing"]}
  ]
}
```

## Step 3: create the key and request enrollment
Generate an Ed25519 key in your custody and request the `agentcard` profile order:
```bash
openssl genpkey -algorithm ED25519 -out clave.pem
chmod 600 clave.pem
crdca enroll \
  --card-url https://example.com/agents/invoices/agent-card.json \
  --clave clave.pem \
  --servidor https://acme.crdca.org/directory \
  --json > alta.json
```
The one-shot variant, useful to see how the server responds, generates the key in memory:
```bash
crdca enroll \
  --card-url https://example.com/agents/invoices/agent-card.json \
  --nueva-clave \
  --servidor https://acme.crdca.org/directory
```
The output reports `cuenta`, `orden`, `perfil`, `clave_origen`, the CSR and whether the order is
`finalizado`. Without the challenge resolved, `finalizado` is `false`: enrollment stopped at the order
and there is no certificate yet.

## Step 4: resolve card-01 and collect the chain
CRDCA downloads your card from the SAN URL and checks that the `card-01` extension carries the challenge
token bound to your key fingerprint. The token is the one from your order's `card-01` challenge; your
platform provides it or you read it from the ACME authorization. With it, the CLI publishes the
extension, answers the challenge, finalizes with the CSR and returns the chain:
```bash
crdca enroll \
  --card-url https://example.com/agents/invoices/agent-card.json \
  --clave clave.pem \
  --publicar-token "$TOKEN" \
  --servidor https://acme.crdca.org/directory \
  --json > alta.json
jq -r '.certificado' alta.json > cadena.pem
```
The chain contains the class leaf and the intermediate. The leaf carries a single SAN URI equal to your
`card_url` and the public key from your CSR.

## Step 5: sign the card
The signature is a detached JWS over `JCS(card without signatures)`. The inclusion proof travels in the
protected header, not in the payload. If you do not have the proof at hand, ask the log for it:
```bash
crdca sign \
  --card agent-card.json \
  --cadena cadena.pem \
  --clave clave.pem \
  --log https://cdn.crdca.org \
  --json > firma.json
jq '.tarjeta' firma.json > agent-card.firmada.json
```
The command writes no files: the signed card comes out on standard output inside `tarjeta`. It never
signs with an invented inclusion; without a proof and without a log, the command exits with
`E_INCLUSION`.

## Check the result
The signed card must carry a single signature with `protected` and `signature`. Decode the protected
header to see its five members:
```python
import base64
import json

card = json.load(open("agent-card.firmada.json"))
protected = card["signatures"][0]["protected"]
header = json.loads(base64.urlsafe_b64decode(protected + "=" * (-len(protected) % 4)))
print(sorted(header))
print(header["alg"], header["kid"])
```
You will see `alg` as `EdDSA`, `typ` as `JOSE`, the `kid` computed over the SPKI of `x5c[0]`, and
`crdca_inclusion` with the proof. The payload carries neither the proof nor the challenge token.

## What to do next
- Publish `agent-card.firmada.json` at the same URL you declared. The signed card replaces the one that
  carried the token.
- Renew at half life with `crdca renew --ari`: the `agentcard` profile lives 604800 s and renewal
  happens at 302400 s.
- Issue one credential per replica with `crdca instance --replicas 2 --jwt`.
- See how others will verify you in [Verify a card](/en/use/verify).

## Continue with your language
- [The CLI, command by command](/en/use/cli): flags, output and exit codes.
- [Python](/en/use/python): the four `crdca` functions.
- [TypeScript](/en/use/typescript): `@nexgensys/crdca-sdk` on Node.
- [Go](/en/use/go): the `crdca-go` client with the four operations.
- [The human mandate](/en/use/mandate): how a person authorizes their agent.
