EDI Mapping Specs

Updated Jul 26, 2026
EDI

EDI Mapping Specs

A mapping spec turns a partner's EDI document into a business object your scripts and apps can use. It says which segment and element carries the PO number, where the line items repeat, and what to call each field.

Find them at Extensions > EDI Mapping Specs. Creating and editing requires DataMagik - Builder.

Why a spec instead of code

Without one, a script reading an 850 has to write segments.find(s => s.tag === "BEG").elements[2] and hope the partner populates BEG03 the way you expect. The knowledge ends up trapped in that script, and onboarding the next partner means copying and editing it. A spec is data: it is versioned, it is testable against a real file, and the same one drives both reading and writing.

Start from a template

DataMagik ships 26 starter mappings, grouped by vertical. Pick one, and the designer opens pre-filled with a sensible layout you then tune to your partner.

The starter template gallery, grouped by vertical
The General Trade group. Automotive & Steel, Warehousing & 3PL and Food & Beverage follow below it.
SetStarterPurpose
810810-standardInvoice — header invoice number/date/PO, IT1 line loop, TDS total.
812812-credit-debit-adjustmentCredit/debit adjustment — the price or weight settlement after a heat is weighed and graded, or a claim against an invoice.
816816-organizational-relationshipsShip-to, bill-to and plant hierarchy sent as data instead of by email.
820820-remittance-adviceWhat a customer paid and which invoices it settles, so cash application is not keyed.
824824-application-adviceSyntactically fine but rejected by the business application — something a 997 cannot say.
830830-planning-scheduleForecast with cumulative accounting. The core automotive release document.
846846-inventory-adviceOn-hand and available stock by item, as a service centre reports coil and plate inventory.
850850-standardPurchase order — header, N1 party loop, PO1 line loop with PID descriptions.
852852-product-activityPOS/inventory movement from a grocer or retailer.
855855-po-acknowledgmentPurchase order acknowledgment — BAK header, per-line ACK status.
856856-standardAdvance ship notice — HL shipment/order/item hierarchy. Steel: heat number via REF at item level.
860860-po-changeThe buyer revises an order already sent — POC lines with change code and revised quantity or price.
861861-receiving-adviceWhat actually arrived, weighed and counted, against what the ASN promised.
862862-shipping-scheduleFirm release against a PO, with FST ship-schedule requirements.
864864-text-messageFree-form mill notes: heat certificates pending, line down, gauge substitution.
865865-po-change-ackThe seller's answer to an 860 — accepted, rejected, or accepted with changes.
866866-production-sequenceBuild-order sequencing against a release: which unit, in what order, to what line-side location.
869869-order-status-inquiryAsk a mill or service centre where an order stands. Outbound.
870870-order-status-reportThe reply: released, rolled, shipped, with quantities by status.
875875-grocery-purchase-orderGrocery purchase order (UCS) — G50 header, N9 references, G69/G55 line items.
940940-warehouse-shipping-orderInstruct a 3PL to ship. Outbound.
944944-stock-transfer-receiptThe 3PL confirms what it received into stock against a transfer.
945945-warehouse-shipping-adviceA 3PL confirms a shipment — HL shipment/order/item with W12 line items.
ORDERSedifact-ordersEDIFACT purchase order — BGM document number, LIN line loop with composite product id and QTY.
DELJITedifact-deljitEDIFACT delivery just-in-time call-off. Inbound from European OEMs.
DESADVedifact-desadvEDIFACT despatch advice / ASN. Outbound to European OEMs.
Starters are a starting layout, not a certified mapping. Several say so in their own description ("tune W01 positions to your 3PL"). Always run Test mapping against a real file from the partner before going live.

The designer

The spec designer with an 850 open and a sample document mapped
Left: the mapping as a structure. Right: a real sample and the object it produced.
PartWhat it does
NameHow the spec is referenced from a partner's routing row and from edi.map(raw, "name") in a script.
DirectionInbound (segments → object) or outbound (object → segments).
Standard / Transaction setX12 or EDIFACT, and which document.
Output keyThe name of the array in the resulting object — purchaseOrders.
Header fieldsOne row per value from the document header. The path is a segment and an element position.
Repeating groupsLine items and parties. A group starts at a segment and repeats — PO1 for order lines, N1 for parties — and can nest.
SettingsDefine your own configuration fields and their defaults, for a document-logic script to read. Acknowledgements, conformance and turnaround are set per partner on the routing row, not here.
Edit as JSONThe whole spec as a document. Nested groups beyond the first level, and code sets, are edited here.

