Netlify function timeout: run an AI video job without waiting
Netlify functions stop at 60 seconds, scheduled ones at 30, background ones at 15 minutes. Submit the video job and take the result on a callback.

A Netlify function has a 60-second synchronous execution limit by default, and Netlify's docs list it as not configurable. Scheduled functions get 30 seconds and background functions 15 minutes. An AI video job can outlast the first two, so don't wait for it inside the function: submit the job to Sume, return quickly, and take the finished video on a callback.
Netlify facts come from its functions configuration, background functions, scheduled functions and functions overview pages, read 2026-09-29. Sume facts come from Jobs and results and Videos. Sume has no Netlify integration: this is a plain HTTPS call from your function.
What is the Netlify function timeout?
It depends on the function type. Netlify's defaults table, dated by the page as last updated Sep 17, 2026, gives one limit per type, and marks each of them as not configurable.
| Function type | Execution limit | Configurable? |
|---|---|---|
| Synchronous | 60 seconds | No |
| Scheduled | 30 seconds | No |
| Background | 15 minutes | No |
| Background request/response payload | 256 KB | No |
How do I start a Sume video job without hitting it?
Use a regular function that only submits. POST /v1/videos answers 202 with a job id, a polling_url and status: pending, so there's nothing to wait for. Give the request a callback_url (HTTPS) and an Idempotency-Key built from your own id, and keep the API key in a Netlify environment variable rather than in the browser.
import type { Config } from "@netlify/functions";
export default async (req: Request) => {
const { orderId, prompt } = await req.json();
const res = await fetch("https://api.sume.com/v1/videos", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SUME_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": `order-${orderId}-video`,
},
body: JSON.stringify({
model: "seedance-2",
prompt,
callback_url: "https://example.com/hooks/sume",
}),
});
if (!res.ok) return new Response("submit failed", { status: 502 });
const job = await res.json();
return Response.json({ job_id: job.id }, { status: 202 });
};
export const config: Config = { method: "POST", path: "/submit" };When does a Netlify background function help?
Set background: true in the function's config and Netlify gives the caller an empty 202 at once while the function runs for up to 15 minutes. Netlify says background functions don't return responses and that you generally pass the result to a destination other than the originating client. That suits work such as a submit followed by writing the job id into your database. It's not a reason to sit in a polling loop for a render: Sume's docs call submitting with async and polling the right answer for anything that can outlast 30 seconds, and a webhook callback removes the loop.
What happens if a background function errors?
Netlify retries it: if the invocation returns an error, a retry happens after one minute, and if it fails again, another retry happens two minutes later. A retry runs your submit code again, which is what the Idempotency-Key is for. Sume's docs say a same-key retry returns the original job instead of billing a second one, and to reuse a key only for the same operation and payload. A timeout on your side doesn't cancel the job either: it keeps running and still bills.
Can a scheduled function submit the job?
Yes, if it only submits. Netlify's scheduled functions page gives a 30-second execution limit and says they don't work with payloads or POST request data, so build the request from constants or your own data store. Receive the result in a separate regular function that verifies Sume's signature and returns 2xx quickly. Sume sends terminal events only, retries non-2xx responses up to 10 attempts, and allows 10 seconds per attempt.
Sources
Related posts
More in Integrations
- Notion button send webhook: put the video URL back on the page
A Notion button can send a webhook that starts a Sume video job. When Sume calls back, PATCH the page's URL property with the finished video.
- OpenAI Agents SDK human in the loop for paid tools
Set needs_approval on a function tool that starts a paid video job. The run pauses with result.interruptions until you approve or reject the call.
- p-retry npm: retry a paid API POST and stop on errors
p-retry reruns an async function with exponential backoff. Throw AbortError on answers a resend can't fix, and keep one Idempotency-Key per job.
- PHP cURL POST JSON with a Bearer token
json_encode the body, pass the string to CURLOPT_POSTFIELDS, set Content-Type and Authorization headers, then check the status: cURL won't fail on a 4xx.
Written by Sume