Run function after a post has finished saving – callback function perhaps?

If you don’t have control over the API, you’re doing it almost right. That is what cron jobs are for.

What needs to be avoided is possible overlapping API calls that do the same thing. Why not instead have a meta field automation_operation_status that stores the … status? Like pending, running, complete, error.

Then, in your cron job you just query those that are pending. And if it’s really that long of a process, you could even limit it to one or two jobs per run.

Just gotta play with the cron job frequency and avoid PHP timeouts.


In the end, the ideal solution would be the API itself offering a fast acting queue where jobs can be stored for later processing. On top of that a service where processing status can be queried. Or a service that posts back to the WordPress installation on job completion (if that needs that info).

All that you would also only call via cron jobs.

This way you put minimum stress on the frontend facing server.