Field paths

A path is SEGMENT[n] for an element and SEGMENT[n][c] for a component. Positions are 0-based, counting the elements after the segment tag. So in BEG*00*SA*PO-48815**20260725:

BEG[0] = "00"          purpose code
BEG[1] = "SA"          PO type
BEG[2] = "PO-48815"    the PO number
BEG[4] = "20260725"    the PO date
BEG[2] is BEG03 in your partner's specification. Their documents number elements from 1; the designer counts from 0. Off-by-one here is the single most common mapping mistake.

Each field also has a type — string, number or date — and a required flag. Default to string: EDI is string data, and a partner sending 00100 for a quantity should not silently become 100 in an audit trail unless you asked for it. Marking a field required means a document that does not carry it is treated as non-conformant and sent to review rather than passed downstream half-empty.

AI discover

Paste a real document into Sample EDI document and press AI discover. DataMagik parses the file structurally — that part is deterministic and always correct — and asks the AI to propose field names and loop boundaries from the segment inventory. You then correct and save.

AI discover reporting that it proposed a mapping
A successful run proposes field names and loop boundaries from the document itself. If the model is unavailable it says so and falls back to the standard template rather than failing silently.

The names it proposes are its own — a discovered 850 might call the line array lineItems where the starter template calls it lines. Rename anything you would rather match your existing scripts before saving.

Runtime parsing never calls AI. The AI is used at authoring time only; once saved, the spec is applied deterministically. A wrong answer at 3am is not possible, because nothing is being decided at 3am.
Discover needs an AI provider key configured. Without one — or if the model cannot be reached — you get the standard template for that transaction set plus a note explaining why, which is a workable starting point rather than a dead end.

Test mapping — a worked 850

This is the part to do before anything else goes live. Paste a document, press Test mapping, and read the object next to the file that produced it.

Given this purchase order:

ISA*00*          *00*          *ZZ*ACMESTEEL      *ZZ*CHUPPCONS      *260725*1200*U*00401*000000101*0*P*>~
GS*PO*ACMESTEEL*CHUPPCONS*20260725*1200*101*X*004010~
ST*850*0001~
BEG*00*SA*PO-48815**20260725~
N1*ST*Chupp Consulting Plant 4~
N4*Columbus*OH*43004~
PO1*1*100*EA*12.50**BP*WIDGET-A~
PID*F****Widget A, zinc plated~
PO1*2*40*EA*31.75**BP*BRACKET-C~
CTT*2~
SE*9*0001~
GE*1*101~
IEA*1*000000101~

the 850-standard starter reports Mapped OK · X12 · envelope valid and produces:

{
  "purchaseOrders": [{
    "poNumber": "PO-48815",
    "poDate": "2026-07-25",
    "parties": [
      { "entityCode": "ST", "name": "Chupp Consulting Plant 4",
        "city": "Columbus", "state": "OH", "postalCode": "43004" }
    ],
    "lines": [
      { "line": "1", "product": "WIDGET-A", "productQualifier": "BP",
        "quantity": 100, "uom": "EA", "unitPrice": 12.5,
        "descriptions": [{ "description": "Widget A, zinc plated" }] },
      { "line": "2", "product": "BRACKET-C", "productQualifier": "BP",
        "quantity": 40, "uom": "EA", "unitPrice": 31.75, "descriptions": [] }
    ]
  }]
}

Note what the spec did beyond copying strings: poDate became a real date, quantity and unitPrice became numbers because those fields are typed, the N1/N4 pair collapsed into one party object, and the PID under each PO1 nested inside its own line rather than floating at the top.

To finish the setup, register the sender as a trading partner with qualifier ZZ and ID ACMESTEEL, and add a routing row for They send us / 850 mapped by this spec.

Using a spec from a script

const result = edi.map(raw, "850-acme");     // apply a saved spec
const tx     = edi.process(raw);             // full pipeline: partner + spec + routing
const specs  = edi.starterSpecs();           // the built-in catalog
const out    = edi.buildMapped(obj, "855-acme");  // the other direction
Related: The Inbound Pipeline explains what happens to a document after a spec has read it.
Was this page helpful?