ml-connector
XeroFedEx

Xero and FedEx integration

Xero is where your business records invoices, purchase orders, and payments. FedEx moves your packages and knows the cost of every shipment and its delivery status. Connecting the two means your outbound orders in Xero automatically generate FedEx shipments, rates flow back to your cost accounts, and package tracking updates land in your expense records without manual re-entry. For businesses shipping physical goods, this turns shipment tracking and cost allocation from a back-office spreadsheet task into a live reconciliation.

How Xero works

Xero exposes contacts, invoices, purchase orders, bank transactions, accounts, and manual journals through a REST API at https://api.xero.com/api.xro/2.0/, authenticated with OAuth2 authorization code flow. Access tokens expire after 30 minutes and refresh tokens expire after 60 days. The API requires the Xero-tenant-id header on every call to target a specific organization. Xero publishes webhooks for contact, invoice, and purchase order events, though events contain metadata only and require a follow-up GET request to fetch the full record. Delta sync via If-Modified-Since header is also supported for polling. Rate limits are strict: 5 concurrent calls, 60 per minute per tenant, and 5000 per day per tenant.

How FedEx works

FedEx exposes shipments, rate quotes, tracking events, and international commerce through REST APIs at https://apis.fedex.com, authenticated with OAuth2 client credentials using an API key and secret. Tracking events are available through paid Advanced Integrated Visibility webhooks or free polling via the Track API, which accepts up to 30 tracking numbers per request. Shipment creation requires a FedEx account number for account-rated calls, and the Ship API provides a transactionId field for client-side deduplication. FedEx does not publish PO or invoice master data, so PO references are customer-provided fields on shipments. Freight invoices are dispute-only through the Billing Online portal, not via REST. Auth rate limits are enforced per IP at 3 tokens per second.

What moves between them

The main flow is Xero outbound: purchase orders and contacts flow from Xero to FedEx to create shipments and request rates. FedEx rate quotes are written back to Xero as line items on manual journals mapped to freight expense accounts. Tracking events flow from FedEx into Xero's bank transactions to post actual carrier charges and confirm delivery. Shipment data is synchronized on a schedule tied to order release cycles, while tracking events are polled once per day or received via FedEx webhooks if enabled.

How ml-connector handles it

ml-connector stores Xero OAuth2 tokens and FedEx API credentials encrypted, and manages the Xero tenant ID passed on every API call. It reads Xero purchase orders with a custom field or contact tag to identify shipping-eligible orders, extracts addresses and line items, and posts them to FedEx's Ship API, using the FedEx transactionId and Xero purchase order ID as a composite key to prevent duplicate shipments if the flow reruns. For rate quoting, ml-connector calls FedEx's Rate API with origin and destination addresses from Xero contacts and posts the resulting rates back to Xero as manual journal lines, mapped to user-configured freight expense accounts and cost centers via Xero's tracking categories. FedEx auth tokens are cached with a 1-hour TTL to stay within the 3-tokens-per-second auth rate limit. Tracking updates are polled from FedEx's Track API by shipment number and written back to Xero as expense journal entries or bank transaction records linked to the original order. All shipment and tracking records carry a full audit trail and can be replayed if a downstream write fails.

A real-world example

A mid-market e-commerce distributor ships orders from a warehouse to retail partners across the country using FedEx Ground and Next Day Air. Before integration, the warehouse team printed shipping labels from FedEx, and the finance team manually entered carrier charges into Xero at month end based on FedEx invoices. Order fulfillment and accounting were disconnected, and shipment costs did not post to Xero until weeks after delivery. With Xero and FedEx connected, each order in Xero triggers a FedEx shipment automatically, rates post to the freight expense account the same day, tracking updates flow back to Xero so fulfillment can be confirmed, and the accounting close process starts with carrier charges already reconciled.

What you can do

  • Create FedEx shipments from Xero purchase orders with automatic address and line-item extraction.
  • Request FedEx rate quotes and post approved rates back to Xero as freight expense journal entries mapped to your chart of accounts.
  • Track FedEx shipments in Xero by polling the Track API and writing delivery status and actual charges to expense records.
  • Prevent duplicate shipment creation by deduplicating FedEx transactionId against Xero purchase order ID.
  • Manage Xero OAuth2 tokens and FedEx client credentials securely, with token caching to respect FedEx auth rate limits.

Questions

Which direction does data move between Xero and FedEx?
Orders and contacts flow from Xero to FedEx to create shipments and quotes. Rate quotes and tracking events flow back to Xero as expense journal entries and bank transactions so costs are reconciled. The main flows are order-to-shipment and tracking-to-expense.
How does ml-connector prevent duplicate shipments if the sync runs twice?
FedEx Ship API requests include a transactionId field that supports client-side deduplication. ml-connector uses a composite key of FedEx transactionId and Xero purchase order ID to track shipments that have already been sent, so re-running the flow does not create duplicate shipments at FedEx.
What Xero objects need to be configured to enable this integration?
Purchase orders must include shipping address information, either directly or pulled from a linked Xero contact. A custom field or contact tag identifies which orders are eligible for FedEx shipment. Xero accounts for freight expenses and cost centers (via tracking categories) must be configured so rate quotes and charges post to the right expense accounts.

Related integrations

Connect Xero and FedEx

Free to use. Add your credentials, ping your real systems, and see if we fit.

Get started