# agent402.tools Atomic Increment/Decrement Counter

> agent402.tools Atomic Increment/Decrement Counter is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Atomically increments or decrements a named numeric counter key and returns the new value, creating it at zero if it doesn't exist.

## Facts

- Endpoint: POST https://agent402.tools/api/memory/incr
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-atomic-increment-decrement-counter-be5c85b6
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Omxswu_wdq7BLbli73vci

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 agent402-tools-atomic-increment-decrement-counter-be5c85b6 -d '<json body>'
```

Example prompt: Increment the shared counter key 'jobs_processed' by 1 and give me the new value — create it at zero if it doesn't exist yet.

## When to prefer this

Use this endpoint when you need a guaranteed atomic increment or decrement of a shared numeric counter across multiple concurrent agents or processes. It is ideal for distributed rate budgets, job counters, lock acquisition counters, or any coordination primitive where race conditions must be avoided. Prefer this over simple key reads followed by writes when atomicity is required.

## Known failure modes

- Key not found and creation fails due to namespace permissions
- Invalid or non-numeric increment value in 'by' field
- Owner namespace provided without a valid readwrite grant — returns authorization error
- Network or service unavailability causing the atomic operation to fail
- Negative amount causes underflow below expected floor if not guarded by caller logic

## How this service works

Atomically increment (or decrement) a numeric key and return the new value - a coordination primitive for counters, locks, and rate budgets shared across agents. Creates the key at 0 if absent.

## Output

Returns the new integer value of the counter after the atomic increment or decrement has been applied. If the key did not exist before, it is initialized to 0 and then the delta is applied.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "by": {
   "type": "number",
   "description": "Amount to add (default 1; negative to decrement)"
  },
  "key": {
   "type": "string",
   "description": "Counter key"
  },
  "owner": {
   "type": "string",
   "description": "Optional 0x namespace (requires a readwrite grant)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "key": "jobs/processed",
  "owner": "0x…",
  "value": 43
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-atomic-increment-decrement-counter-be5c85b6/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
