# SDKs and tools

Every public Provenance package, from the Node and Python SDKs and offline verifiers to the CLI, the MCP server, agent framework packages, payment rails, Identify middleware and native capture and consent libraries.

The SDKs are typed clients for the Provenance API, for Node and Python, that add the key, retry rate-limited and failed requests, and turn error responses into typed exceptions. Around them sit smaller packages for one job each: verifiers that check a token offline with no API key, the CLI, the MCP server, packages that gate agent framework tools, payment rails, Identify middleware and native libraries for capture and consent.

## When to use it

- Call Provenance from your backend with less code than raw HTTP.
- Check intent tokens, receipts or webhook signatures in your own service.
- Give an agent Provenance as tools, with [Provenance MCP](https://provenanceauth.com/docs/provenance-mcp.md), or gate the tools of the framework you already use.

## Packages

Every package shares one version number.

### API clients and verifiers

| Package | Runs on | For |
| --- | --- | --- |
| `@provenanceauth/sdk` | Node 18 and later, and browsers | The full API, plus offline verifiers and webhook signature checks |
| `provenanceauth-sdk` | Python 3.10 and later | The main API resources, plus the same verifiers |
| `provenanceauth-verify` | Python 3.10 and later | [Offline token checks](https://provenanceauth.com/docs/sdks/verify.md) only |
| `go.provenanceauth.com/verify` | Go 1.26 and later | Offline token checks only; not published yet, its source is in the Provenance repository |

**This package isn't on npm yet. These packages aren't on PyPI yet.** Until then, every request in these docs runs over HTTP against the [sandbox](https://provenanceauth.com/docs/get-started/sandbox.md).

With access to the private Provenance repository, which your Provenance contact grants, install from it:

```bash
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-sdk-1.0.0.tgz
```

```bash
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
pip install ./provenance/python/sdk ./provenance/python/verify
```

### Tools

| Package | Runs on | For |
| --- | --- | --- |
| `@provenanceauth/cli` | Node 20 and later | The [CLI](https://provenanceauth.com/docs/get-started/cli.md): forward sandbox events to a local URL and resend webhook deliveries |
| `@provenanceauth/mcp-server` | Any MCP client | The agent tools over stdio ([agent tools](https://provenanceauth.com/docs/provenance-mcp/agent-tools.md)) |
| `@provenanceauth/connect` | Node 18 and later | Connect an AI assistant to Provenance in one step: writes its MCP config, and for Claude Code adds a hook that asks before risky tool calls ([connect your assistant](https://provenanceauth.com/help/personal/guides/connect-your-assistant)) |

**These packages aren't on npm yet.** Until then, every request in these docs runs over HTTP against the [sandbox](https://provenanceauth.com/docs/get-started/sandbox.md).

With access to the private Provenance repository, which your Provenance contact grants, install from it:

```bash
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-cli-1.0.0.tgz ../provenance-packs/provenanceauth-sdk-1.0.0.tgz ../provenance-packs/provenanceauth-rails-1.0.0.tgz ../provenance-packs/provenanceauth-mcp-server-1.0.0.tgz
```

### Agent frameworks

| Package | Runs on | For |
| --- | --- | --- |
| `@provenanceauth/agent-adapters` | Node 18 and later | [Gating agent tools](https://provenanceauth.com/docs/mandate/guides/framework-integrations.md) in your own loop or on an MCP server |
| `@provenanceauth/ai-sdk` | Node, with `ai` 5, 6 or 7 (`>=5 <8`) | [Gating Vercel AI SDK tools](https://provenanceauth.com/docs/mandate/guides/vercel-ai-sdk.md) |
| `@provenanceauth/langchain` | Node, with `@langchain/core` 0.3 or 1.x (`>=0.3 <2`) | [Gating LangChain tools](https://provenanceauth.com/docs/mandate/guides/langchain.md) |
| `provenanceauth-langchain` | Python 3.10 and later, with `langchain-core` 0.3 or 1.x (`>=0.3,<2`) | [Gating LangChain tools](https://provenanceauth.com/docs/mandate/guides/langchain.md) |
| `@provenanceauth/claude-agent-sdk` | Node 18 and later, with `@anthropic-ai/claude-agent-sdk` (`>=0.2 <0.4`) | [Gating Claude Agent SDK tools](https://provenanceauth.com/docs/mandate/guides/claude-agent-sdk.md) |
| `provenanceauth-claude-agent-sdk` | Python 3.10 and later | [Gating Claude Agent SDK tools](https://provenanceauth.com/docs/mandate/guides/claude-agent-sdk.md) |
| `@provenanceauth/openai-agents` | Node 18 and later, with `@openai/agents` (`>=0.8 <1`) | [Gating OpenAI Agents SDK tools](https://provenanceauth.com/docs/mandate/guides/openai-agents-sdk.md) |
| `provenanceauth-openai-agents` | Python 3.10 and later | [Gating OpenAI Agents SDK tools](https://provenanceauth.com/docs/mandate/guides/openai-agents-sdk.md) |
| `provenanceauth-google-adk` | Python 3.10 and later | [Gating Google ADK tools](https://provenanceauth.com/docs/mandate/guides/google-adk.md) |
| `provenanceauth-crewai` | Python 3.10 and later | [Gating CrewAI tools](https://provenanceauth.com/docs/mandate/guides/crewai.md) |

Each framework guide has its install line.

### Stores, sites and claims systems

| Package | Runs on | For |
| --- | --- | --- |
| `@provenanceauth/rails` | Node | Verify agent orders where agents pay: checkout, ACP, x402 and AP2 bindings, deals, tabs, grants and disputes ([agent payments](https://provenanceauth.com/docs/authorize/guides/agent-payments.md)) |
| `@provenanceauth/identify` | Node 18 and later, Cloudflare Workers, Vercel Edge | [Identify middleware](https://provenanceauth.com/docs/identify/guides/verify-signed-agents.md): name signed agents and likely bots, and apply your traffic policy in-process |
| `provenanceauth-identify` | Python 3.10 and later | The same middleware for FastAPI, Starlette and Django |
| `@provenanceauth/connectors` | Node | [Claim-system connectors](https://provenanceauth.com/docs/attest/guides/connectors.md) for Guidewire ClaimCenter and Duck Creek Claims |

**These packages aren't on npm yet. This package isn't on PyPI yet.** Until then, every request in these docs runs over HTTP against the [sandbox](https://provenanceauth.com/docs/get-started/sandbox.md).

With access to the private Provenance repository, which your Provenance contact grants, install from it:

```bash
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-sdk-1.0.0.tgz ../provenance-packs/provenanceauth-rails-1.0.0.tgz ../provenance-packs/provenanceauth-identify-1.0.0.tgz ../provenance-packs/provenanceauth-connectors-1.0.0.tgz
```

```bash
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
pip install ./provenance/python/sdk ./provenance/python/identify
```

### Apps on a phone

| Package | Runs on | For |
| --- | --- | --- |
| `@provenanceauth/react-native` | React Native 0.74 and later, Expo 51 and later | [Capture on a phone](https://provenanceauth.com/docs/attest/guides/native-sdk.md): photos signed in the phone's secure hardware |
| `ProvenanceTextConsent` | iOS 16 and later, Swift Package Manager | [The consent step and box](https://provenanceauth.com/docs/messaging/text-consent/swift.md) in your own iOS app |
| `com.provenanceauth:text-consent` | Android | [The consent step and box](https://provenanceauth.com/docs/messaging/text-consent/kotlin.md) in your own Android app |

Each of these guides has its install line.

## Reference

Every method, generated from the SDK sources, with its signature, the HTTP operation it calls, the errors it can return and an example:

| Reference | Covers |
| --- | --- |
| [Node SDK](https://provenanceauth.com/docs/sdks/node.md) | `@provenanceauth/sdk`, by namespace |
| [Python SDK](https://provenanceauth.com/docs/sdks/python.md) | `provenanceauth-sdk`, by namespace |
| [Rails](https://provenanceauth.com/docs/sdks/rails.md) | `@provenanceauth/rails` and its subpaths: checkout, ACP, x402, AP2, deals, tabs, mandates, disputes, discovery |
| [Verifiers](https://provenanceauth.com/docs/sdks/verify.md) | The offline verifiers for TypeScript, Python and Go |

## How it works

1. **Create a client** with your key and the API's base URL.
2. **Call a resource method.** Node takes and returns camelCase; Python takes and returns the API's snake_case.
3. **Errors become exceptions.** `429` and `5xx` responses are retried up to three times with exponential backoff, honoring `Retry-After`. Any other error raises a typed exception at once.

## Make a call and handle an error

**curl**

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe

curl $PROVENANCE_API/v1/attest/claims/CLM-DOES-NOT-EXIST/provenance \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
import { NotFoundError, Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
try {
  await prov.attest.claims.getProvenance("CLM-DOES-NOT-EXIST");
} catch (err) {
  if (err instanceof NotFoundError) console.log(err.code, err.param, err.requestId);
  else throw err;
}
```

**Python**

```python
import os
from provenanceauth import Provenance
from provenanceauth.errors import NotFoundError

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
try:
    prov.attest.claims.get_provenance("CLM-DOES-NOT-EXIST")
except NotFoundError as err:
    print(err.code, err.param, err.request_id)
```

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "resource_missing",
    "message": "No such claim: 'CLM-DOES-NOT-EXIST'",
    "param": "claim_id"
  }
}
```

Each error `type` has its own exception class:

| `type` | Exception |
| --- | --- |
| `authentication_error` | `AuthenticationError` |
| `permission_error` | `PermissionError` |
| `invalid_request_error` | `InvalidRequestError`, or `NotFoundError` for `resource_missing` |
| `rate_limit_error` | `RateLimitError`, after the retries run out |
| `billing_error` | `BillingError`, with `billing` on `trial_ended`, `spend_cap_reached` and `seat_limit_reached` |
| `api_error`, `unavailable_error` | `ApiError`, `UnavailableError` |

Every exception carries the fields of the [error body](https://provenanceauth.com/docs/platform/errors.md), such as `code` and `request_id`. A request that never reached the API raises `ConnectionError`.

The client takes these options:

- `apiKey / api_key` (string): Your key. Required.
- `baseUrl / base_url` (string): The API's base URL. Always set it; these docs use `PROVENANCE_API`.
- `maxRetries / max_retries` (integer): Retries for `429` and `5xx`. Default 3; 0 turns retries off.
- `retryBaseMs / retry_base_ms` (integer): The first backoff, in milliseconds, doubled on each retry. Default 250.

The Python SDK covers the main resources. For endpoints it doesn't wrap yet, such as cases, agents and agreements, the guides call the API with `httpx`.

## Verify without an API key

The verifier functions check a token's signature and expiry against the published keys. They're in both SDKs, and in the verifier-only libraries for Python and Go:

**Node**

```ts
import { fetchJwks, verifyIntentTokenOffline } from "@provenanceauth/sdk";

const jwks = await fetchJwks(process.env.PROVENANCE_API!);
const result = await verifyIntentTokenOffline(token, jwks);
```

**Python**

```python
from provenanceauth_verify import fetch_jwks, verify_intent_token

jwks = fetch_jwks(os.environ["PROVENANCE_API"])
result = verify_intent_token(token, jwks)
```

**Go**

```go
import pv "go.provenanceauth.com/verify"

jwks, err := pv.FetchJWKS(os.Getenv("PROVENANCE_API"))
result := pv.VerifyIntentToken(token, jwks, 0)
```

An offline check can't see revocations or check the payload; see [verify tokens offline](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md) for what to add. Both SDKs also check webhook signatures, with `verifyWebhookSignature` and `verify_webhook_signature`; see [webhooks](https://provenanceauth.com/docs/integrate/webhooks.md).

Every library is tested against the same committed test vectors for token signatures and canonical JSON, so a payload hashes the same in every language. To port the format to another language, pass those vectors.

## Related

- [CLI](https://provenanceauth.com/docs/get-started/cli.md)
- [Example apps](https://provenanceauth.com/docs/get-started/example-apps.md)
- [Choose your path](https://provenanceauth.com/docs/get-started/choose-your-path.md)
- [Verify tokens offline](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md)
- [Errors](https://provenanceauth.com/docs/platform/errors.md)
