EDI integration
Start and stop records from your dispatch system's X12 214s, and send approved records to your customer's system as X12 210s.
Pro plan
What EDI does
What it does
- 214 arrivals (X3, X1) open a record for the driver; a departure (AF, CD or D1) stops the shipment's open wait and submits it for your review, priced on the fuel buyer's terms
- An X12 210 (version 004010) for each approved record, sent by HTTPS POST, to a REST API, or (Enterprise) as a file on your partner's SFTP server
- Inbound messages by HTTPS POST, signed with HMAC-SHA256; a resent message is processed once
- Message History for both directions: download any X12 file, and send a failed 210 again
- A 997 functional acknowledgment for every inbound X12 interchange, in the response to the POST: each transaction set accepted or rejected (control numbers and segment counts are checked; rejected sets aren't applied)
Limits
- No 990s, and 997s you send Demurly are stored without acting on them
- Only 214s change records. Inbound 210s, JSON and CSV are stored, not applied
- Outbound is 210 only (no outbound 214), through one active 210 configuration per carrier
- No AS2, VAN or email transfers, and no inbound files by SFTP (214s come by HTTPS POST)
Supported formats
| Format | Direction | What Demurly does |
|---|---|---|
| X12 214 | Inbound | Opens and stops records (see below). Reads the reference and shipment ID (B10), status and time (AT7), driver (L11 DRV), bill of lading (L11 BM) and ship-from and ship-to names (N1) |
| X12 210 | Outbound | Built from the approved record: invoice number is the record number (B3), load and bill of lading (L11), wait start and end (G62), bill-to, carrier and terminal (N1), the detention line with the hourly rate (L1) and the total (L3) |
| X12 210 | Inbound | Stored: invoice reference, date and amount (B3), parties (N1), address (N3/N4) |
| Other X12 | Inbound | Stored as raw segments |
| JSON | Inbound | Stored: the fields in your field mappings (dot paths, e.g. shipment.bol) |
| CSV | Inbound | Stored: one entry per row; the first row is the header; columns from your field mappings |
Field mapping paths can't use __proto__, constructor or prototype; such mappings are rejected.
How 214s start and stop records
| AT7 status | Meaning | What Demurly does |
|---|---|---|
| X3 | Arrived at pickup | Opens the pickup wait as a record |
| AF | Departed pickup | Stops the pickup record (or, when the shipment has no pickup, its one open delivery record) |
| X1 | Arrived at delivery | Opens the delivery wait as a record |
| CD, D1 | Departed delivery, finished unloading | Stops the delivery record (or, when the shipment has no delivery yet, its one open pickup record: a D1 after an X3 stops the pickup wait) |
- Each status names the driver with
L11*<driver number>*DRV, in its LX loop or the heading. It must match an active driver's Driver Number in your company. - The B10 reference (B10-01, else B10-02) ties a departure to its arrival. Each shipment has one pickup and one delivery wait per place, so a 214 sent twice opens one record.
- Times come from the 214 (AT7-05 date, AT7-06 time, AT7-07 time code), not from when it arrived. Times sent as local time, or with no time code, use the time zone set on the configuration.
- A departure stops the record at the reported time and submits it for your review, as the driver's Stop does. The record's evidence says it was stopped by your shipment status message (for example "EDI 214, AF"), not by the driver.
- The record is billed to the fuel buyer named in the ship-to (N1*ST) when that name matches one of your connected customers, else the terminal's default customer, else your only connected customer. Its billable time and amount are saved on that customer's terms (free time and rate) when it stops.
- If the driver already started recording this wait in the app within 2 hours of the reported arrival, the 214 uses that record instead of opening a new one.
- A record opened by a 214 gets the load number (B10), bill of lading, customer name (ship-to) and, for pickups, the terminal whose name matches the ship-from name. Its times are the 214's, not GPS-logged times.
- Statuses with no driver, no reference, no date or time, a time in the future or more than 30 days ago are skipped with a reason. Other status codes are ignored.
- 214s apply to carriers' records. A fuel buyer can receive 214s, but they are only stored.
How 210s are sent
- When a customer approves a record (in full or in part) and the carrier has an active outbound 210 configuration, Demurly sends the record as a 210 for the approved amount. Records approved before the configuration was turned on aren't sent.
- Webhook: an HTTPS POST of the X12 file to your partner's URL, with
Content-Type: application/edi-x12,X-EDI-Control-Numberand, if you set a signing secret,X-EDI-Signature(hex HMAC-SHA256 of the body). - REST API: a POST to your partner's endpoint with the headers and API key you enter (Bearer, X-API-Key or Basic).
- The ISA and GS segments use the Sender ID (or your SCAC), the partner's Receiver ID and your SCAC. Turn on Test files to mark interchanges as tests (ISA15 = T).
- Any answer other than 2xx counts as a failure. A failed send is tried again up to five times over about 32 hours, with the same file and control number, so your partner can drop repeats. You can also send it again from Message History.
- When a partial approval changes the total, the line carries only the charge, not the hourly rate.
Transport
Inbound: webhook (HTTPS POST)
The only way to send messages to Demurly. Your partner posts the raw message to:
POST https://www.demurly.com/api/edi/webhookOutbound: webhook, REST API or SFTP
210s go to your partner's HTTPS URL, as described above. On Enterprise, they can instead go to your partner's SFTP server: each 210 is its own file (demurly-210-<control number>.x12) in the folder you choose. You need the server's address and port, a user with its password or private key (stored encrypted), and the server's host key fingerprint (ssh-keyscan host | ssh-keygen -lf -): Demurly checks it before signing in. Test Connection connects and opens the folder.
997 acknowledgments
Every inbound X12 interchange is answered with a 997 in the response body (acknowledgment.x12), with sender and receiver IDs swapped and your qualifiers and test indicator echoed. A set whose SE count or control number is wrong is rejected (AK5 R) and not applied. Sending the same interchange again returns the same 997.
The configuration dialog also lists email and AS2 (and SFTP and REST API for inbound) as "coming soon": no files or messages are transferred by those.
Setup instructions
Create a configuration
- Carriers: go to Settings > EDI. Customers: go to Settings > Connected systems > EDI integrations. (Organization admins only.)
- Click New Configuration
- On the Basic tab, enter a name and choose the direction. Inbound: choose the format (X12, JSON or CSV) and, for X12, the transaction set (214 to start and stop records, or 210). Outbound: X12 210 is set for you.
Set up the connection
- Inbound: on the Connection tab, keep the connection type Webhook and enter a Signing Secret (a long random string). It's required: messages to a configuration without one are rejected.
- Outbound: choose Webhook (enter your partner's URL and, optionally, a signing secret) or REST API (endpoint, headers and API key). Then enter the Sender ID, Receiver ID and SCAC your partner gave you.
Time zone (214) or field mappings (JSON and CSV)
For inbound 214s, choose the time zone that local times are in (a new configuration starts in your company's time zone; if your company hasn't set one, you choose). For JSON and CSV, on the Mapping tab, enter where each field is in your partner's messages: a dot path for JSON (for example load.reference) or the column header for CSV. X12 210 and 214 use the standard mapping above.
Save, enable and share
- Save. The configuration is saved on or off as the Enable configuration switch is set; it shows "Enabled, awaiting first message" until the first message arrives, then Active.
- Turn it on or off later from the list. Disabled inbound configurations reject messages; disabled outbound configurations send nothing. One outbound 210 configuration can be on at a time.
- Inbound: give your partner the webhook URL, the configuration ID (shown on the Connection tab after saving) and the signing secret.
Test
- Click Test on the configuration. For a webhook configuration this checks the settings; it doesn't send anything. For a REST API configuration it contacts the endpoint.
- Inbound: have your partner send a signed test message (examples below), then check Message History for a success or failed entry, and your records for any 214 arrivals.
- Outbound: turn on Test files while you try it out, then approve a record and check Message History for the 210.
Sending a message to Demurly
| Header | Value |
|---|---|
| X-EDI-Config-Id | The configuration ID |
| X-EDI-Signature | Hex HMAC-SHA256 of the raw request body, keyed with the signing secret |
- The body is the raw message (X12, JSON or CSV), at most 1 MB.
Content-Type: for X12,application/edi-x12,application/x-edi,text/plainorapplication/octet-stream; for JSON,application/jsonortext/plain; for CSV,text/csvortext/plain. Any other type (for exampleapplication/xml) is refused with 415.- Sign exactly the bytes you send; re-serializing JSON after signing breaks the signature.
- Each request is stored as one message in Message History.
- For a 214, the response also lists what each status did (
started,linked,stopped,ignoredorskipped, with the record number and a reason), andresult:applied,partly_applied,not_applied(every status was skipped) orno_change. Message History shows the same, with the status codes and the reason a status was skipped. - Retries are safe: a body identical to one already received for the configuration is not processed again, and the response returns the original message_id with "duplicate": true and the same 997. A body whose statuses weren't all applied is applied again when resent (after you add the driver, say), on the same message and with the same 997 ("reprocessed": true).
Node.js
import { createHmac } from "node:crypto";
import fs from "node:fs";
const configId = "<configuration id>";
const signingSecret = "<signing secret>";
const body = fs.readFileSync("invoice-210.edi");
const signature = createHmac("sha256", signingSecret).update(body).digest("hex");
const res = await fetch("https://www.demurly.com/api/edi/webhook", {
method: "POST",
headers: {
"Content-Type": "text/plain",
"X-EDI-Config-Id": configId,
"X-EDI-Signature": signature,
},
body, // send exactly the bytes you signed
});
console.log(res.status, await res.json());curl and openssl
CONFIG_ID="<configuration id>"
SECRET="<signing secret>"
SIGNATURE=$(openssl dgst -sha256 -hmac "$SECRET" -hex < invoice-210.edi | sed 's/^.* //')
curl -X POST https://www.demurly.com/api/edi/webhook \
-H "Content-Type: text/plain" \
-H "X-EDI-Config-Id: $CONFIG_ID" \
-H "X-EDI-Signature: $SIGNATURE" \
--data-binary @invoice-210.ediResponse (200)
{
"success": true,
"message_id": "6f1c2a9e-...",
"processing_time_ms": 42,
"result": "applied",
"statuses": [
{ "code": "X3", "shipment": "LOAD123", "action": "started", "record_number": "DMR-00000437", "reason": null }
]
}Errors use { "error": { "code", "message" } }. See the troubleshooting guide for each status code.
Security
- Inbound messages are accepted over HTTPS only with a valid HMAC-SHA256 signature
- Connection secrets (signing secret, passwords, API keys) are encrypted at rest with AES-256-GCM and never shown again after saving
- Outbound 210s can be signed with your own secret, and are only sent to public addresses (private and internal hosts are refused)
- Every message received or sent is kept in Message History with its raw content and status
Need help?
If your partner's messages fail to parse, contact us with the message ID from Message History.
Contact support