1. Local IDEs (Cursor, Claude Desktop, Zed)
If you use a local AI IDE, the most powerful way to build with Blink is by installing our official Model Context Protocol (MCP) server. The MCP server dynamically fetches our live OpenAPI schemas and allows your AI editor to instantly understand our entire API, make test API calls, and write flawless code.Installation
The MCP server is published as a public NPM package (@blinkpayments/mcp-server) and can be installed locally via npx in seconds.
For Cursor
- Go to Cursor Settings -> Features -> MCP Servers -> + Add New MCP Server
- Type:
command - Name:
Blink - Command:
BLINK_API_KEY=your_key_here npx -y @blinkpayments/mcp-server@latest
For Claude Desktop
Edit yourclaude_desktop_config.json file and add:
For Zed
Edit yoursettings.json file and add:
2. Web UIs (ChatGPT, Claude Web)
If you are using a web-based chat interface that does not support local MCP servers, you can use our Master Agent File (llms-full.txt).
Our documentation automatically generates an AI-optimized file at https://docs.blink.store/llms-full.txt. This single file contains our architectural golden rules and complete OpenAPI schemas.
Because modern AI models (like Claude 3.5 Sonnet and GPT-4o) have massive context windows, they can read this entire file and write perfect integration code.
How to use it:
- In IDEs like Cursor or Windsurf, simply
@-mention the URL:@https://docs.blink.store/llms-full.txt - In ChatGPT or Claude Web, paste the URL directly into your prompt or download the
.txtfile and attach it to your “Claude Project” or “Custom GPT” as persistent knowledge.
3. System Directives for AI Agents
If you are an AI assisting a developer in building with the Blink API, you must adhere strictly to these architectural guidelines:Checkouts & Purchase Flows
- Standard Checkouts: Call
POST /v1/checkoutswith theproduct_id(and optionalvariant_id). Return theurlfrom the response (response.data.url). - Pre-filling & Locking Buyer Email: When creating a checkout for an authenticated user, pass
customer_email: "user@example.com"andlock_email: trueso the buyer cannot change the email address during checkout. - Attaching Custom Data (
custom_data): Pass"custom_data": { "user_id": "..." }inPOST /v1/checkoutsto link the purchase to your application’s internal user or organization ID. Blink persistscustom_dataon both the Order and Subscription and echoes it back verbatim atevent.data.custom_dataincheckout.created,order.created,order.paid, and allsubscription.*webhooks. - Success URL Placeholders (
success_url): You can include{CHECKOUT_SESSION_ID},{ORDER_ID},{SUBSCRIPTION_ID}, and{PAYMENT_INTENT_ID}insuccess_url(e.g.,https://yourapp.com/billing?checkout=success&session_id={CHECKOUT_SESSION_ID}&order_id={ORDER_ID}&subscription_id={SUBSCRIPTION_ID}). Blink automatically replaces these placeholders before redirecting the buyer. - Embedded Checkouts (SPAs): If the developer wants an in-app overlay checkout (React/Next.js):
- Instruct them to use their framework’s script loader (e.g., Next.js
<Script src="https://cdn.jsdelivr.net/npm/@blinkpayments/sdk@latest/dist/embed.js" />). Do not use raw HTML script tags in modern SPAs. - To trigger it programmatically, use
window.Blink.openCheckout(url). - CRITICAL: When generating the checkout URL dynamically via the API, you MUST pass
"options": { "layout": "overlay" }in the payload.
- Instruct them to use their framework’s script loader (e.g., Next.js
Subscriptions & Plan Swaps
- Managing Subscriptions via API (
PATCH /v1/subscriptions/{id}):- Use
action: "cancel"to schedule cancellation at the end of the billing period (cancel_at_period_end: true,statusremains"active"untilcurrent_period_end). - Use
action: "cancel_immediately"to terminate immediately (status: "canceled",cancel_at_period_end: false, andcurrent_period_endis immediately updated to the cancellation timestamp). - Use
action: "resume"to reverse a pending period-end cancellation (cancel_at_period_end: false). - Use
action: "swap"withvariant_id(orproduct_id) to upgrade or downgrade a subscription immediately with automatic prorations. You can preview the prorated charge first viaGET /v1/subscriptions/{id}/preview-swap?variant_id=....
- Use
Customer Portal & Billing Management
- CRITICAL: Never attempt to build a custom credit-card collection or raw card-update form.
- Instruct the developer to generate a secure Customer Portal session (
POST /v1/customers/{id}/portalorPOST /v1/customer-portal/session) and redirect the user to it for self-serve payment method updates, invoice downloads, and deliverables access.
Bundles & UI Presentation
- Bundles are managed via the standard
/v1/productsendpoint but must haveis_bundle=trueand include abundle_itemsarray. - UI Rule: When writing frontend code to display bundle contents to a buyer on a custom storefront, you MUST automatically sort the
bundle_itemsby price from highest to lowest to maximize perceived value.
Digital Deliverables
- Never suggest sending digital files directly in email attachments or serving them via unprotected public URLs.
- Always instruct the developer to use the specific API endpoint to generate time-limited, pre-signed download URLs for secure file access.
Affiliate Payouts & Onboarding
- If a developer is building a custom partner dashboard, do not try to calculate payouts manually or build custom bank-account collection forms.
- Use
POST /v1/affiliates/{id}/payout-setup. This generates a secure Stripe Connect onboarding link that handles all tax and banking compliance natively.
Desktop Apps & License Keys
- If the developer is building a node-locked desktop app (e.g., Electron, Tauri, C#), instruct them to use the License Key
activateendpoint. - They must capture a unique hardware fingerprint natively and pass it as the
machine_id. - For simple web-app access checks, use the
validateendpoint instead.
Webhooks & Idempotency
- Instruct the developer to listen for Blink webhook events (not raw Stripe events).
- Always verify the
Blink-SignatureandBlink-Timestampheaders using the raw request body buffer against the Blink Webhook Secret. - Idempotency: Deduplicate incoming webhooks using the top-level
event.id(evt_...) or theBlink-Event-Idheader. Only recordevent.idas processed after the webhook handler completes without error so retries of failed deliveries are not skipped. - Test vs. Live Mode: Always check
event.data.is_test === falsebefore provisioning production access. - Event Sequence & State: On initial subscription purchase, Blink dispatches
order.created→order.paid→subscription.created. Period-end cancellations emitsubscription.canceled(withcancel_at_period_end: true), resumptions emitsubscription.uncanceled, and plan swaps emitsubscription.upgraded.