# Text Diff (Before/After Comparison)

> Text Diff (Before/After Comparison) is a paid API for AI agents from x402-gateway-production-1f21.up.railway.app, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-12).

Computes a deterministic diff between two text strings, returning structured change information for detecting what content was added, removed, or modified.

## Facts

- Endpoint: POST https://x402-gateway-production-1f21.up.railway.app/text/diff?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/text-diff-before-after-comparison-3db3ea37
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_KzIG8-Vn0sdHnaJpqDfjt

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability text-diff-before-after-comparison-3db3ea37 -d '<json body>'
```

Example prompt: Compare these two versions of our privacy policy and tell me exactly what changed — here's the old version: 'We collect your email and usage data.' and the new version: 'We collect your email, location, and usage data, and share it with partners.'

## When to prefer this

Choose this endpoint when you need a deterministic, machine-readable diff between two text snapshots — especially for automated change monitoring pipelines (e.g. tracking webpage content, policy documents, pricing pages). Prefer it over manual string comparison when you need structured output suitable for RAG ingestion or downstream processing. It is pay-per-call at $0.001 USDC via x402, making it cost-effective for high-frequency monitoring agents.

## Known failure modes

- Input text exceeding 125,000 characters returns a validation error
- Missing 'before' or 'after' fields causes a 400 bad request
- Invalid bodyType (not json, form-data, or text) causes request rejection
- Payment failure via x402 protocol results in 402 response before processing
- Empty strings for both before and after may return an empty diff

## How this service works

Machine-payable x402 utilities for hashing, Base64, UUID generation, unit and timezone conversion, realtime crypto market data, webpage/document extraction, URL-to-Markdown, metadata, RAG ingestion and deterministic website change detection.

## Output

A JSON response with status and structured diff output indicating what text content was added, removed, or modified between the 'before' and 'after' inputs. The result is deterministic — identical inputs always produce identical output.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "type": "object",
     "required": [
      "before",
      "after"
     ],
     "properties": {
      "after": {
       "type": "string",
       "maxLength": 125000
      },
      "before": {
       "type": "string",
       "maxLength": 125000
      }
     },
     "additionalProperties": false
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "status": "ready"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-diff-before-after-comparison-3db3ea37/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-gateway-production-1f21.up.railway.app](https://www.zero.xyz/host/x402-gateway-production-1f21.up.railway.app/llms.txt)
