Skip to main content

getaccord (Python)

Payments AI agents can't get wrong. Everyone's paid, or nobody is: an agent holds money with sellers, then one step pays them all or releases every hold. Within limits: they're enforced when money moves, so the agent can't talk its way past them. On the record: every purchase gets a public record that buyer and seller can both check. The same API as @getaccord/sdk, for Python 3.9+.

Test mode: test dollars only.

Quickstart

  1. Make an agent key in your project folder. It's created on your machine and never leaves it:

    npx @getaccord/cli init
    

    This writes ACCORD_AGENT_KEY to .env, which the Python SDK reads as is.

  2. Install:

    pip install getaccord
    
  3. Buy something: hold money with each seller, then commit.

    from getaccord import Accord
    
    accord = Accord()                        # reads ACCORD_AGENT_KEY and ACCORD_URL from the env or ./.env
    intent = accord.intent(budget=4500)      # whole cents; budget_micros= for exact sub-cent amounts
    intent.hold("skyfare", 3000, ref="SFO to JFK")
    intent.hold("stayco", 1500, ref="2 nights")
    result = intent.commit()                 # everyone is paid, or no one is
    print(result.status, result.intent["proofUrl"])
    

Amounts are whole cents (int) or exact micros (amount_micros=, millionths of a dollar). Floats are refused, so no amount is ever rounded.

Buying

accord.intent(budget, *, budget_micros, coin, mode, expires_in, key) Opens a purchase. coin: the usual dollar coin or "USDC". mode: "all" (everyone or no one) or "each".
intent.hold(seller, amount, *, amount_micros, ref, type) Locks money with one seller. type: "reserve" or "deliver".
intent.holds([...]) Several holds in one step (one transaction).
intent.commit(wait="60s") Waits for every seller to confirm, then pays them all. In "all" mode a decline or timeout releases everything.
intent.abort() Calls it off; every held dollar comes back.
intent.results(), intent.accept(i), intent.reject(i) Deliver holds: check the work before anyone is paid.
accord.resume(intent_id) A purchase made earlier, by its ID: commit, abort or add holds after a restart.
accord.balance() What's available, and what's left of the key's weekly budget.

Errors are AccordError with a stable .code (limit_exceeded, seller_not_allowed, insufficient_balance, awaiting_approval, too_many_holds, ...) and a message that says what to do.

A purchase over the key's sign-off limit waits for a person: hold() raises awaiting_approval and no money is locked. For a test key, the owner approves it with accord.test.approve(intent.id, owner_token), passing the owner token init saved to ~/.accord/owner-<key id>. The file holds comment lines and one line ACCORD_OWNER_TOKEN=own_…: pass only the own_… value. The SDK never reads that file itself, so an agent with only its key can't approve its own purchases. Dashboard keys are approved at app.useaccord.ai.

After a restart, accord.resume(intent_id) picks a purchase up again to commit or abort it.

Async: AsyncAccord has the same methods, awaitable.

import asyncio
from getaccord import AsyncAccord

async def main():
    accord = AsyncAccord()
    intent = await accord.intent(budget=4500)
    await intent.hold("skyfare", 3000)
    result = await intent.commit()
    print(result.status)

asyncio.run(main())

Paying x402 sellers

Sellers that charge per request with x402 can add an Accord option to their 402.

from getaccord.x402 import pay

response = pay("https://seller.example/report")   # quote, hold, commit, fetch with the proof
print(response.status, response.json())

Several sellers in one purchase: quote(url), hold(intent, offer) for each, intent.commit(), then fetch_paid(offer, intent.id, result.digest, indexes).

Selling with x402: add accord_requirement(pay_to=..., usd_cents=25, public_url='https://api.example.com') (the URL buyers reach you at; required) to your 402's accepts, then check each paid request with verify_accord_payment(header, requirement, resource=url). See examples/x402_gateway.py.

Selling (webhooks)

Accord tells your server about each hold with a signed webhook. Answer whether you can deliver:

from getaccord import Handler

handler = Handler(
    on_hold=lambda event: True,                 # ready (or False, or {"declined": "why"})
    on_commit=lambda event: print("paid", event["intentId"]),
)                                               # reads ACCORD_WEBHOOK_SECRET

# Flask
@app.post("/accord")
def accord_webhook():
    status, body = handler.handle(request.get_data(), request.headers)
    return body, status

With async def callbacks (FastAPI, aiohttp), use status, body = await handler.handle_async(raw, headers).

handle() checks the Accord-Signature header (HMAC-SHA256, a 5-minute window against replays, old and new secrets during a rotation) and answers each event once. Give it the raw request body. verify_signature(raw, header, secret) is there on its own too.

Examples

  • examples/trip_booker.py: a flight, a hotel and a car, all paid or none (--fail ridenow to see a decline release everything).
  • examples/seller_webhook.py: a seller answering webhooks with no framework.
  • examples/x402_gateway.py: an x402 gateway paid through Accord.

Tests

pip install -e '.[dev]'
pytest                                                    # unit tests
ACCORD_LIVE=1 ACCORD_URL=https://api.useaccord.ai pytest  # plus a live test-mode purchase

Signatures are checked byte-for-byte against the TypeScript SDK's.

License

Apache-2.0

Metadata

Release files for getaccord 0.6.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for getaccord 0.6.6
File Size Uploaded Provenance Actions
getaccord-0.6.6.tar.gz 37.8 kB With provenance Details for getaccord-0.6.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for getaccord 0.6.6
File Interpreter ABI Platform Actions
getaccord-0.6.6-py3-none-any.whl Python 3 none any Details for getaccord-0.6.6-py3-none-any.whl

Total release size: 66.3 kB

Release files / getaccord-0.6.6.tar.gz

Download URL getaccord-0.6.6.tar.gz
Size 37.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d39d1a57a9f3c327f350fffe39aabc25c47a831ba4f4997eddc05b874000589b
BLAKE2b-256 checksum
How to use checksums
504b14f6ccde7ed6f392b50eed450c2357ecc2e349a9f922f5439c5d123979ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / getaccord-0.6.6-py3-none-any.whl

Download URL getaccord-0.6.6-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
575208c7cbd26544c5cb6f397a5d8d991357076b7ed5177f63e5c7681376ec33
BLAKE2b-256 checksum
How to use checksums
4df2ff0a255af2ae95267083b0a847a40e99f6e8569f390f191d827bc98d2c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for getaccord 0.6.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for getaccord-0.6.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page