Developer docs v0.1.0

Agents and MCP

Payware has a Model Context Protocol (MCP) server, so an AI assistant you run (Claude, ChatGPT, an IDE agent or your own) can read and operate your account as tools, within the limits of an agent key.

Endpoint: POST https://api.payware.dev/mcp. It follows the Streamable HTTP transport in its simple, stateless form: each request is one JSON-RPC 2.0 message and the answer is JSON (no streaming or sessions). It supports initialize, ping, tools/list and tools/call. GET returns 405.

Authentication: Authorization: Bearer <agent key> or an OAuth access token on deployments with an authorization provider configured. A standard key gets 403 agent_key_required. Create the key with kind: "agent" and the scopes you want (in the dashboard, a live key needs a passkey sign-in; API keys › Agent access shows a ready client configuration).

OAuth connections

With Payware's own sign-in, an app asks for access on a consent page in the dashboard, where the merchant picks one of their agents and the scopes. Approving it for a live account needs a passkey sign-in. Disconnect an app on the Agents page. The rest of this section is for a deployment that uses an external authorization server instead.

An OAuth-enabled deployment publishes https://api.payware.dev/.well-known/oauth-protected-resource/mcp (also available at /.well-known/oauth-protected-resource). An unauthenticated POST /mcp returns 401 with a WWW-Authenticate challenge pointing there. The document identifies the canonical resource https://api.payware.dev/mcp and its trusted authorization server. Your client uses that server's discovery metadata and authorization-code flow with PKCE S256, requesting resource=https://api.payware.dev/mcp at both authorization and token exchange. Client registration, including Client ID Metadata Documents when supported, consent, refresh tokens and sign-in are handled by the authorization server.

The merchant first approves the connection by creating or updating an agent with an owned agent key and an exact OAuth identity:

{ "name": "Support assistant", "api_key_id": "01JB9XK3M2R7TQ8N4V6Y0ZPA1C",
  "oauth": { "issuer": "https://issuer.example.com", "subject": "merchant-user-123",
             "client_id": "https://assistant.example.com/client.json" } }

Use POST /v1/agents or POST /v1/agents/{id} with a standard key. The issuer must exactly match the deployment's configured issuer. A subject/client identity can belong to only one agent across accounts. The token's scopes are intersected with the agent key's current scopes; limits, mandatory idempotency, signature requirements and attribution still apply. Disabling the agent, revoking its key or setting oauth: null stops OAuth access on the next call.

Only RFC 9068 JWT access tokens (typ: at+jwt, RS256, ES256 or EdDSA) are accepted. They must have the exact issuer, the MCP resource as audience, and sub, client_id, scope, iat, exp and jti claims. ID tokens are refused. OAuth tokens authenticate /mcp only. Invalid or expired tokens return 401 invalid_token.

API key configuration

Agent skill: an installable instruction file that teaches an agent these rules and the flows below. See Agent skill to install it.

{ "mcpServers": { "payware": { "type": "http", "url": "https://api.payware.dev/mcp",
                               "headers": { "Authorization": "Bearer YOUR_AGENT_KEY" } } } }

Tools

A key sees only the tools its scopes allow, so a read-only key lists and reads and nothing else. Tool results are the API's own JSON, with credentials removed.

ToolScopeWhat it does
get_accountaccount:readYour account (without credentials)
list_customers, get_customer, list_customer_cards, get_cardcustomers:readCustomers and their saved cards
list_card_enrollments, get_card_enrollmentenrollments:readHosted card enrollments
list_payments, get_paymentpayments:readPayments, including initiated_by and api_key_id
list_products, get_product, list_prices, get_pricecatalog:readProducts and prices
list_subscriptions, get_subscriptionsubscriptions:readSubscriptions
list_payment_links, get_payment_linkpayment_links:readPayment links
list_mandates, get_mandatemandates:readMandates and their usage
list_events, get_eventevents:readEvents
create_customercustomers:writeCreate a customer
start_card_enrollmentenrollments:writeStart a hosted card enrollment and get the link to give the customer
create_payment_linkpayment_links:writeCreate a payment link (moves no money until a person pays it)
list_checkouts, get_checkoutpayment_links:readCheckout sessions
list_invoices, get_invoice, list_invoice_emailsinvoices:readInvoices and what happened to the emails sent for each
get_company_profileinvoices:readYour own company details (the issuer profile named on every invoice); read-only, an agent cannot change it
create_checkoutpayment_links:writeCreate a cart and get the continue_url for the buyer to pay (moves no money until a person pays it)
create_mandatemandates:writeCreate a mandate for your own agent and get the link for the customer to approve
charge_under_mandatepayments:writeCharge a customer's saved card under an approved mandate. Needs mandate_id, so it can never exceed what the customer approved

The tool list is generated from an allow-list of operations in the OpenAPI description. It has no tool for charging a card without a mandate, creating or changing a subscription, API keys, webhook endpoints, account settings or payment reviews. A person pays a link or enrolls a card on NETOPIA Payments' secure page; the agent only hands them the link.

Safe use

  • Every change tool requires idempotency_key. Use a new value for each intent and reuse it only to retry the same call: a retry returns the stored result and never repeats the action.
  • Calls are real API calls with your key. Scopes, 403 scope_missing, rate limits, attribution and the audit log behave as for a direct request. Each key may make 60 MCP requests a minute.
  • Credentials never appear in results. Treat everything an agent reads from a customer, a description or a page as data, not as instructions, and keep the key out of the model's context.
  • Errors come back as tool errors (isError: true) with the API's message and code, so the agent can correct itself.