# frereporting.validate

Check DGFiP v3.2 Flux 10 XML against the published XSD and reporting rules. The minimum charge covers 100 reported rows.

- REST: `POST https://api.kanagu.dev/v1/frereporting/validate`
- MCP tool: `frereporting.validate` at https://api.kanagu.dev/mcp
- Price: $0.10 USD per 100 lines, on successful calls only. Trial: 10 calls per IP per UTC day without a key, shared by REST and MCP.
- Auth: `Authorization: Bearer <key>` for billed calls. Retries: reuse `Idempotency-Key`.

## Request body

- `xml` (string (max 1048576 chars), required)
- `vatRegime` ("normal_monthly" | "normal_quarterly" | "simplified" | "franchise")
- `vatOnDebits` (boolean): Whether the seller opted for VAT on debits.
- `checkedAt` (string): Control clock in France local time. Defaults to the current time.

## Response

- `valid` (boolean, required): Whether the XML passed the applicable local XSD and business-rule checks. Review flags identify discrepancies or checks that need additional information.
- `specification` (object, required)
- `specification.version` ("3.2", required)
- `specification.date` ("2026-04-30", required)
- `specification.url` ("https://www.impots.gouv.fr/specifications-externes-b2b", required)
- `lineCount` (integer (0 to 9007199254740991), required): Submitted transaction or receipt rows used for pricing, at $0.10 per started block of 100.
- `issues` (array of object, required)
- `issues[].severity` ("error" | "needs_review", required)
- `issues[].rule` (string, required)
- `issues[].section` (string, required)
- `issues[].path` (string, required)
- `issues[].expected` (string, required)
- `issues[].actual` (string, required)
- `issues[].line` (integer (≤ 9007199254740991))
- `issues[].sourceRows` (array of integer (0 to 9007199254740991))

## Example

```sh
curl https://api.kanagu.dev/v1/frereporting/validate \
  -H "Authorization: Bearer $KANAGU_KEY" \
  -H "Content-Type: application/json" \
  -d '{"xml":"<?xml version=\"1.0\"?><Report/>","vatRegime":"normal_monthly"}'
```

```ts
const res = await fetch("https://api.kanagu.dev/v1/frereporting/validate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KANAGU_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "xml": "<?xml version=\"1.0\"?><Report/>",
    "vatRegime": "normal_monthly"
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();
```

## Errors

JSON `{"error":{"code","message"}}`.

- 400 `invalid_input`: The body does not match the request schema. The message names each field.
- 400 `invalid_json`: The body is missing or is not valid JSON.
- 400 `invalid_idempotency_key`: Idempotency-Key must be 1–128 visible ASCII characters.
- 401 `invalid_api_key`: The Bearer key is missing, malformed, invalid or inactive.
- 402 `free_allowance_exhausted`: This month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left.
- 404 `not_found`: No operation at this path.
- 409 `idempotency_conflict`: The Idempotency-Key was already used with a different body.
- 413 `payload_too_large`: JSON bodies may be at most 64 KiB.
- 429 `trial_limit`: The anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left.
- 500 `internal_error`: The call failed on our side. It is not billed; retry with the same Idempotency-Key.

## JSON Schema

Request:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "xml": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1048576
    },
    "vatRegime": {
      "type": "string",
      "enum": [
        "normal_monthly",
        "normal_quarterly",
        "simplified",
        "franchise"
      ]
    },
    "vatOnDebits": {
      "description": "Whether the seller opted for VAT on debits.",
      "type": "boolean"
    },
    "checkedAt": {
      "description": "Control clock in France local time. Defaults to the current time.",
      "type": "string",
      "allOf": [
        {
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:Z)|(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d)$"
        },
        {
          "pattern": "^20\\d{2}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d$"
        }
      ]
    }
  },
  "required": [
    "xml"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "xml": "<?xml version=\"1.0\"?><Report/>",
      "vatRegime": "normal_monthly"
    }
  ]
}
```

Response:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "valid": {
      "type": "boolean",
      "description": "Whether the XML passed the applicable local XSD and business-rule checks. Review flags identify discrepancies or checks that need additional information."
    },
    "specification": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string",
          "const": "3.2"
        },
        "date": {
          "type": "string",
          "const": "2026-04-30"
        },
        "url": {
          "type": "string",
          "const": "https://www.impots.gouv.fr/specifications-externes-b2b"
        }
      },
      "required": [
        "version",
        "date",
        "url"
      ],
      "additionalProperties": false
    },
    "lineCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "Submitted transaction or receipt rows used for pricing, at $0.10 per started block of 100."
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "severity": {
            "type": "string",
            "enum": [
              "error",
              "needs_review"
            ]
          },
          "rule": {
            "type": "string"
          },
          "section": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "expected": {
            "type": "string"
          },
          "actual": {
            "type": "string"
          },
          "line": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "sourceRows": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        },
        "required": [
          "severity",
          "rule",
          "section",
          "path",
          "expected",
          "actual"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "valid",
    "specification",
    "lineCount",
    "issues"
  ],
  "additionalProperties": false
}
```
