libraries/hyprpay/skills/hyprpay/SKILL.md
Use when integrating @montte/hyprpay SDK to sync customer lifecycle with Montte. Covers createHyprPayClient setup, customers.create/get/update/list, subscriptions, usage ingestion, benefits, coupons, customer portal, HyprPayError handling, and the better-auth plugin for automatic customer creation on signup.
npx skillsauth add Montte-erp/montte-nx @montte/hyprpay/overviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
import { createHyprPayClient } from "@montte/hyprpay";
const hyprpay = createHyprPayClient({
apiKey: process.env.MONTTE_API_KEY, // generate at Montte → Settings → API Keys
// baseUrl: "https://api.montte.com.br" (default)
});
// Create — always pass externalId (your app's user ID) for idempotent lookups
await hyprpay.customers.create({
name: "Maria Silva",
email: "[email protected]",
externalId: user.id,
});
// Get by externalId
const customer = await hyprpay.customers.get(user.id);
// Update
await hyprpay.customers.update(user.id, { email: "[email protected]" });
// List (paginated)
const { items, total } = await hyprpay.customers.list({ page: 1, limit: 20 });
// Create subscription with items
const { subscription, checkoutUrl } = await hyprpay.subscriptions.create({
customerId: user.id,
items: [{ priceId: "price-123", quantity: 1 }],
couponCode: "PROMO10", // optional
}).match((v) => v, (e) => { throw e });
// Cancel
await hyprpay.subscriptions.cancel({ subscriptionId: sub.id });
await hyprpay.subscriptions.cancel({ subscriptionId: sub.id, cancelAtPeriodEnd: true });
// List
const subs = await hyprpay.subscriptions.list(user.id).match(
(v) => v,
(e) => { throw e },
);
// Manage items
await hyprpay.subscriptions.addItem({ subscriptionId: sub.id, priceId: "price-456" });
await hyprpay.subscriptions.updateItem({ itemId: item.id, quantity: 3 });
await hyprpay.subscriptions.removeItem(item.id);
// Ingest usage event (queued via DBOS — durable)
await hyprpay.usage.ingest({
customerId: user.id,
meterId: "meter-abc",
quantity: 5,
properties: { source: "api" },
idempotencyKey: requestId, // optional but recommended
});
// List usage events
const events = await hyprpay.usage.list({ customerId: user.id, meterId: "meter-abc" });
// Check a specific benefit
const result = await hyprpay.benefits.check({ customerId: user.id, benefitId: "benefit-xyz" });
// result.status: "granted" | "revoked" | "not_found"
// List all benefit grants
const grants = await hyprpay.benefits.list(user.id);
// Validate a coupon before subscription creation
const validation = await hyprpay.coupons.validate({ code: "PROMO10" });
if (validation.valid) {
// validation.coupon has type, amount, duration, scope
} else {
// validation.reason: "not_found" | "inactive" | "expired" | "max_uses_reached" | "price_scope_mismatch"
}
// Generate a short-lived signed portal URL (15 minutes)
const { url, expiresAt } = await hyprpay.customerPortal.createSession(user.id);
// Embed in email or show as "Gerenciar assinatura" link
All errors are HyprPayError with typed code and statusCode:
import { HyprPayError } from "@montte/hyprpay";
try {
await hyprpay.customers.get("unknown");
} catch (err) {
if (err instanceof HyprPayError) {
err.code; // "NOT_FOUND" | "UNAUTHORIZED" | ...
err.statusCode; // 404
}
}
import { hyprpay } from "@montte/hyprpay/better-auth";
betterAuth({
plugins: [
hyprpay({
apiKey: process.env.MONTTE_API_KEY,
createCustomerOnSignUp: true, // zero-config hook on afterSignUp
customerData: (user) => ({
name: user.name,
email: user.email,
externalId: user.id,
}),
}),
],
});
externalId, you cannot do customers.get() laterteamId in metadataexternalId to identify, not just namestools
Use when listing, filtering, creating, summarizing, or deleting financial transactions via the montte CLI. Covers all options for date ranges, types, account/category filters, and pagination.
tools
Use when managing transaction categories via the montte CLI: listing by type, creating parent or subcategories, archiving (soft delete), or permanently removing.
tools
Use when creating or checking monthly budget goals per category via the montte CLI. Covers listing progress (percent used), alert thresholds, and removing goals.
tools
Use when authenticating the CLI, managing API keys, or handling "Not logged in" errors. Covers login, logout, whoami, and env var auth.