# efw2.validate

Check a tax-year 2026 SSA, Maryland or Pennsylvania EFW2 file against the published format and reconcile its count and money totals. Price per employee-state, based on complete fixed-width records with an employee identity.

- REST: `POST https://api.kanagu.dev/v1/efw2/validate`
- MCP: `call_operation` with `operation: "efw2.validate"` at https://api.kanagu.dev/mcp
- Price: $0.15 USD per employee-state, on successful calls only.
- Auth: `Authorization: Bearer <key>` for REST and `call_operation`. Retries: reuse `Idempotency-Key` (MCP: `idempotencyKey`).

## Compliance coverage

- Domain: Finance & accounting
- Jurisdictions: US
- Standard: SSA Publication 42-007 Tax year 2026, version 4 (2026-11-12) — https://www.ssa.gov/employer/efw/26efw2.pdf
- Standard: Maryland Employer Reporting of W-2s Instructions and Specifications Tax year 2026, version 1.0 (2026-09-27) — https://www.marylandcomptroller.gov/content/dam/mdcomp/tax/instructions/2026/reporting-w2-instructions.pdf
- Standard: Pennsylvania myPATH W-2 Wage Records (EFW2) Undated web specification, snapshot 2026-11-26 (2026-11-26) — https://www.pa.gov/agencies/revenue/resources/mypath/multi-import/employer-withholding-file-upload-specs/pa-w-2-wage-records-efw2
- Standard: 26 CFR § 1.224-1(h), Table 1 TD 10044 (2026-04-13) — https://www.govinfo.gov/content/pkg/FR-2026-04-13/pdf/2026-07104.pdf
- Verification: efw2.generate checks generated files and efw2.validate checks submitted files locally against published fixed-width, sequence, field and total rules.
- Last reviewed: 2026-11-26

## Request body

- `destination` ("SSA" | "MD" | "PA")
- `text` (string (max 2100000 chars), required)

## Response

- `status` ("pass" | "invalid" | "needs_review", required)
- `findings` (array of object, required)
- `findings[].severity` ("error" | "needs_review", required)
- `findings[].destination` ("SSA" | "MD" | "PA", required)
- `findings[].rule` (string, required)
- `findings[].line` (integer (≤ 9007199254740991))
- `findings[].column` (integer (≤ 9007199254740991))
- `findings[].input` (string)
- `findings[].field` (string, required)
- `findings[].expected` (string, required)
- `findings[].actual` (string, required)
- `findings[].source` (string (uri), required)
- `billableEmployeeStates` (integer (0 to 9007199254740991), required)
- `verification` (object, required)
- `verification.method` ("published_specification", required)
- `verification.agencyPortal` ("not_run", required)
- `verification.standards` (array of object, required)
- `verification.standards[].name` (string, required)
- `verification.standards[].version` (string, required)
- `verification.standards[].date` (string (date), required)
- `verification.standards[].url` (string (uri), required)
- `recordCount` (integer (0 to 9007199254740991), required)
- `employerCount` (integer (0 to 9007199254740991), required)
- `employeeCount` (integer (0 to 9007199254740991), required)
- `stateRecordCount` (integer (0 to 9007199254740991), required)
- `omittedFindings` (integer (0 to 9007199254740991), required)

## Example

```sh
curl https://api.kanagu.dev/v1/efw2/validate \
  -H "Authorization: Bearer $KANAGU_KEY" \
  -H "Content-Type: application/json" \
  -d '{"destination":"SSA","text":"RA"}'
```

```ts
const res = await fetch("https://api.kanagu.dev/v1/efw2/validate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KANAGU_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "destination": "SSA",
    "text": "RA"
  }),
});
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.
- 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": {
    "destination": {
      "default": "SSA",
      "type": "string",
      "enum": [
        "SSA",
        "MD",
        "PA"
      ]
    },
    "text": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2100000
    }
  },
  "required": [
    "text"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "destination": "SSA",
      "text": "RA"
    }
  ]
}
```

Response:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "pass",
        "invalid",
        "needs_review"
      ]
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "severity": {
            "type": "string",
            "enum": [
              "error",
              "needs_review"
            ]
          },
          "destination": {
            "type": "string",
            "enum": [
              "SSA",
              "MD",
              "PA"
            ]
          },
          "rule": {
            "type": "string"
          },
          "line": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "column": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "input": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "expected": {
            "type": "string"
          },
          "actual": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "severity",
          "destination",
          "rule",
          "field",
          "expected",
          "actual",
          "source"
        ],
        "additionalProperties": false
      }
    },
    "billableEmployeeStates": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "verification": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "const": "published_specification"
        },
        "agencyPortal": {
          "type": "string",
          "const": "not_run"
        },
        "standards": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              },
              "date": {
                "type": "string",
                "format": "date",
                "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])))$"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "name",
              "version",
              "date",
              "url"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "method",
        "agencyPortal",
        "standards"
      ],
      "additionalProperties": false
    },
    "recordCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "employerCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "employeeCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "stateRecordCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "omittedFindings": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "status",
    "findings",
    "billableEmployeeStates",
    "verification",
    "recordCount",
    "employerCount",
    "employeeCount",
    "stateRecordCount",
    "omittedFindings"
  ],
  "additionalProperties": false
}
```
