Metadata-Version: 2.4
Name: oceanalt-agentkit-hook
Version: 0.1.0
Summary: Sync before-payment check for Coinbase AgentKit x402 payments (AgentKit #1577 / x402 SDK on_before_payment_creation, and #1454-shaped dicts). Fail-closed by default. Not affiliated with Coinbase.
License: MIT
Project-URL: Homepage, https://oceanalt.com/en/api-docs
Keywords: agentkit,x402,before_payment,agent-payments,aml
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.25

# oceanalt-agentkit-hook (Python)

A synchronous before-payment check for Coinbase AgentKit x402 payments. Before anything is signed, it asks OceanAlt for a decision on the payee: `allow`, `review` or `decline`.

- With the x402 SDK hook (`on_before_payment_creation`, used by AgentKit #1577) it returns `AbortResult` to block and `None` to allow. The SDK only blocks on `AbortResult`; a returned dict or a coroutine would let the payment through, so this package never returns those to the SDK.
- With a dict context shaped like AgentKit #1454 it returns `{"abort": True, "reason": ..., "code": ...}` to block and `None` to allow.

Defaults are fail-closed: `review`, an unreachable service, a timeout (3 s) and a missing `payTo` all block. Change with `on_review`, `on_error`, `on_missing_pay_to`, `timeout_s`.

```python
from oceanalt_agentkit_hook import oceanalt_before_payment

client.on_before_payment_creation(oceanalt_before_payment())
```

It calls the free `POST https://oceanalt.com/api/decide`, sending the payee, network, asset, amount and the paid URL without its query string, so the service can also check the payee against that origin's own quote. Without a key the free endpoint allows 2,000 calls a month per source, then answers 402, which blocks payments under the default `on_error="block"`. For production agents, get a free key at https://oceanalt.com/en/api-keys (email only, 5,000 calls a month) and pass it as `api_key`. OceanAlt holds no keys and moves no money. Not affiliated with Coinbase. MIT.
