> ## 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.

# Issue Invoices with Line-Item Detail via WSMTXCA

> Use { service: 'wsmtxca' } to send full line-item detail to ARCA's WSMTXCA service. Learn item fields, monetary precision, and how totals must reconcile.

WSMTXCA is ARCA's alternative CAE service for electronic invoices. Unlike WSFE — which only carries fiscal header totals — WSMTXCA transmits the full breakdown of every line item with each voucher. Use it when you need ARCA to register individual products, services, quantities, and per-item VAT alongside the authorisation code.

The `facturas` SDK covers WSMTXCA with exactly the same high-level methods as WSFE: `issue()`, `issueCreditNote()`, `issueDebitNote()`, `preview()`, `previewCreditNote()`, and `previewDebitNote()`. You never build SOAP arrays manually — the SDK handles both encodings.

## Opt in per call

Pass `{ service: "wsmtxca" }` as the second argument to any issuance or preview method. The SDK never switches services automatically — not after a rejection, not after a timeout, and not based on invoice content.

```typescript theme={null}
import { createArcaClient } from "facturas";

const arca = createArcaClient();

const result = await arca.issue(input, { service: "wsmtxca" });
```

Without a `service` option, or with `{ service: "wsfe" }`, the call goes to WSFE. The TypeScript return type narrows to the chosen service: with `{ service: "wsmtxca" }`, `result.request` and `result.sent` carry WSMTXCA-specific types without any casts.

## The `details` array

Add a `details` array to your input to supply line-item breakdown. Each element represents one line on the invoice.

<ParamField body="description" type="string" required>
  Human-readable description of the product or service.
</ParamField>

<ParamField body="quantity" type="number" required>
  Quantity of units.
</ParamField>

<ParamField body="unit" type="number" required>
  ARCA unit-of-measure code (e.g. `7` for units).
</ParamField>

<ParamField body="unitPrice" type="string" required>
  Unit price as a **decimal string in major currency units** with up to six decimal places (e.g. `"100.000000"`). This is the only monetary field in the SDK that is not an integer number of centavos.
</ParamField>

<ParamField body="vatCondition" type="number" required>
  ARCA VAT condition code for this item (e.g. `5` for 21%).
</ParamField>

<ParamField body="vatAmount" type="number">
  VAT amount for this item in integer centavos. Required for Class A invoices.
</ParamField>

<ParamField body="amount" type="number" required>
  Total line amount **including VAT**, in integer centavos.
</ParamField>

<ParamField body="discount" type="number">
  Optional discount amount in integer centavos.
</ParamField>

<ParamField body="code" type="string">
  Optional product or service code.
</ParamField>

<ParamField body="matrixCode" type="string">
  Optional ARCA matrix code.
</ParamField>

<ParamField body="matrixUnits" type="number">
  Optional matrix unit quantity.
</ParamField>

<Note>
  `unitPrice` is the only monetary exception in the SDK. Every other amount — `vatAmount`, `amount`, `discount`, header totals — is an **integer in centavos**. `unitPrice` is a decimal string in major units (e.g. pesos) to preserve the vendor's full price precision, which can have up to six decimal places.
</Note>

## Totals must reconcile

Item `amount` values include VAT. The sum of your `details` items must reconcile with the fiscal header totals you supply through the `items` or `amounts` fields — the same fields WSFE uses. The `details` array adds line-item detail to the voucher; it does not replace the fiscal breakdown.

## Full example

```typescript theme={null}
import { createArcaClient } from "facturas";
import type { IssueInput } from "facturas";

const arca = createArcaClient();

const input = {
  issuer: "responsable_inscripto",
  salesPoint: 1,
  to: { condition: "responsable_inscripto", cuit: "20123456789" },
  // Fiscal header — same structure as WSFE.
  items: [{ net: 10_000, vat: 21 }],
  // Line-item detail for WSMTXCA.
  details: [
    {
      description: "Product",
      quantity: 1,
      unit: 7,
      unitPrice: "100.000000",  // Decimal string, major units (pesos).
      vatCondition: 5,           // VAT condition code for 21%.
      vatAmount: 2100,           // Integer centavos: ARS 21.00.
      amount: 12_100,            // Total including VAT, integer centavos.
    },
  ],
} satisfies IssueInput;

const result = await arca.issue(input, {
  service: "wsmtxca",
  idempotencyKey: "order:abc-123",
});

if (result.kind === "authorized") {
  console.log("CAE:", result.voucher.cae);
  console.log("Voucher number:", result.voucher.number);
}
```

## Previewing a WSMTXCA request

Call `preview()` with `{ service: "wsmtxca" }` to inspect the full WSMTXCA request the SDK would send, without reserving a voucher number or contacting ARCA:

```typescript theme={null}
const preview = arca.preview(input, { service: "wsmtxca" });

// Inspect the WSMTXCA-specific request structure.
const total = preview.request.comprobanteCAERequest.importeTotal;
console.log("Total:", total);
```

To capture the exact request that was sent on a successful authorization, pass `include: { exactInput: true }` to `issue()`. The `result.sent` field will contain the WSMTXCA request object.

## FCE invoices

Electronic credit invoices (FCE) work the same way across both WSFE and WSMTXCA. Supply `fce: { cbu, alias?, transfer?, reference? }` on the invoice and `fce: { annulment, reference? }` on the credit note — the SDK translates the fields to the correct encoding for each service:

| Field       | WSFE encoding                 | WSMTXCA encoding                        |
| ----------- | ----------------------------- | --------------------------------------- |
| CBU / alias | Optional fields 2101 and 2102 | Additional data 21 (combined `c1`/`c2`) |
| Annulment   | Optional field 22             | Additional data 22                      |
| Transfer    | Optional field 27             | Additional data 27                      |

Do not duplicate these entries through `optionalFields` when you are already using the `fce` option — the SDK populates them automatically.

## Idempotency and retries

WSMTXCA reservations are stored as `v: 2` records in your store and always carry the provider name. A reservation written by a WSMTXCA call cannot be replayed through WSFE — this prevents a rollback to an older SDK version from silently re-sending an itemized invoice as a header-only WSFE voucher.

On a retry, WSMTXCA evidence verification compares the full line-item detail, not just the header total. If the lookup returns incomplete evidence, the result is `indeterminate` and nothing is re-sent.

For direct access to the lower-level `client.wsmtxca` methods — `issue()`, `getLastAuthorizedVoucher()`, `getVoucher()` — see the [Exact Layer](/reference/exact-layer) reference.
