How to Integrate the Privacy API Into Your Agentic Workflow
This guide covers how to use the Privacy API to create virtual cards, set spending limits, monitor transactions, and manage card state programmatically within an agentic workflow.
What You Need Before You Start
A Privacy account. API access is available to anyone on Privacy Plus ($5/month), Privacy Pro ($10/month), or Privacy Premium ($20/month). Sign up or upgrade at privacy.com/pricing.
Your API key. Once you're on a paid plan, generate your API key from your account page. This key authenticates all API requests.
The sandbox (recommended). Privacy provides a sandbox environment at sandbox.privacy.com with test card numbers. The sandbox requires a separate API key, also available on your account page.
A note on this guide: The Privacy API docs mark some features as "Issuing" or "Enterprise." Some of these labels may be outdated. If you encounter a permissions error on any endpoint described below, contact support@privacy.com to confirm access for your plan tier.
API Basics
All requests go to https://api.privacy.com/v1/ (or https://sandbox.privacy.com/v1/ for testing).
Authentication: Include your API key in the request header:
Authorization: api-key YOUR_API_KEY
Amounts are integers in the smallest currency unit (e.g., 1000 = $10.00 USD).
Dates are ISO 8601 format.
Responses are paginated:
Step 1: Create a Virtual Card for Your Agent
Send a POST request to /v1/cards with the card type, spending limit, and limit duration.
Example: Create a Single-Use Card with a $5 limit
The response includes the card details needed to make a purchase:
The agent reads pan, cvv, exp_month, and exp_year from the response to use at checkout.
Choosing a Card Type
Setting Spend Limits
The spend_limit (in cents) and spend_limit_duration fields determine how much the card can authorize.
Example: a Merchant-Locked Card for LLM API billing, capped at $100/month:
Step 2: Monitor Agent Spending
The Transactions endpoint returns transaction history, filterable by card, date range, and result.
List transactions for a specific card
Each transaction includes:
- amount: The transaction amount in cents
- merchant.descriptor: The merchant name (e.g., "OPENAI" or "PERPLEXITY AI")
- merchant.mcc: Merchant category code
- result: APPROVED or a decline reason (e.g., USER_TRANSACTION_LIMIT if the spend limit was hit)
- status: PENDING, SETTLED, DECLINED, VOIDED, etc.
- created: Timestamp of the transaction
Example response
Useful query parameters
Step 3: Control Cards Programmatically
Cards can be paused, resumed, updated, or permanently closed via PATCH requests.
Pause a card
Pausing a card declines all future transactions until the card is set back to OPEN.
Resume a card
Close a card permanently
Closing a card is irreversible. The card will not accept further transactions.
Update a spend limit
Spend limits and durations can be updated on active cards.
Step 4: Set Up Webhooks for Real-Time Monitoring
Instead of polling the Transactions endpoint, you can configure webhooks to receive real-time transaction data.
Set your webhook URL in your Privacy account settings. Once configured, Privacy will send an HTTP POST request to your endpoint with a Transaction object every time a transaction event occurs on any of your cards.
Webhooks are HMAC-verified, so you can confirm each notification actually came from Privacy. If your server is unavailable, Privacy retries with exponential backoff (doubling the wait time between attempts) for up to 24 hours.
Use cases for webhooks
- Spend alerts: Trigger notifications when charges occur
- Automated card controls: Pause a card programmatically if a transaction exceeds an expected threshold
- Audit logging: Record every agent transaction with merchant details and timestamps
- Agent feedback loops: Confirm a purchase succeeded before the agent proceeds to its next task
Putting It All Together: A Sample Agentic Workflow
Here's a typical integration flow. In this example, an agent needs to purchase a Perplexity AI subscription to gain search capabilities.
- Create card. Orchestration layer calls POST /v1/cards to create a single-use card with a $20 limit.
- Read card details. The API response includes pan, cvv, exp_month, and exp_year. The agent stores these temporarily.
- Complete purchase. The agent navigates to Perplexity AI's checkout and enters the card details.
- Webhook fires. Your server receives a webhook: $5.00 charged by PERPLEXITY AI, result APPROVED.
- Card auto-closes. Single-Use Card closes after the first transaction. No further charges are possible.
- Agent continues. With the subscription active, the agent proceeds to its next task.
If the charge at step 3 exceeds the $20 limit, the transaction is declined. If the agent attempts to reuse the card, it's already closed.
Python Quick Reference
Most agent frameworks are Python-based. Here's a minimal wrapper around the Privacy API:
Best Practices
- Single-Use Cards for one-off purchases. They close automatically after the first transaction, preventing repeat or unauthorized charges.
- Merchant-Locked Cards for recurring billing. Only the original merchant can charge the card.
- Tight spend limits. If you expect a $5 charge, set a limit close to that. Smaller limits reduce exposure.
- Label cards with memo. Clear labels like "Agent - Anthropic API" or "Agent - domain purchase" make auditing straightforward.
- Develop against the sandbox. sandbox.privacy.com provides the same functionality with test card numbers.
- Use webhooks over polling. Webhooks provide real-time transaction data without additional API calls.
API Reference Summary
Full API documentation: privacy-com.readme.io/docs
Get Started
- Sign up or upgrade to a Privacy plan (Plus or higher) at privacy.com/pricing
- Generate your API key from your account page
- Build against the sandbox at sandbox.privacy.com
- Go live when ready
Questions? Reach out to support@privacy.com.