---
title: Create or update a filtering rule
slug: reference/create-or-update-a-filtering-rule
createdAt: 2025-01-21T18:39:14.860Z
---

{
  "id": "IuWOSfdBnbSgxd5aQRUFJ",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/ingest-snapshot/custom-filtering-rules",
    "servers": [
      {
        "url": "https://app.amberflo.io/ingest-snapshot/custom-filtering-rules"
      }
    ],
    "name": "Create or update a filtering rule",
    "description": "<p>Creates or updates a custom filtering rule for bulk cancellation of ingested meter events. Use this endpoint to retroactively remove incorrectly ingested usage data from your meters.</p>\n<p>Common use cases:</p>\n<ul>\n<li>Remove events from system-wide errors or outages</li>\n<li>Cancel events from failed or unintended usage</li>\n<li>Filter out test data that was accidentally sent to production</li>\n<li>Bulk correct meter events based on time ranges and dimensions</li>\n</ul>\n<p>Filtering rules specify criteria including time range, meter API name, and optional dimension values to precisely target events for removal.</p>\n<p><strong>Important:</strong> Filtering rules are permanent and cannot be undone. Review criteria carefully before applying as this affects historical usage data and billing calculations.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "Filtering rule for excluding specific ingestion data from S3 snapshots based on property criteria",
          "customType": "ingestion.s3_snapshot.filtering_rules.ByPropertyFilteringOutRule.in",
          "schema": [
            {
              "name": "type",
              "kind": "optional",
              "type": "string",
              "description": "Rule type identifier specifying the filtering mechanism to apply",
              "example": ""
            },
            {
              "name": "id",
              "kind": "optional",
              "type": "string",
              "description": "Unique identifier for this filtering rule configuration",
              "example": ""
            },
            {
              "name": "ingestionTimeRange",
              "kind": "optional",
              "type": "object",
              "description": "Time range specification for which ingestion data should be filtered",
              "modelRef": "#/components/schemas/ingestion.s3_snapshot.common.TimeRange.in",
              "customType": "ingestion.s3_snapshot.common.TimeRange.in",
              "schema": [
                {
                  "name": "startTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "description": "Beginning timestamp in Unix time seconds for snapshot data ingestion range",
                  "example": 0
                },
                {
                  "name": "endTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "description": "Ending timestamp in Unix time seconds for snapshot data ingestion range",
                  "example": 0
                }
              ]
            },
            {
              "name": "meterApiName",
              "kind": "optional",
              "type": "string",
              "description": "Meter API name to filter by, excluding data from this specific meter",
              "example": ""
            },
            {
              "name": "dimensionValuesMap",
              "kind": "optional",
              "type": "map",
              "description": "Map of dimension names to arrays of values that should be excluded from snapshots",
              "example": "",
              "customType": "map<string, string[]>",
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/ingestion.s3_snapshot.filtering_rules.ByPropertyFilteringOutRule.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "S3 snapshot filtering rule output configuration specifying exclusion criteria based on ingestion properties",
            "customType": "ingestion.s3_snapshot.filtering_rules.ByPropertyFilteringOutRule.out",
            "schema": [
              {
                "name": "type",
                "kind": "optional",
                "type": "string",
                "description": "Classification identifier for the specific filtering rule type being applied",
                "example": ""
              },
              {
                "name": "id",
                "kind": "optional",
                "type": "string",
                "description": "Unique identifier for this custom filtering rule configuration within the snapshot system",
                "example": ""
              },
              {
                "name": "ingestionTimeRange",
                "kind": "optional",
                "type": "object",
                "description": "Time period boundaries defining when this filtering rule applies to ingested data",
                "modelRef": "#/components/schemas/ingestion.s3_snapshot.common.TimeRange.out",
                "customType": "ingestion.s3_snapshot.common.TimeRange.out",
                "schema": [
                  {
                    "name": "startTimeInSeconds",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "description": "Beginning timestamp in Unix time seconds for snapshot data ingestion range",
                    "example": 0
                  },
                  {
                    "name": "endTimeInSeconds",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "description": "Ending timestamp in Unix time seconds for snapshot data ingestion range",
                    "example": 0
                  }
                ]
              },
              {
                "name": "meterApiName",
                "kind": "optional",
                "type": "string",
                "description": "API identifier of the meter whose data should be excluded from snapshot processing",
                "example": ""
              },
              {
                "name": "dimensionValuesMap",
                "kind": "optional",
                "type": "map",
                "description": "Mapping of dimension names to arrays of values that trigger data exclusion when matched",
                "example": "",
                "customType": "map<string, string[]>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/ingestion.s3_snapshot.filtering_rules.ByPropertyFilteringOutRule.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/ingest-snapshot/custom-filtering-rules \\\n     --header 'accept: application/json'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/ingest-snapshot/custom-filtering-rules\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/ingest-snapshot/custom-filtering-rules\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/ingest-snapshot/custom-filtering-rules\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful request\n{\n  \"type\": \"\",\n  \"id\": \"\",\n  \"ingestionTimeRange\": {\n    \"startTimeInSeconds\": \"\",\n    \"endTimeInSeconds\": \"\"\n  },\n  \"meterApiName\": \"\",\n  \"dimensionValuesMap\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": "",
      "id": "v1qH-fcuWzmUEcZsI_apy"
    }
  ]
}