{
  "name": "edi.build",
  "group": "edi",
  "summary": "Generate a valid X12 856 ASN or 850 purchase order from JSON, with correct HL pointers and envelope counts.",
  "description": "Compiles structured JSON into standards-valid X12. The parts that get documents rejected are exactly the parts a language model cannot hold in its head: the 856 hierarchy needs sequential HL IDs where every level names its parent's ID, and on a multi-carton, multi-SKU shipment that bookkeeping goes wrong silently. The ISA header is fixed-width — 106 characters exactly, every element space-padded to size — and one character out crashes the receiver's translator. Segment counts in SE01, CTT01, GE01 and IEA01 must agree with what was actually emitted. All of that is computed here rather than written by hand.",
  "keywords": [
    "generate edi",
    "build x12",
    "create 856",
    "write edi",
    "emit x12",
    "asn generator",
    "hl loop",
    "edi envelope",
    "isa segment",
    "x12 writer",
    "advance ship notice",
    "edi output"
  ],
  "endpoint": "https://fluentedi.com/v1/edi/build",
  "mcp_name": "edi_build",
  "makes_network_request": false,
  "parameters": {
    "type": "object",
    "properties": {
      "document": {
        "description": "Transaction set to build.",
        "type": "string",
        "enum": [
          "856",
          "850"
        ],
        "default": "856"
      },
      "data": {
        "description": "Document content. For 856: {shipment_id, ship_date, orders:[{po_number, packs:[{sscc, items:[{upc, quantity, unit}]}]}], parties:[{role,name,id}]}. For 850: {po_number, order_date, lines:[{quantity, unit, unit_price, upc, description}], parties:[...]}.",
        "type": "object"
      },
      "sender_id": {
        "description": "ISA06 sender identifier.",
        "type": "string",
        "default": "SENDER",
        "maxLength": 15
      },
      "receiver_id": {
        "description": "ISA08 receiver identifier.",
        "type": "string",
        "default": "RECEIVER",
        "maxLength": 15
      },
      "sender_qualifier": {
        "description": "ISA05 qualifier, e.g. ZZ, 01 (DUNS), 12 (phone).",
        "type": "string",
        "default": "ZZ",
        "maxLength": 2
      },
      "receiver_qualifier": {
        "description": "ISA07 qualifier.",
        "type": "string",
        "default": "ZZ",
        "maxLength": 2
      },
      "control_number": {
        "description": "Interchange control number (ISA13). Also seeds GS06 and ST02.",
        "type": "integer",
        "default": 1,
        "minimum": 1
      },
      "test_indicator": {
        "description": "Mark the interchange as test (ISA15 = T) rather than production (P).",
        "type": "boolean",
        "default": true
      },
      "timestamp": {
        "description": "ISO instant for the envelope date/time. Defaults to now.",
        "type": "string",
        "default": ""
      },
      "include_envelope": {
        "description": "Wrap the transaction set in ISA/GS ... GE/IEA.",
        "type": "boolean",
        "default": true
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  },
  "examples": [
    {
      "description": "Build an ASN: one order, two cartons, correct HL tree",
      "url": "https://fluentedi.com/v1/edi/build?document=856&data=%7B%22shipment_id%22%3A%22SHIP1001%22%2C%22orders%22%3A%5B%7B%22po_number%22%3A%224500123456%22%2C%22packs%22%3A%5B%7B%22sscc%22%3A%22006141411234567890%22%2C%22items%22%3A%5B%7B%22upc%22%3A%22012345678905%22%2C%22quantity%22%3A12%2C%22unit%22%3A%22EA%22%7D%5D%7D%2C%7B%22sscc%22%3A%22006141411234567906%22%2C%22items%22%3A%5B%7B%22upc%22%3A%22012345678905%22%2C%22quantity%22%3A8%2C%22unit%22%3A%22EA%22%7D%5D%7D%5D%7D%5D%2C%22parties%22%3A%5B%7B%22role%22%3A%22ST%22%2C%22name%22%3A%22ACME%20STORES%22%2C%22id%22%3A%220042%22%7D%5D%7D",
      "args": {
        "document": "856",
        "data": {
          "shipment_id": "SHIP1001",
          "orders": [
            {
              "po_number": "4500123456",
              "packs": [
                {
                  "sscc": "006141411234567890",
                  "items": [
                    {
                      "upc": "012345678905",
                      "quantity": 12,
                      "unit": "EA"
                    }
                  ]
                },
                {
                  "sscc": "006141411234567906",
                  "items": [
                    {
                      "upc": "012345678905",
                      "quantity": 8,
                      "unit": "EA"
                    }
                  ]
                }
              ]
            }
          ],
          "parties": [
            {
              "role": "ST",
              "name": "ACME STORES",
              "id": "0042"
            }
          ]
        }
      }
    },
    {
      "description": "Build a purchase order",
      "url": "https://fluentedi.com/v1/edi/build?document=850&data=%7B%22po_number%22%3A%22PO-9001%22%2C%22order_date%22%3A%222026-08-24%22%2C%22lines%22%3A%5B%7B%22quantity%22%3A100%2C%22unit%22%3A%22EA%22%2C%22unit_price%22%3A9.99%2C%22upc%22%3A%22012345678905%22%7D%5D%2C%22parties%22%3A%5B%7B%22role%22%3A%22ST%22%2C%22name%22%3A%22ACME%20STORES%22%2C%22id%22%3A%220042%22%7D%5D%7D",
      "args": {
        "document": "850",
        "data": {
          "po_number": "PO-9001",
          "order_date": "2026-08-24",
          "lines": [
            {
              "quantity": 100,
              "unit": "EA",
              "unit_price": 9.99,
              "upc": "012345678905"
            }
          ],
          "parties": [
            {
              "role": "ST",
              "name": "ACME STORES",
              "id": "0042"
            }
          ]
        }
      }
    }
  ],
  "suggestion": null
}