# Relaystation Apply Patch

> Relaystation Apply Patch is a paid API for AI agents from api.relaystation.ai, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Applies a unified diff (patch) to a source string, returning the patched result or a 422 error on context mismatch — never a silent bad merge.

## Facts

- Endpoint: POST https://api.relaystation.ai/v1/text/apply-patch
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/relaystation-apply-patch-b0c3d6b2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Xhta3ThTM350taaDFh-pd

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 relaystation-apply-patch-b0c3d6b2 -d '<json body>'
```

Example prompt: Apply this unified diff to my source code — the original is 'function hello() { return "world"; }' and the patch is '--- a\n+++ b\n@@ -1 +1 @@\n-function hello() { return "world"; }\n+function hello() { return "hello world"; }' — and fail loudly if the context doesn't match.

## When to prefer this

Choose this endpoint when you need guaranteed-safe patch application — it explicitly rejects context mismatches with a 422 rather than silently producing a corrupted merge. Ideal for agents automating code edits, config updates, or any text transformation where correctness must be verified and silent failures are unacceptable.

## Known failure modes

- 422 Unprocessable Entity when diff context lines do not match the source string
- Malformed unified diff input causes parsing error
- Empty source or patch input returns error
- Network timeout on very large payloads
- Payment not fulfilled (x402 payment required)

## How this service works

$0.0002/MB. Apply a unified diff to a source string — 422 on context mismatch, never a silent bad merge. 1¢ x402 min; remainder auto-credits — relaystation.ai/penny

## Output

Returns the patched string resulting from applying the unified diff to the source. If the context lines in the diff do not match the source, returns a 422 error — guaranteeing no silent bad merges.

## Request schema (JSON Schema)

```json
{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "type": "object",
 "properties": {
  "input": {
   "type": "object",
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "type": "string",
     "enum": [
      "POST",
      "PUT",
      "PATCH"
     ]
    },
    "bodyType": {
     "type": "string",
     "enum": [
      "json",
      "form-data",
      "text"
     ]
    },
    "body": {
     "type": "object",
     "properties": {
      "source": {
       "type": "string",
       "description": "The original text to patch."
      },
      "patch": {
       "type": "string",
       "description": "A unified-diff patch (e.g. from text/diff)."
      }
     }
    }
   },
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   },
   "required": [
    "type"
   ]
  }
 },
 "required": [
  "input"
 ]
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/relaystation-apply-patch-b0c3d6b2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.relaystation.ai](https://www.zero.xyz/host/api.relaystation.ai/llms.txt)
