{
  "id": "json-selector-redact",
  "name": "Explicit structural JSON redaction",
  "description": "Remove object members or replace selected JSON subtrees with caller-supplied scalars using bounded typed selectors. Original-snapshot matching, expected-count guards and overlap rejection make edits atomic. Optional audit omission; no secret discovery, PII inference, anonymization or safe-to-share guarantee.",
  "category": "structured",
  "priceUsd": "0.005",
  "pricingStatus": "proposed-unverified",
  "pricing": {
    "unit": "one successful operation call",
    "proposedNominalUsd": "0.005",
    "sixDecimalTokenBaseUnits": "5000",
    "subscription": false,
    "includesPayerWalletOrNetworkFees": false,
    "liveQuoteVerified": false,
    "condition": "Actual SDK challenge is authoritative only within the caller's explicit authorization; configured six-decimal token peg is an operator assertion, not a conversion guarantee."
  },
  "intents": [
    "redact explicit JSON fields across repeated records",
    "remove selected object members with expected match counts",
    "replace structured JSON subtrees with explicit scalar placeholders"
  ],
  "whenToUse": [
    "Caller knows which structural fields must be removed or replaced",
    "Guard a repeated-record cleanup with exact match counts and simultaneous edits"
  ],
  "whenNotToUse": [
    "Discover secrets or infer personal information from meaning",
    "Guarantee anonymity or that remaining data is safe to share",
    "Apply arbitrary JSONPath, regex, recursive descent or scripts",
    "Remove array elements or reorder their identity",
    "Known exact-pointer edits already fit JSON Patch",
    "Read files, send documents, fetch data or change external state"
  ],
  "capabilities": [
    "Declared profile: explicit-structural-redaction-v1",
    "Typed key/index/anyKey/anyIndex selectors with exact own-property matching",
    "Resolve against the original snapshot, guard match counts, reject duplicate and ancestor targets, then clone",
    "Audit contains only caller rule IDs, escaped JSON Pointer paths, action names and counts; includeAudit=false omits both audit and counts",
    "Audit paths/counts and the retained document can expose sensitive structure; callers control replacement values",
    "Deterministic input-only result; no network, clock, randomness, filesystem or runtime dependencies"
  ],
  "limits": {
    "inputBytes": 100000,
    "outputBytes": 400000,
    "jsonNodes": 12000,
    "depth": 20,
    "rules": 64,
    "selectorTokens": 20,
    "selectedTargets": 2000,
    "selectorVisits": 250000,
    "profile": "explicit-structural-redaction-v1",
    "ruleIdScalars": 64,
    "selectorIndexMaximum": 9007199254740991
  },
  "errorCodes": [
    "INPUT_LIMIT",
    "OUTPUT_LIMIT",
    "COMPLEXITY_LIMIT",
    "INVALID_JSON",
    "INVALID_NUMBER",
    "INVALID_UNICODE",
    "UNSAFE_KEY",
    "INVALID_INPUT",
    "DUPLICATE_RULE_ID",
    "INVALID_MATCH_BOUNDS",
    "SELECTOR_VISIT_LIMIT",
    "MATCH_COUNT",
    "TARGET_LIMIT",
    "INVALID_REMOVE_TARGET",
    "TARGET_CONFLICT"
  ],
  "related": [
    "json-patch",
    "pii-redact",
    "json-batch-encode"
  ],
  "requirementsProfile": {
    "format": "declared-requirements-v1",
    "facts": {
      "execution.suppliedCode": false,
      "execution.remoteMutation": false,
      "execution.llmInference": false,
      "execution.paidMcp": false,
      "verification.semanticTruth": false,
      "verification.sourceAuthenticity": false,
      "verification.liveVulnerabilities": false,
      "numbers.arbitraryPrecisionJson": false,
      "numbers.model": "ieee754-binary64",
      "privacy.requestBodyPersisted": false,
      "execution.deterministic": true,
      "execution.networkAccess": false,
      "privacy.resultBodyPersisted": false,
      "payment.x402": true,
      "payment.mpp": true,
      "operation.id": "json-selector-redact",
      "operation.category": "structured",
      "limit.httpRequestBytes": 131072,
      "limit.requestBytes": 100000,
      "limit.responseBytes": 524288,
      "limit.resultBytes": 400000,
      "limit.jsonDepth": 20,
      "limit.jsonNodes": 12000,
      "selectorRedaction.profile": "explicit-structural-redaction-v1",
      "selectorRedaction.maxRules": 64,
      "selectorRedaction.maxSelectorTokens": 20,
      "selectorRedaction.maxTargets": 2000,
      "selectorRedaction.maxVisits": 250000,
      "selectorRedaction.matchSnapshot": "original-document",
      "selectorRedaction.conflictPolicy": "reject-duplicate-and-ancestor-targets",
      "selectorRedaction.auditOptional": true,
      "selectorRedaction.arrayElementRemoval": false,
      "selectorRedaction.recursiveDescent": false,
      "selectorRedaction.jsonpath": false,
      "selectorRedaction.piiDetection": false,
      "selectorRedaction.completeAnonymization": false,
      "selectorRedaction.sharingSafetyCertified": false,
      "selectorRedaction.artifactLocation": "result.document",
      "selectorRedaction.envelopeIncludesOriginalRequestSha256": true,
      "selectorRedaction.auditOmissionRemovesEnvelopeProvenance": false,
      "selectorRedaction.wholeResponseSanitized": false,
      "selectorRedaction.requestDigestMayExposeGuessableInputs": true,
      "input.rules.maxItems": 64,
      "input.rules.minItems": 1
    },
    "unknownPolicy": "Undeclared requirements are unknown, never compatible. Matching declared facts does not establish semantic fit or input validity.",
    "preflight": "/preflight"
  },
  "documentation": "/reference/tools/json-selector-redact.md",
  "serviceContract": "/reference/services/json-selector-redact.json",
  "errors": [
    {
      "status": 400,
      "meaning": "Malformed JSON, missing/invalid idempotency key, or payment identifier mismatch",
      "retry": "Correct the request before payment"
    },
    {
      "status": 402,
      "meaning": "Payment challenge or rejected payment",
      "retry": "Use official protocol SDK; inspect payment outcome before another payment"
    },
    {
      "status": 409,
      "meaning": "Idempotency conflict, duplicate proof, or PAYMENT_UNCERTAIN",
      "retry": "Keep original key, body, and proof; reconcile uncertainty with operator; never blindly repay"
    },
    {
      "status": 413,
      "meaning": "Input or generated output too large",
      "retry": "Reduce input; no payment attempted for validation failure"
    },
    {
      "status": 415,
      "meaning": "Unsupported media type or compression",
      "retry": "Send uncompressed application/json"
    },
    {
      "status": 422,
      "meaning": "Schema or service-specific semantic validation failure",
      "retry": "Correct input using returned error code; no payment attempted"
    },
    {
      "status": 429,
      "meaning": "Request/payment-attempt rate exceeded",
      "retry": "Wait for rate limit window; preserve existing payment identity"
    },
    {
      "status": 503,
      "meaning": "Payment configuration/provider/state unavailable, or live DNS preparation failed before settlement",
      "retry": "Check readiness; DNS preparation failures may retry the identical key/body/credential only; uncertainty requires reconciliation"
    }
  ],
  "numericPrecision": "JavaScript IEEE-754 numbers; use strings for large integer IDs/exact decimals where the schema accepts strings. No lossless numeric parsing.",
  "paymentWorkflow": {
    "discoveryOnly": false,
    "supportedProtocols": [
      "x402",
      "mpp"
    ],
    "x402": {
      "credentialHeader": "PAYMENT-SIGNATURE",
      "challengeHeader": "PAYMENT-REQUIRED",
      "receiptHeader": "PAYMENT-RESPONSE",
      "version": 2,
      "scheme": "exact",
      "paymentIdentifier": "payment-identifier extension MUST equal the HTTP Idempotency-Key",
      "sdk": "@x402/core with @x402/evm"
    },
    "mpp": {
      "supported": true,
      "credentialHeader": "Authorization",
      "challengeHeader": "WWW-Authenticate",
      "receiptHeader": "Payment-Receipt",
      "method": "tempo",
      "intent": "charge",
      "sdk": "mppx",
      "tokenDecimals": 6
    },
    "steps": [
      "Check configured readiness and the exact service schema",
      "Generate a fresh random Idempotency-Key for this operation; never use a discovery probe fixture for purchases",
      "Send valid input without a credential to obtain the official protocol challenge",
      "Use the official SDK and authorized wallet to fulfill the challenge",
      "Retry only with identical key, body, protocol and credential",
      "On PAYMENT_UNCERTAIN stop and request operator reconciliation; never blindly pay again"
    ],
    "versionedRetries": "Request fingerprint includes service release version. Retries across a version upgrade can conflict; coordinate upgrades outside the 24-hour replay window and reconcile pending attempts.",
    "docs": "/llms.txt"
  },
  "method": "POST",
  "paths": {
    "x402": "/v1/x402/json-selector-redact",
    "mpp": "/v1/mpp/json-selector-redact"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "document": {
        "$ref": "#/$defs/__schema0"
      },
      "rules": {
        "minItems": 1,
        "maxItems": 64,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[\\s\\S]{1,64}(?![\\s\\S])"
            },
            "select": {
              "maxItems": 20,
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "key"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "index"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "anyKey": {
                        "type": "boolean",
                        "const": true
                      }
                    },
                    "required": [
                      "anyKey"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "anyIndex": {
                        "type": "boolean",
                        "const": true
                      }
                    },
                    "required": [
                      "anyIndex"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            },
            "action": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "replace"
                    },
                    "value": {
                      "type": [
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "type",
                    "value"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "remove"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "minMatches": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            },
            "maxMatches": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          },
          "required": [
            "id",
            "select",
            "action",
            "minMatches",
            "maxMatches"
          ],
          "additionalProperties": false
        }
      },
      "includeAudit": {
        "type": "boolean"
      }
    },
    "required": [
      "document",
      "rules"
    ],
    "additionalProperties": false,
    "$defs": {
      "__schema0": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/$defs/__schema0"
            }
          },
          {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "$ref": "#/$defs/__schema0"
            }
          }
        ]
      }
    }
  },
  "outputSchema": {
    "type": "object",
    "required": [
      "operation",
      "version",
      "result",
      "provenance"
    ],
    "properties": {
      "operation": {
        "const": "json-selector-redact",
        "type": "string"
      },
      "version": {
        "const": "0.29.0",
        "type": "string"
      },
      "result": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "document": {
                "$ref": "#/properties/result/$defs/__schema0"
              }
            },
            "required": [
              "document"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "document": {
                "$ref": "#/properties/result/$defs/__schema1"
              },
              "audit": {
                "maxItems": 2000,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "ruleId": {
                      "type": "string"
                    },
                    "path": {
                      "type": "string"
                    },
                    "action": {
                      "type": "string",
                      "enum": [
                        "replace",
                        "remove"
                      ]
                    }
                  },
                  "required": [
                    "ruleId",
                    "path",
                    "action"
                  ],
                  "additionalProperties": false
                }
              },
              "counts": {
                "minItems": 1,
                "maxItems": 64,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "ruleId": {
                      "type": "string"
                    },
                    "matches": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 2000
                    }
                  },
                  "required": [
                    "ruleId",
                    "matches"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "document",
              "audit",
              "counts"
            ],
            "additionalProperties": false
          }
        ],
        "$defs": {
          "__schema0": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/properties/result/$defs/__schema0"
                }
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "$ref": "#/properties/result/$defs/__schema0"
                }
              }
            ]
          },
          "__schema1": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/properties/result/$defs/__schema1"
                }
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "$ref": "#/properties/result/$defs/__schema1"
                }
              }
            ]
          }
        }
      },
      "provenance": {
        "type": "object",
        "required": [
          "inputSha256",
          "outputSha256",
          "deterministic",
          "externalRequests"
        ],
        "properties": {
          "inputSha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "outputSha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "deterministic": {
            "const": true
          },
          "externalRequests": {
            "const": 0
          }
        }
      }
    },
    "additionalProperties": false
  },
  "exampleInput": {
    "document": {
      "users": [
        {
          "email": "a@example.invalid",
          "name": "A"
        },
        {
          "email": "b@example.invalid",
          "name": "B"
        }
      ]
    },
    "rules": [
      {
        "id": "email",
        "select": [
          {
            "key": "users"
          },
          {
            "anyIndex": true
          },
          {
            "key": "email"
          }
        ],
        "action": {
          "type": "replace",
          "value": "[REDACTED]"
        },
        "minMatches": 2,
        "maxMatches": 2
      }
    ]
  },
  "exampleResponse": {
    "operation": "json-selector-redact",
    "version": "0.29.0",
    "result": {
      "document": {
        "users": [
          {
            "email": "[REDACTED]",
            "name": "A"
          },
          {
            "email": "[REDACTED]",
            "name": "B"
          }
        ]
      },
      "audit": [
        {
          "ruleId": "email",
          "path": "/users/0/email",
          "action": "replace"
        },
        {
          "ruleId": "email",
          "path": "/users/1/email",
          "action": "replace"
        }
      ],
      "counts": [
        {
          "ruleId": "email",
          "matches": 2
        }
      ]
    },
    "provenance": {
      "inputSha256": "c13cf62b63cbaafe9d7c6aa847143adc63520cd1abf7abf76ac9b552aa4de723",
      "outputSha256": "3cb2f0624e5a91719650e702ddc997419a88216846b14e80be844bb1119eb33c",
      "deterministic": true,
      "externalRequests": 0
    }
  },
  "requiredHeaders": {
    "Content-Type": "application/json",
    "Idempotency-Key": "random 16–128 character operation identifier"
  },
  "fixedExample": "/reference/examples/json-selector-redact.json",
  "execution": {
    "deterministic": true,
    "externalRequests": 0,
    "maxExternalRequests": 0,
    "resultSnapshotPersisted": false,
    "fixedExampleIsIllustrativeSnapshot": false,
    "requiresPayment": true,
    "supportsMcpExecution": false
  },
  "releaseSnapshot": {
    "format": "static-release-reference-v1",
    "sourceVersion": "0.29.0",
    "sourceRegistrySha256": "a2b5ec09bf6c38b9d2879d746a4fded374f5928b445377b0270ef6aa8e6cac65",
    "generatedAt": "2026-10-06T15:38:00Z",
    "releaseAcceptance": "not-verified-by-generator",
    "runtimeReadiness": "not-evaluated",
    "livePaymentsVerified": false,
    "indexingVerified": false,
    "apiOrigin": null,
    "notice": "Build-time release reference. Runtime readiness, deployment, payment settlement and external indexing are not evaluated here. Prices are proposed; this file cannot authorize execution or payment."
  }
}
