---
updatedAt: 2026-01-09T14:02:36.000Z
agentTools:
  projectIndex: https://developers.opentrack.co/llms.txt
---

# Last Free Day (LFD) via API

The Last Free Day (LFD) you have to outgate the container before **demurrage** is incurred: This is one of the most operationally important data points we provide. Here's how to consume it from our API and use it in your application.

> For **Detention** (Per Diem) Last Free Day, use the field `detentionLastFreeDay`. <Anchor label="Learn more about Detention LFD in this guide." target="_blank" href="https://support.opentrack.co/en/articles/12111548-detention-last-free-day-lfd-monitoring">Learn more about Detention LFD in this guide.</Anchor>

# Last Free Day (LFD) fields to use

OpenTrack reports three different LFD fields:

1. `lastFreeDay` = applies only to the ocean port terminal
2. `lastFreeDayAtRailFacility` = applies only to the final rail facility
3. `lineLastFreeDay` = the LFD provided by the steamship line (ocean carrier). Can apply to either the ocean port terminal or the final rail facility.

## How to use them

If in doubt, you can default to displaying all LFDs reported on a container. We’ve found that logistics professionals prefer having more information rather than less.

However, you may want to provide a more streamlined experience—and we don’t blame you. We do this too! We use logic to display a smart [Destination LFD](https://support.opentrack.co/en/articles/8981112-guide-to-the-last-free-day-lfd-in-opentrack), which only shows the most relevant, actionable LFD value. Here’s how you can replicate this.

### How to build a smart destination LFD

The logic is pretty simple:

1. If the container has `"isRailMove":"true"`, then use the **earliest** of `lastFreeDayAtRailFacility` or `lineLastFreeDay`
2. If the container has `"isRailMove":"false"`, then use the **earliest** of `lastFreeDay` or `lineLastFreeDay`

This will ensure you use the relevant LFD for the container’s destination. If it’s moving by rail, you don’t want to rely on the ocean port terminal LFD.

It also ensures that when multiple sources report a relevant LFD, you’re displaying the earliest one to be conservative. For example, if both the steamship line and the rail carrier report an LFD, and the line’s is earlier, you’ll want to use that—all else being equal.

# Where LFD comes from

Click here to see our coverage map for each of the Last Free Day types:

* [Terminal Last Free Day](https://airtable.com/appD3uzxe4nixuDeO/shrvDoUc8Up6cEaGR)
* [Rail Last Free Day](https://airtable.com/appD3uzxe4nixuDeO/shrMV3fYhN9UqO5m9)
* [Line Last Free Day](https://airtable.com/appD3uzxe4nixuDeO/shrtHtjy4INEHsZIw)

Other questions? Don’t hesitate to reach out to us.