ml-connector
FreshBooksFedEx

FreshBooks and FedEx integration

FreshBooks runs your invoicing and expense tracking. FedEx runs your shipping, rates, and delivery tracking. Connecting the two keeps logistics and accounting in step. Shipment details from FreshBooks invoices flow to FedEx for rating and label creation, while FedEx tracking updates return to FreshBooks so your expense records show actual delivery confirmation and real transit costs. ml-connector handles the OAuth handshake for each system and maps addresses and line items so the data lands correctly on both sides.

How FreshBooks works

FreshBooks is a REST-based cloud accounting platform that exposes invoices, expenses, clients, bill vendors, payments, and chart of accounts through JSON endpoints. It uses OAuth 2.0 user-delegated authorization (not Client Credentials), so each customer logs in once to grant FreshBooks API access to their account. FreshBooks can push events via webhooks to a customer-supplied endpoint for invoice creation, invoice updates, expense creation, and client changes, with HMAC-SHA256 signatures for verification. Webhook delivery is not real-time and can range from seconds to several minutes, and the platform times out after 10 seconds per attempt. For records that require real-time pull, ml-connector can poll the invoices, expenses, and payments endpoints on a set schedule.

How FedEx works

FedEx is a REST API platform for shipping, rate quoting, package tracking, freight management, and international customs documentation. It uses OAuth 2.0 Client Credentials (grant_type=client_credentials) with an API Key and API Secret issued by the FedEx Developer Portal. FedEx offers webhooks for tracking push events through its Advanced Integrated Visibility service, but webhooks are a paid subscription and tracking numbers are billed separately. For free tracking access, ml-connector can poll the Track API, which accepts up to 30 tracking numbers per request and returns both in-transit and historical events. FedEx rate quotes, shipment creation, and label APIs are request-response only; there is no webhook event stream for those operations. FedEx has strict rate limits at the IP level (3 tokens per second) and per project (1,400 transactions per 10 seconds), so ml-connector caches OAuth tokens with a 1-hour TTL to stay within limits.

What moves between them

Shipment line items from FreshBooks invoices and expenses flow into FedEx for rate quoting and label creation. ml-connector extracts the recipient address and item weight from each invoice line item, queries FedEx for available rates and service levels, and stores the chosen rate and label in the FreshBooks expense record. FedEx tracking events are read back via polling on a daily or per-shipment basis and matched to FreshBooks expense records by tracking number, so accounting staff can see delivery confirmation and actual freight charges without leaving FreshBooks. Address data moves primarily one direction (FreshBooks to FedEx), while tracking status flows back into expenses.

How ml-connector handles it

ml-connector stores FreshBooks OAuth tokens (user-delegated) and FedEx API credentials (Client Credentials) encrypted in the database. For each FreshBooks invoice or expense marked for shipment, it extracts the recipient client address and line item details, then calls FedEx's Rate API with package weight and origin postal code to fetch available service levels. If a rate is selected, ml-connector calls the Ship API to create a label, stores the FedEx tracking number in the expense record, and caches the Bearer token from FedEx (1-hour TTL) to avoid hitting FedEx's strict 3-tokens-per-second rate limit. FedEx provides a transactionId on the Ship API response for client-side deduplication in case of network retries. For tracking, ml-connector polls the Track API daily or on demand with up to 30 tracking numbers per request, matches returned events to FreshBooks expense records, and appends delivery confirmation and actual carrier charges to the expense. FreshBooks webhooks are available for invoice and expense events and can trigger immediate rate lookups, but polling is also supported for systems that prefer a scheduled sync. FedEx has no invoice REST API, so freight charges must be reconciled manually from the FedEx Billing Online portal or extracted from tracking events.

A real-world example

A small e-commerce retailer uses FreshBooks to track orders as invoices and records fulfillment costs as expenses. Before the integration, the shipping manager used FedEx's web portal to rate and book shipments, then sent tracking numbers back to the office manager via email to be manually entered into FreshBooks. At month-end reconciliation, the office manager compared FedEx invoice charges with FreshBooks expense records and had to chase down shipments with mismatched costs or missing tracking data. With FreshBooks and FedEx connected, each new invoice in FreshBooks automatically triggers a rate lookup in FedEx. The shipping manager picks the best rate from ml-connector's dropdown, a label is generated, and the tracking number is logged directly in the FreshBooks expense. FedEx tracking updates sync back daily, so by month-end the office manager can see which shipments have been delivered and compare the agreed-upon rate with actual charges without manual lookup or re-entry.

What you can do

  • Extract shipment recipient addresses and weights from FreshBooks invoices and expenses, and send them to FedEx for rate quoting and label generation.
  • Store FedEx tracking numbers, service levels, and negotiated rates directly in FreshBooks expense records for full fulfillment transparency.
  • Poll FedEx tracking events daily to retrieve delivery confirmation status and actual freight charges, and link them back to FreshBooks expense records.
  • Manage FreshBooks OAuth 2.0 user-delegated tokens and FedEx OAuth 2.0 Client Credentials separately, with secure encrypted storage and token caching to respect FedEx rate limits.
  • Trigger immediate rate lookups from FreshBooks webhook events (invoice.create, expense.create) or sync on a scheduled daily basis for batch processing.

Questions

How do addresses flow from FreshBooks to FedEx?
ml-connector extracts the FreshBooks client address (stored in the client record linked to each invoice) and uses it as the FedEx recipient address. The shipper address is configured once per FreshBooks account during setup. If a client address is missing or incomplete, the rate lookup will fail and return an error so ml-connector can prompt the user to complete the address in FreshBooks before retrying.
Does FedEx webhook tracking require a paid subscription?
Yes. FedEx's Advanced Integrated Visibility webhooks are a paid feature, with tracking numbers billed separately. ml-connector supports both modes: if webhooks are enabled, tracking events push to ml-connector immediately; otherwise, ml-connector polls the FedEx Track API daily for free. Polling is the lower-cost option and suitable for retailers who do not need real-time tracking alerts.
What happens if a FreshBooks client address is incomplete or invalid?
FedEx's rate API requires a complete destination address. If ml-connector encounters a missing city, postal code, or country, it returns a validation error and logs the error in FreshBooks so the user can complete the address. FedEx sandbox is virtualized and accepts any address field except country, so testing can proceed with placeholder addresses; production rates will fail if the address is not complete and valid.

Related integrations

Connect FreshBooks and FedEx

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

Get started