Urgent.News

What's breaking now, across thousands of outlets.

Tech

How Facebook Page bulk deletion actually works with the Graph API

There is no Meta endpoint called “bulk delete Facebook Page posts.” If you have ever searched for one, you already know the trap: Business Suite can delete a small batch, Activity Log is click-hell, and Chrome extensions pretend there is a bulk API by driving the website UI. Under the hood, official deletion is still one HTTP call per post. DELETE…

Facebook utilizes the Graph API to delete posts from a Page, but there is no built-in endpoint specifically for bulk deletion. Users often mistake the Business Suite, Activity Log, and Chrome extensions for such tools, when in reality, deletion is carried out through individual HTTP calls. Each post requires its own DELETE request using the syntax DELETE https://graph.facebook.com/v21.0/{page-id}_{post-id} with the appropriate Authorization header containing the Page access token.

When aiming to delete a thousand posts, this translates to ten thousand separate DELETE calls. It is essential to understand that the whole process is still built on a one-call-per-post architecture. To actually delete posts, a Page access token and the permissions pages_manage_posts are required. The process involves scanning the Page's feed, filtering posts by their 'created_time' property, and then sending a DELETE request for each matching post ID.

In practice, some key scopes need to be considered, such as pages_show_list, pages_manage_posts, pages_read_engagement, and pages_read_user_content. Failing to include these scopes often results in errors like Graph 10 or 200. It is crucial to connect to the correct login method, as using a user token instead of a Page token will lead to unnecessary complications.

Some elements are not deletable using this method, including profile pictures, cover photos, story highlights, personal profile timeline posts, group posts, and posts that have already been removed. Exporting the post IDs, dates, and links to a CSV file is only a checklist, not a means of restoring any deleted content. Graph does not provide the original image files, and there is no undo option available.

Creating a naive script to perform bulk deletion would involve iterating through an array of post IDs, making a DELETE request for each one, and checking the 'success' property in the response. While this may work on a small test Page, it will fail when applied to a real Page due to Meta's rate limits.

When Meta starts throttling the requests, the JSON error code could be 4, 17, 32, or 613, accompanied by messages like "too many calls" or "request limit reached." The headers X-Page-Usage and X-App-Usage can provide additional information about the rate limits. A production-grade solution would limit the loop when usage is around 80%, pause when near 95%, and implement a backoff strategy after experiencing error codes.

However, token errors are different. Code 190 requires reconnecting to Facebook Login and starting a new job for the remaining posts. Retrying an expired token has no effect. For a production environment, it is recommended to run the deletion on a server, not a browser tab. Chrome extensions claiming to "bulk delete" are unreliable, as they interact with the website UI rather than utilizing the Pages API.

In conclusion, bulk deletion of Facebook Page posts is executed through individual DELETE requests utilizing the Graph API, with strict adherence to the required scopes and access tokens. Building a reliable job should involve utilizing a worker to queue post IDs, employ pacing, persist progress, and provide a clear mechanism for pausing and resuming the deletion process.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The Art of Doing One Thing Well

Okay, but what one thing? In my last post, I wrote about the problems I was creating for myself by trying to learn everything at once. Which summarised is just that I was spreading myself too thin.

More from Thursday 10 September →