{
  "slug": "edi-997-specification",
  "title": "EDI 997 specification: every segment and code, with a live decoder",
  "description": "The complete AK1 through AK9 structure of a Functional Acknowledgment, every error code in every position, and an endpoint that turns one into plain language.",
  "keywords": [
    "edi 997 specification",
    "997 segments",
    "ak1 ak2 ak3 ak4 ak5 ak9",
    "997 error codes",
    "functional acknowledgment format",
    "edi 997 decoder",
    "999 implementation acknowledgment"
  ],
  "cause": [
    "A 997 has six segments and almost no prose. ST opens it. AK1 names the functional group being acknowledged. AK2 opens a loop per transaction set. AK3 reports a segment fault and AK4 an element fault inside it. AK5 gives the verdict for that transaction set, AK9 for the group as a whole, and SE closes it.",
    "Every verdict is a letter and every fault a number. AK5 and AK9 use A (accepted), E (accepted with errors), R (rejected), and additionally for AK9, P (partially accepted) — plus M, W and X for security failures rather than content failures. AK3 codes 1-8 cover segment faults: 1 unrecognised, 2 unexpected, 3 mandatory missing, 4 loop over maximum, 5 segment over maximum, 6 not in this transaction set, 7 out of sequence, 8 has element errors. AK4 codes cover elements: 1 mandatory missing, 2 conditionally required missing, 3 too many, 4 too short, 5 too long, 6 invalid character, 7 invalid code value, 8 invalid date, 9 invalid time.",
    "AK5 also carries its own set: 1 transaction set not supported, 2 trailer missing, 3 ST/SE control numbers disagree, 4 SE01 count wrong, 5 one or more segments in error, 23 control number not unique within the group. AK9 covers group-level faults: 1 group not supported, 4 GS/GE control numbers disagree, 5 GE01 count wrong.",
    "The 999 Implementation Acknowledgment is the same shape with IK3, IK4 and IK5 replacing AK3, AK4 and AK5."
  ],
  "example": {
    "label": "Decode a rejection down to the offending element",
    "curl": "curl -sX POST https://fluentedi.com/v1/edi/acknowledge -H 'content-type: application/json'   -d '{\"input\":\"ST*997*0002~AK1*SH*12~AK2*856*0001~AK3*HL*4**7~AK4*2**7*XX~AK5*R*5~AK9*R*1*1*0~SE*8*0002~\"}'",
    "output": "\"summary\": \"1 of 1 transaction set(s) rejected: 0001.\",\n\"errors\": [\n  { \"level\": \"segment\", \"segment\": \"HL\", \"position_in_transaction_set\": 4,\n    \"code\": \"7\", \"meaning\": \"Segment out of sequence.\" },\n  { \"level\": \"element\", \"element_position\": 2, \"code\": \"7\",\n    \"meaning\": \"Invalid code value — the value is not in the allowed code list.\",\n    \"rejected_value\": \"XX\" }\n]"
  },
  "fix": [
    "Read AK9 first for the group verdict, then each AK2 loop for the transaction sets it covers. A group of P means at least one set was rejected even though the group was answered.",
    "AK3 gives you the segment and its ordinal position within the transaction set — count segments from ST to find it. AK4 gives the element position within that segment.",
    "Resend with a NEW control number. Reusing a rejected one is itself a rejection, AK5 code 23.",
    "Reconcile against what you sent. A transaction set that appears in no AK2 loop was never acknowledged, and that is a worse outcome than rejection because nothing reports it."
  ],
  "tools": [
    "https://fluentedi.com/v1/edi/acknowledge",
    "https://fluentedi.com/v1/edi/validate",
    "https://fluentedi.com/v1/edi/parse"
  ]
}