> ## Documentation Index
> Fetch the complete documentation index at: https://facturas-sdk.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Register Your ARCA Credentials for Electronic Invoicing

> Generate a private key and CSR with the facturas CLI, register them in ARCA's homologación portal, and save your certificate to start issuing invoices.

Before you can issue any invoice, ARCA must recognize your application as an authorized web service client. That means you need a private key, a certificate that ARCA has signed, and a service authorization that links that certificate to the Facturación Electrónica web service. This guide walks you through every step for the test (homologación) environment, then explains how to repeat the process for production.

<Note>
  **Test and production environments are completely separate.** Each requires its own private key, its own certificate, its own service authorization in ARCA's portal, and its own sales point. A test certificate will not work against production endpoints, and vice versa.
</Note>

<Steps>
  <Step title="Check prerequisites">
    Before you start, confirm you have:

    * A valid **CUIT** (11 digits, e.g. `20123456786`)
    * A **clave fiscal** for that CUIT at level 2 or higher — WSASS (homologación) is not delegable, so you must log in as the natural person holding the CUIT, not a company representative
    * **Node.js 20 or later** installed locally

    You do not need a database, a server, or any infrastructure beyond your local machine to complete this setup.
  </Step>

  <Step title="Generate your private key and CSR">
    Run `npx facturas init` with your CUIT and the target environment. The CLI generates an RSA 2048 private key and the Certificate Signing Request (CSR) with the exact subject format ARCA requires.

    ```bash theme={null}
    npx facturas init --cuit 20123456786 --env test
    ```

    The command:

    * Writes `arca-test.key` (your private key, permissions `0600`) and `arca-test.csr` to the current directory
    * Copies the CSR to your clipboard (on macOS, Linux with `xclip`/`xsel`/`wl-copy`, or Windows) so you can paste it directly into ARCA's form
    * Prints the exact pages, fields, and buttons in ARCA's portal for your chosen environment
    * Prompts you to paste the certificate once ARCA issues it

    If no clipboard tool is available (e.g. an SSH session), the CLI prints the CSR inline for you to copy from the terminal.

    <Warning>
      `arca-test.key` is your private key. Never commit it to version control. The CLI automatically adds `arca-*.key` and `arca-*.crt` to `.gitignore` if a `.gitignore` file exists in the directory.
    </Warning>

    <Accordion title="Available flags for npx facturas init">
      | Flag                       | Default           | Description                                          |
      | -------------------------- | ----------------- | ---------------------------------------------------- |
      | `--cuit <cuit>`            | prompted          | 11-digit CUIT, with or without hyphens               |
      | `--env <test\|production>` | prompted          | Target environment                                   |
      | `--name <alias>`           | `facturas`        | Common name for the CSR (the alias in ARCA's portal) |
      | `--org <name>`             | CUIT              | Organization field in the CSR                        |
      | `--dir <path>`             | current directory | Where to write the generated files                   |
      | `--force`                  | —                 | Overwrite existing files                             |
      | `--no-clipboard`           | —                 | Print the CSR instead of copying it                  |
      | `--no-paste`               | —                 | Skip the certificate prompt at the end               |
    </Accordion>
  </Step>

  <Step title="Log in to ARCA's WSASS portal">
    WSASS is ARCA's homologación certificate manager. It runs as a separate application from the main AFIP portal and handles only test-environment credentials.

    1. Go to [auth.afip.gob.ar](https://auth.afip.gob.ar/contribuyente_/login.xhtml) and log in with your clave fiscal.
    2. In **Mis Servicios**, open **WSASS — Autogestión Certificados Homologación**.
       * If it doesn't appear, add it first: **Administrador de Relaciones** → **Adherir Servicio** → ARCA → **Servicios Interactivos** → WSASS → confirm, then log out and back in.
    3. In the WSASS menu, click **Nuevo Certificado**. The form has three fields:
       * **Nombre simbólico del DN** — the alias for this certificate (e.g. `facturasTest`)
       * **CUIT del contribuyente** — pre-filled, do not edit
       * **Solicitud de certificado en formato PKCS10** — paste your CSR here, including the `-----BEGIN CERTIFICATE REQUEST-----` and `-----END CERTIFICATE REQUEST-----` lines
    4. Click **Crear DN y Obtener Certificado**.
  </Step>

  <Step title="Copy your certificate">
    After clicking the button, the signed certificate appears **in the result box on that same page** — there is no download. Copy the entire PEM block from `-----BEGIN CERTIFICATE-----` to `-----END CERTIFICATE-----`, inclusive.

    <Note>
      **Do not close the page** until you have copied the certificate. WSASS does not offer a way to retrieve it again after you navigate away. If you do close it, you will need to create a new certificate entry.
    </Note>

    If the `npx facturas init` prompt is still open in your terminal, paste the certificate there. The CLI verifies that it matches your private key and CUIT, saves it as `arca-test.crt`, and tells you the expiry date:

    ```text theme={null}
    > -----BEGIN CERTIFICATE-----
    ...
    -----END CERTIFICATE-----
    ✓ arca-test.crt     certificate saved, expires 2027-09-07
    ```
  </Step>

  <Step title="Save the certificate if you exited init">
    If you closed the `init` prompt before pasting the certificate, run:

    ```bash theme={null}
    npx facturas cert
    ```

    Paste the PEM block when prompted. `cert` finds the matching `arca-test.key` automatically, verifies the certificate against it, and saves `arca-test.crt`. It also works non-interactively for scripts:

    ```bash theme={null}
    npx facturas cert < certificate.pem
    ```
  </Step>

  <Step title="Authorize the wsfe service">
    Back in the WSASS portal, go to **Crear autorización a servicio** in the menu:

    * **Nombre simbólico del DN a autorizar** — the alias you used in step 3 (e.g. `facturasTest`)
    * **CUIT representado** — your CUIT (or the CUIT you are operating on behalf of)
    * **Servicio al que desea acceder** — select `wsfe - Facturación Electrónica`

    Click **Crear Autorización de Acceso**. ARCA links your certificate to the WSFE service. This authorization step is what lets the SDK authenticate with WSAA.
  </Step>

  <Step title="Verify all layers">
    Run `npx facturas check` from the directory containing your `arca-test.crt` and `arca-test.key` files. The CLI finds them automatically and tests every layer in order:

    ```bash theme={null}
    npx facturas check
    ```

    A passing result looks like this:

    ```text theme={null}
    ✓ configuración       arca-test.crt in this directory, CUIT 20123456786 from certificate
    ✓ certificado y clave  match, expires 2027-09-07
    ✓ WSAA                ticket obtained
    ✓ WSFE                server ok
    ✓ puntos de venta     1 reported
      3 (enabled, CAE)
    ```

    If any layer fails, the CLI names it and tells you exactly which ARCA page to visit to fix it.

    <Tip>
      `npx facturas check` pinpoints exactly which layer fails — configuration, certificate parsing, WSAA authentication, WSFE connectivity, or sales point registration — without touching ARCA's write endpoints. Run it any time you change credentials or get an unexpected authentication error.
    </Tip>

    <Accordion title="What each layer checks">
      | Layer                 | What is tested                                                                               |
      | --------------------- | -------------------------------------------------------------------------------------------- |
      | `configuración`       | Resolves flags, environment variables, and local files; validates the CUIT format            |
      | `certificado y clave` | Parses both PEMs, verifies the private key matches the certificate, reads the expiry date    |
      | `WSAA`                | Authenticates with WSAA for the `wsfe` service; reuses a cached ticket if one is still valid |
      | `WSFE`                | Calls `getServerStatus()` then `getSalesPoints()`                                            |
      | `puntos de venta`     | Lists enabled sales points; checks a specific one if you pass `--sales-point`                |
    </Accordion>
  </Step>

  <Step title="Set up a sales point">
    `npx facturas check` reports which sales points are enabled. If none are, you need to create one in ARCA's portal under **Administración de Puntos de Venta y Domicilios** → **Nuevo**. Choose the system that matches your fiscal condition:

    | Condition             | Sales point system                                   |
    | --------------------- | ---------------------------------------------------- |
    | Responsable inscripto | `RECE para aplicativo y Web Services`                |
    | Monotributo           | `Factura Electrónica – Monotributo – Web Services`   |
    | Exento en IVA         | `Factura Electrónica – Exento en IVA – Web Services` |

    Do not use **Comprobantes en línea** — that is a separate system and does not work with the web services API.
  </Step>
</Steps>

## Going to production

Repeat every step above with `--env production`. The production certificate flow uses a different portal section:

1. In **Mis Servicios**, open **Administración de Certificados Digitales** (add it via **Administrador de Relaciones** → **Nueva Relación** → **Servicios Interactivos** if needed).
2. Click **Agregar alias**, enter an alias (e.g. `facturasProduction`), and upload `arca-production.csr`.
3. In the listing, click **Ver** → the download icon to get the certificate file. Save it as `arca-production.crt`, or open it and paste the text into `npx facturas cert`.
4. Go to **Administrador de Relaciones** → **Nueva Relación**. Under **Servicio**, search for **Facturación Electrónica** (within Webservices). Under **Representante**, select the `facturasProduction` alias you just created. Confirm twice.

Then run `npx facturas check --env production` to verify. Once it passes, set `ARCA_ENVIRONMENT=production` in your deployment environment.

<Warning>
  A test invoice in production is a **real fiscal document** registered with ARCA. Even a 1-peso smoke test (`items: [{ amount: 100 }]`) creates a permanent record. Only switch to `production` after your homologación flow is fully validated.
</Warning>

## Official ARCA references

<Accordion title="Links to ARCA's official documentation">
  * [Electronic invoicing documentation index](https://www.arca.gob.ar/ws/documentacion/ws-factura-electronica.asp)
  * [WSAA documentation](https://www.afip.gob.ar/ws/documentacion/wsaa.asp)
  * [Test/homologación certificates](https://www.afip.gob.ar/ws/documentacion/certificados.asp)
  * [WSAA developer manual (PDF)](https://www.afip.gob.ar/ws/WSAA/WSAAmanualDev.pdf)
  * [WSASS setup guide (PDF)](https://www.afip.gob.ar/ws/WSASS/WSASS_como_adherirse.pdf)
  * [WSASS user manual](https://www.arca.gob.ar/ws/WSASS/html/index.html)
  * [Production certificate generation (PDF)](https://www.afip.gob.ar/ws/WSAA/WSAA.ObtenerCertificado.pdf)
  * [Web service delegation guide (PDF)](https://www.afip.gob.ar/ws/WSAA/ADMINREL.DelegarWS.pdf)
  * [WSFE developer manual (PDF)](https://www.afip.gob.ar/ws/documentacion/manuales/manual-desarrollador-ARCA-COMPG.pdf)
</Accordion>

Once `npx facturas check` passes for your target environment, you're ready to issue invoices. Head to the [Quick Start](quickstart) guide to write your first `arca.issue()` call.
