Async and Long-Running Operations via the Data API
ExpertHandle slow FileMaker scripts and bulk operations asynchronously using job queues, polling endpoints, and server-sent events.
What you'll learn
- How to design an async job queue for long-running FM operations
- How to implement a polling endpoint for job status
- How to use FileMaker scripts as async workers via the Data API
- How to stream progress updates with server-sent events
Some FM operations take seconds or minutes: bulk imports, PDF generation, complex scripts. Synchronous API calls block the client and timeout at the gateway. The solution is an async job pattern: the client submits the job, receives a job ID, and polls for completion. This section implements that pattern on top of the FM Data API.
1/4
1
Job submission endpoint
Accept the job request, write a job record to a FM table (or your own DB), return a job ID immediately. The client gets a 202 Accepted with a poll URL.
FileMaker Script
// POST /api/jobs/bulk-import
export async function POST(req: Request) {
const body = await req.json();
const jobId = crypto.randomUUID();
// Write job to FM (or Postgres) -- status: "pending"
await fm.createRecord('Jobs', {
JobID: jobId,
Type: 'bulk-import',
Payload: JSON.stringify(body),
Status: 'pending',
CreatedAt: new Date().toISOString(),
});
return Response.json(
{ jobId, pollUrl: `/api/jobs/${jobId}/status` },
{ status: 202 }
);
}Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo