Loading…
Flat-fee payments need no tracking integration. For revenue-share briefs and posts with milestone bonuses, track the creator’s customers and report collected revenue from your server. Testing opportunities can also use the tester access API.
You can post a revenue-share brief and receive applications before you integrate, but you can only hire once tracking is connected: an active server key that your server has used for at least one successful call, such as reading a month's revenue in step 5. That way every hired creator's referrals can be credited from day one.
Open your app, then choose SDK & API: server keys and tracked revenue. Create a dedicated sl_amb_… server key. Keep it secret; old perk and Wandamark keys do not work here.
npm install https://shoploop.dev/sdk/shoploop-sdk-0.4.0.tgzThe package is distributed from this site, not yet from the npm registry. Download the package · Full SDK reference and migration notes
import { captureReferral, clearReferral } from '@shoploop/sdk/browser';
const referralCode = captureReferral();
// Send it to your own signup handler.
// Clear only after your server confirms the binding:
clearReferral();Each hired creator links to your brief's landing URL with their own shoploop_ref=<code> parameter; the code is shown next to the creator on the brief's management page. Call captureReferral() on the landing page after any required storage consent. The first valid shoploop_ref is retained for 30 days. No page activity or payment data is collected in the browser. If storage is blocked, attribution is available only from the current link.
import { Shoploop } from '@shoploop/sdk';
const shoploop = new Shoploop({ key: process.env.SHOPLOOP_SERVER_KEY });
await shoploop.attribute({ customerId: user.id, referralCode, email: user.email }); // email is optionalUse the authenticated new customer’s ID from your own database. Each customer can be bound to only one creator per app. Repeat the same binding safely; do not overwrite it on later visits. Use opaque IDs, never names or email addresses. The optional email is hashed and used only to stop creators signing themselves up for milestone bonuses.
On a post with milestone bonuses, each attribute() call is one sign-up. It counts once it has passed the post's hold without being revoked, and only within the post's bonus window. Posts that count paying customers also need a settled sale() for that customer. During the hold, remove fraudulent, duplicate or test sign-ups from your server, or from the post's page:
await shoploop.revokeSignup({ customerId: user.id, reason: 'Duplicate account' });After the hold, revokeSignup returns revoke_window_closed (409). When a creator's counted sign-ups reach a milestone, Shoploop invoices you for that bonus on the post's bonus terms.
// Only after verifying your payment provider's webhook and payment:
await shoploop.sale({
eventId: 'sale:order_42', orderId: 'order_42', customerId: user.id,
amountCents: 10000, currency: 'USD', occurredAt: '2026-11-10T14:00:00Z'
});
await shoploop.refund({
eventId: 'refund:re_42', orderId: 'order_42', amountCents: 2500,
currency: 'USD', occurredAt: '2026-11-12T14:00:00Z'
});Amounts are integer USD cents. Keep a durable outbox and reuse identical event IDs and payloads on retries. Deliver attribution before sales. Partial refunds are supported; refunds arriving first wait for their sale. Never trust browser-supplied paid status, amounts or customer IDs. Shoploop records your server’s assertions; it does not independently verify the payment processor.
const totals = await shoploop.revenue('2026-11');Your app’s integration page shows gross sales, refunds, net revenue and differences from amounts already reported. Compare them with your complete payment records, then report each closed month from the brief management page. Manual reporting remains available.
Refunds adjust the original sale month. Tracking never automatically bills an app or changes an existing invoice. Late receipts or refunds that change a reported month require reconciliation with Shoploop support.
Send JSON with Authorization: Bearer sl_amb_… to POST /api/v1/ambassadors/attributions, /attributions/revoke, /sales and /refunds. Read totals at GET /api/v1/ambassadors/revenue?month=YYYY-MM. Fields match the SDK calls above.
401 means a missing or revoked key; 404 means missing attribution or referral; 409 means conflicting replay or a revoke after the hold; 422 means invalid data. Retry network errors, 429 and 5xx through your outbox. Respect Retry-After. Server keys must never be placed in browser code.
Ripple links send people to your website with shoploop_ref=srp_…. The same captureReferral() and attribute() calls handle them, so the steps above already cover signups. Two more calls make the Ripple dashboard show real use, not just signups:
// When the customer actually uses your app (finished onboarding, first session). Safe to repeat.
await shoploop.activate({ customerId: user.id });
// A settled sale. Add offerCode when they used your Ripple offer, so it counts as redeemed.
await shoploop.sale({ eventId: 'sale:order_42', orderId: 'order_42', customerId: user.id,
amountCents: 4900, currency: 'USD', occurredAt: '2026-11-10T14:00:00Z', offerCode: 'FRIENDS50' });Ripple attribution is separate from creator attribution: a customer can have both. activate() returns unknown_customer (404) for customers who didn't arrive through Ripple. Your app checks offer codes and expiry; Shoploop only counts a sale as redeemed when it happened before the offer expired. Over HTTP: POST /api/v1/ripple/attributions and POST /api/v1/ripple/activations (SDK 0.4.0 or later). Ripple is included with the Growth and Unlimited plans.
Creators promote an app better when they use it. On the Growth and Unlimited plans you can give the creators you hire free access: save an invite link, a promo code or written steps on your app's page, switch gifting on for a brief, and each creator you hire sees those details. That set-up needs no code. The steps below are optional, for apps that want to grant the access themselves and notice when it is withdrawn. Apps Shoploop operates use the same flow for approved testers.
Hiring on a brief with gifting on, or approval on a testing opportunity, creates a grant. The creator can create a one-time token on their creator page. Your server redeems it using this app's server key; keep the key and token out of logs and browser URLs.
POST /api/v1/access/verify
Authorization: Bearer <app server key>
Content-Type: application/json
{"token":"<creator one-time token>"}
// Successful response (referralCode and applicationId are null for a gift made by Shoploop):
{"valid":true,"grantId":"<id>","referralCode":"<code>","applicationId":"<id>"}Bind the successful result to the creator's authenticated account on your server. A token expires after 7 days, works once, and is replaced only when the creator requests a new one. Invalid, expired, used or revoked tokens return valid: false; do not grant access from an HTTP 200 alone.
// Check continued access with the same endpoint and server key:
{"grantId":"<grantId stored when the token was redeemed>"} // or {"referralCode":"<code>"}
// Response:
{"active":true}Check continued access before protected operations and refuse access when active is false or the check fails. A public referral code is not a login credential. Restoring a revoked grant requires a new token redemption. Revocation cannot undo a copied shared invite or a session your app fails to check. A successful redemption shows integration activity; it does not prove every access path is protected.
// With the SDK (0.2.0 or later):
const result = await shoploop.redeemAccess(token); // { valid, grantId, ... }
const { active } = await shoploop.accessStatus({ grantId }); // false once suspended or the hire endsThe endpoint returns 401 for an invalid server key, 422 for malformed input and 429 for rate limits. Shoploop does not call your server when access changes, so check active yourself. The app must enforce access itself. Testing opportunities are for apps Shoploop operates.
The legacy perks, study-testing and invitation-bonus APIs are retired. Stop creating new claims or starting those flows. Existing claim lookup, redemption, rejection and milestones remain available to honor old claims, as do historical refund reconciliation and payment webhooks. New testing opportunities use the brief and tester-access flows described above.
Keep @wandamark/sdk if you use Wandamark analytics. Its wm_ref and testing helpers do not handle Shoploop ambassador links. Use this separate SDK for shoploop_ref.