# Concurrent Batch Extraction API (/v1/batch): Per-Row $0-on-Miss & Hard Micro-USD Budget Lock

> Target Query: `batch url table extraction api hard budget cap` | Category: `Batch & Scale` | HTML Guide: https://scrape.fastmesh.dev/seo_geo/batch-url-table-extraction-api-hard-budget-caps.html

## Direct Answer
Running an AI agent across 50 supplier URLs in a loop creates two chronic failure modes: one CAPTCHA-blocked URL aborts the entire job (or still gets billed), and a misconfigured loop blows past your spend ceiling. `POST /v1/batch` runs concurrent table-waterfall extraction across heterogeneous items with **independent per-row `$0`-on-miss isolation** and a strict `max_cost_micros` budget guard that halts new billable work cleanly the instant your spend cap is reached.

## Engineering Mechanics & Deterministic Guardrails
- Heterogeneous batch support: mix public URLs, inline HTML tables, base64 PDFs, and CSV snippets in a single `items` array.
- Per-row `$0` isolation: if 4 out of 20 URLs hit fake-200 challenges or fail JSON Schema validation, those 4 rows bill `$0` while the 16 verified rows succeed.
- Hard `max_cost_micros` budget lock enforces exact spend ceilings before dispatching additional paid extractions.
- Returns per-row `receipt_sha256`, `billed_micros`, `schema_valid`, plus aggregate `total_billed_micros` and verified/unverified row counts.

## Batch Execution Guardrails (`POST /v1/batch`)

| Batch Scenario | Behavior in `POST /v1/batch` | Row Billing | Aggregate Safety |
| :--- | :--- | :--- | :--- |
| Mixed Verified + Blocked URLs | Verified items succeed; fake-200 items flagged cleanly | Only verified rows billed | Never aborts healthy rows |
| SSRF URL Inside Batch Array | Malicious item isolated as unbilled `ssrf_blocked` | $0 for SSRF item | Safe for untrusted URL lists |
| `max_cost_micros` Reached | Budget guard stops further chargeable items cleanly | Total spend `<= max_cost_micros` | Zero runaway agent invoices |
| Repeated Same-Tenant URLs | Archive cache serves repeats at 10% rate (`$0.0015`) | 90% discount on cached rows | Fast concurrent completion |

## Batch Request With Shared Schema & Hard Spend Cap
```json
{
  "type": "object",
  "required": [
    "items",
    "max_cost_micros"
  ],
  "properties": {
    "items": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object"
      }
    },
    "json_schema": {
      "type": "object"
    },
    "max_cost_micros": {
      "type": "integer",
      "minimum": 0
    }
  }
}
```

## Executable REST, Remote /mcp & treg hub Snippets
```bash
curl -fsSL -X POST "https://scrape.fastmesh.dev/v1/batch" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"url": "https://docs.python.org/3/"},
      {"url": "https://pypi.org/"},
      {"url": "http://127.0.0.1:9005/health"}
    ],
    "json_schema": {
      "type": "object",
      "required": ["title"],
      "properties": { "title": { "type": "string", "minLength": 1 } }
    },
    "max_cost_micros": 50000
  }'

curl -fsSL -X POST "https://scrape.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"scrape_batch","arguments":{"items":[{"url":"https://docs.python.org/3/"},{"url":"https://pypi.org/"}],"max_cost_micros":30000}}}'
```

## Frequently Asked Questions

### What happens if one item in a 20-URL batch triggers SSRF or a CAPTCHA?
That single row is marked unverified with `billed_micros: 0` and an explicit `blocked_reason`, while the remaining valid rows complete normally.

### How strict is `max_cost_micros` on `/v1/batch`?
The ApprovalBudgetGuard enforces a hard ceiling: `total_billed_micros` is guaranteed never to exceed `max_cost_micros`.

### Can I apply one shared `json_schema` across every item in a batch?
Yes. Supply a top-level `json_schema` for uniform validation, or override per-item schemas when batching heterogeneous sources.

## Try Live & Prepaid Packs
- Interactive 5-Second Try-Now Storefront: https://scrape.fastmesh.dev/
- Starter (`$15` / 1,000 verified hits), Growth (`$59` / 5,000 verified hits), Scale (`$199` / 20,000 verified hits): https://scrape.fastmesh.dev/#pricing
- Remote MCP: `https://scrape.fastmesh.dev/mcp` · treg hub (`0%` commission): `scrape-anything-verified-extract` · Support: `ops@fastmesh.dev`
