You can build this in the time it takes to finish a cup of coffee.
If your goal is simply to notify a team when a flight is delayed, there is no need for a complex infrastructure. With APIlayer’s Flight API, you can create a lightweight workflow that periodically checks flight status, compares delay information, and sends an alert whenever a delay is detected. The result is a simple, reliable flight delay notification system that can be implemented with minimal code and maintenance.
Aviationstack API is a good fit for that kind of single-purpose integration. Its REST API returns flight status, departure delay, arrival delay, and flight identifiers in a JSON shape that is easy to use from a serverless function.
In this tutorial, we will build a compact flight status API integration with one Next.js App Router route, one Vercel cron definition, and one Slack incoming webhook.
Table of Contents
How the system works
Vercel calls /api/check-flight on a schedule. That route calls Aviationstack with a flight IATA code, reads departure.delay and arrival.delay, and sends a Slack message if either value is above zero.
That is the whole architecture: one serverless function, one cron entry in vercel.json, and one outbound webhook POST. No background worker, no separate scheduler, and no aviation-specific infrastructure to maintain.
Creating the serverless function
Inside a Next.js App Router project, create this file:
app/api/check-flight/route.ts
Paste in the route below. It uses environment variables for the Aviationstack key and Slack webhook URL, avoids cached flight data, and returns clear status codes when the upstream API or webhook fails.
declare const process: { env: Record };
export async function GET() {
const flightIata = "AA100";
const apiKey = process.env.AVIATIONSTACK_API_KEY!;
const slackUrl = process.env.SLACK_WEBHOOK_URL!;
const url = new URL("https://api.aviationstack.com/v1/flights");
url.searchParams.set("access_key", apiKey);
url.searchParams.set("flight_iata", flightIata);
const { data } = await fetch(url, { cache: "no-store" }).then((res) => res.json());
const flight = data?.[0];
if (!flight) {
return Response.json({ error: "Flight not found" }, { status: 404 });
}
const delay = Math.max(flight.departure?.delay ?? 0, flight.arrival?.delay ?? 0);
if (delay > 0) {
await fetch(slackUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
text: `Flight ${flight.flight.iata} is delayed by ${delay} minutes.`,
}),
});
}
return Response.json({
flight: flight.flight.iata,
status: flight.flight_status,
delay,
});
}
The route uses AA100 as the example flight, but you can replace that with any flight IATA code you want to monitor. For multiple flights, keep the same route shape and loop through an array of flight codes.
Add environment variables
Add these values in your Vercel project settings before deploying:
AVIATIONSTACK_API_KEY=your_api_key
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
You can create the Aviationstack key from your Aviationstack dashboard. Slack incoming webhooks are created from your Slack app configuration.
Schedule it with Vercel Cron
The final piece is scheduling the function to run automatically. Vercel provides built-in Cron Jobs that can trigger a serverless function on a schedule, which means you do not need a separate scheduler, background worker, or third-party automation service.
Create a file named vercel.json in the root of your project. The root directory is the same location that contains files such as package.json, tsconfig.json, and next.config.js. It should sit alongside your app folder, not inside it.
Your project structure should look similar to this:
my-project/
├── app/
│ └── api/
│ └── check-flight/
│ └── route.ts
├── package.json
├── tsconfig.json
├── next.config.js
└── vercel.json
Create vercel.json in the project root, next to package.json and your app folder.
{
"crons": [
{
"path": "/api/check-flight",
"schedule": "0 9 * * *"
}
]
}
This daily schedule works with Aviationstack free tier limits and Vercel Hobby cron limits. It is the right example if you are testing the workflow or monitoring a small number of flights without upgrading plans.
If you need a near-real-time alert every 15 minutes, use this schedule instead, but only after moving to a Vercel plan that supports frequent cron runs and an Aviationstack plan with enough monthly requests:
{
"crons": [
{
"schedule": "*/15 * * * *",
"path": "/api/check-flight"
}
]
}
Vercel cron jobs run only after deployment. During local development, call the route directly at http://localhost:3000/api/check-flight or use curl/Postman.
What Aviationstack returns
The /v1/flights endpoint returns detailed flight information in a clean JSON structure. For this project, we only care about a few specific fields: the flight status, the flight IATA code, and the delay values inside the departure and arrival objects.
Here is an example response from the Aviationstack API:
{
"data": [
{
"arrival": {
"airport": "London Heathrow",
"delay": 38,
"iata": "LHR",
"scheduled": "2026-05-28T20:15:00+00:00"
},
"departure": {
"airport": "John F. Kennedy International",
"delay": 42,
"iata": "JFK",
"scheduled": "2026-05-28T08:00:00+00:00"
},
"flight": {
"iata": "AA100",
"number": "100"
},
"flight_date": "2026-05-28",
"flight_status": "active"
}
]
}
Because the delay values are already structured fields, the function does not have to scrape text, parse airport pages, or guess from timestamps. It can compare the numbers directly and send the Slack alert.
Deploy
Once the route, cron config, and environment variables are ready, deploy the project:
vercel deploy
After deployment, Vercel triggers the route on the cron schedule and the route checks Aviationstack for the latest flight status. For a public endpoint, add a CRON_SECRET check so only Vercel cron invocations can trigger it.
One more thing before you deploy
This version sends a Slack message every time it sees a delay. If the same flight stays delayed, you can get repeated alerts on every run. The practical production fix is to store the last-known alert state in Vercel KV, Redis, or another small datastore and only notify when the status or delay changes.
Explore Aviationstack API Pricing
Access real-time flight status, airline schedules, airport information, and global aviation data through the Aviationstack API. Explore available plans to find the right fit for your application.
Explore API PricingFind the right plan for your aviation data needs.
Aviationstack gives you 100 requests per month on the free tier, which is enough for light daily checks and quick prototypes. For 15-minute monitoring, budget for more API calls and use a Vercel cron plan that supports that frequency. Grab an API key at https://aviationstack.com/ and deploy the first version before your coffee gets cold.
FAQs
Can I monitor multiple flights with the same setup?
Yes. Replace the single flightIata value with an array of flight IATA codes and send one Slack message per delayed flight.
Does Vercel Cron run locally?
No. Cron schedules run in deployed environments. Locally, call /api/check-flight manually.
Is Aviationstack free tier enough for this project?
Yes for light daily checks and prototypes. No for 15-minute monitoring, because that schedule uses far more than 100 requests per month.
How do I prevent duplicate Slack alerts?
Store the last-known flight status or delay in Vercel KV and only notify when the value changes.