Purge cache 1012 error

Hey guys, I was hoping someone could help point me in the direction.

I’m trying to purge everything in a cache and I’ve spent hours trying to form a request but keep running into the same “request must contain one of purge_everything, files, tags, hosts, prefixes” error response.

I’ve googled and read dozens of different pages on the same problem but most of them are using cURL.

I can tell the “purge_everything”: “true” is being attached as a body but it doesn’t seem to work for me.

I’m using NodeJS and cannot figure out what the name of the body field should be for “purge_everything”.

I’ve tried setting a field as “body” and then “forms”, setting the “Content-Type: x-www-encoded-forms” and then “Content-Type: application/json”. I’ve tried all sorts of weird combos of random guessing in the hopes of making this work.

There was a random post on StackOverflow where someone else said “change the field name to JSON” ??? but absolutely nothing works.

Can someone tell me what I’m doing wrong?

This is what my https request options look like:

const options = {
host: “api.cloudflare.com”,
port: 443,
path: “/client/v4/zones/ZONE_ID/purge_cache”,
method: “POST”,
headers: {
“X-Auth-Email” : “[email protected]”,
“X-Auth-Key” : “AUTH_KEY_ID”,
“Content-Type”: “application/json”
json: {
“purge_everything”: “true”

I found a solution thanks to Convert cURL command syntax to Python requests, Ansible URI, browser fetch, MATLAB, Node.js, R, PHP, Strest, Go, Dart, JSON, Elixir, and Rust code, the {“purge_everything”:true} has to go into the body

var request = require('request');

  var headers = {
      'X-Auth-Email': '[email protected]',
      'X-Auth-Key': 'AUTH_KEY',
      'Content-Type': 'application/json'

  var dataString = '{"purge_everything":true}';

  var options = {
      url: 'https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache',
      method: 'POST',
      headers: headers,
      body: dataString

  function callback(error, response, body) {
      if (!error && response.statusCode == 200) {

  request(options, callback);

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.