jassi-platform-sdk
v0.1.0
Published
Official JS/Node SDK for the JASSI Platform API — reward users with JASSI tokens from your own app or website.
Downloads
142
Maintainers
Readme
jassi-platform-sdk
Official JS/Node SDK for the JASSI Platform API. Reward your users with JASSI tokens from your own website, app, or backend — without hand-rolling HTTP calls.
Install
npm install jassi-platform-sdkRequires Node 18 or later. Ships as pure ESM with a bundled TypeScript declaration file — no build step required.
Quick start
import { createClient } from "jassi-platform-sdk";
const jassi = createClient({
apiKey: process.env.JASSI_API_KEY, // sk_test_... or sk_live_...
baseUrl: "https://yourapp.example.com/api",
});
// Define a rewardable action once (idempotent to re-run; skip if it already exists)
await jassi.createAction({ name: "newsletter_signup", rewardAmount: 50 });
// Reward a user when they complete that action
const event = await jassi.submitEvent({
action: "newsletter_signup",
identifier: "[email protected]",
idempotencyKey: "[email protected]", // use your own unique id
});
console.log(event.status); // "approved" | "pending" | "unclaimed" | "rejected"Auth
Use either a static secret API key (simplest):
createClient({ apiKey: "sk_live_...", baseUrl: "..." });...or OAuth2 client-credentials (the SDK fetches and auto-refreshes the access token):
createClient({ clientId: "coid_live_...", clientSecret: "cs_live_...", baseUrl: "..." });Both are created from the Business Dashboard → Developer tab.
API
getBalance()— current JASSI balance available to spend on rewards.listActions()/createAction(input)— manage rewardable actions.lookupUser(identifier)— check whether an identifier (email) has a JASSI account.submitEvent(input)— reward a user for completing an action. Always pass your ownidempotencyKeyderived from something unique on your side (order id, form submission id, etc.) so retries never double-reward.getEvent(id)— check the status of a previously submitted event.
Webhooks
Register a webhook endpoint from the Business Dashboard → Developer tab and choose
which event types it receives (subscribedEvents). Each delivery is a signed POST
with body { type, data, createdAt } where type is one of:
event.approved— a submitted event was approved (auto or manual review) and JASSI was credited.event.rejected— a submitted event failed verification and was rejected outright.event.pending— a submitted event landed in the review queue, for any reason (above the action's auto-approve threshold, or a fraud-check flag). Fires for every pending event, regardless of cause.event.flagged— fires in addition toevent.pending(never instead of it) only when the pending event was caused by a fraud check (duplicate submission, rate limit, daily cap, or GPS mismatch/missing) rather than a plain above-threshold amount. Use this if you want to alert on suspected fraud specifically, without reacting to every ordinary pending review.
Idempotency
Every submitEvent() call requires an idempotency key (the SDK generates a random
one if you don't supply one, but you should always supply your own so that retries
from your system are also safe). Resubmitting the same key returns the original
event instead of creating a duplicate reward.
