# Verify app signups and trials with Trim ## Set up the offer 1. Open **App verification** as an app-business vendor. Create an offer with the app’s destination URL, the qualifying action and the affiliate reward per confirmed action. 2. Generate the signing key and copy it into your app’s server-side secret storage. Save the webhook URL from Trim. Generating a replacement key revokes the previous one. 3. Connect with an affiliate and accept the same Trim collaboration terms. The affiliate can then open **App verification**, select the offer, and create a referral link and downloadable QR code. The link and QR open the same customer-facing offer page. When the customer continues, Trim adds an opaque `trim_referral` parameter to the app URL. Save the parameter on your server and carry it through signup until the account completes the action in the offer. Each referral is valid for seven days. The app vendor can close the offer in **App verification**. Shared links and QRs then display the closed offer page. Keep sending callbacks for qualifying actions from customers who continued before closure and are still within the original seven-day referral window. ## Send the confirmation Send one signed `POST` to the webhook URL after the agreed action occurs. Use `signup_verified` after confirming a new account according to the offer, or `trial_started` after an eligible account starts its trial. Reuse the same fields and event ID if you retry a confirmation. | Field | Value | | --- | --- | | `eventId` | A stable, opaque ID for this confirmation. | | `referralId` | The `trim_referral` value captured at handoff. | | `eventType` | `signup_verified` or `trial_started`, matching the offer. | | `appAccountId` | An opaque ID for the app account. Keep names, phone numbers and emails in your app. | | `occurredAt` | The time of the qualifying action as an ISO date and time, preferably UTC. | The `X-Trim-Timestamp` header holds the current Unix timestamp in seconds. The `X-Trim-Signature` header holds `sha256=` followed by the hex HMAC-SHA-256 of the timestamp, a period and the exact JSON bytes being sent. Use the full signing key as text. Create a fresh timestamp and signature on each delivery attempt. ```js import { createHmac } from 'node:crypto'; export async function sendTrimConfirmation(webhookUrl, signingKey, event) { const body = JSON.stringify(event); const timestamp = String(Math.floor(Date.now() / 1000)); const signature = createHmac('sha256', signingKey) .update(`${timestamp}.${body}`) .digest('hex'); const response = await fetch(webhookUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Trim-Timestamp': timestamp, 'X-Trim-Signature': `sha256=${signature}`, }, body, }); const result = await response.json(); if (!response.ok) throw new Error(result.error); return result.status; } ``` `verified` means Trim credited the action to the affiliate. `duplicate` means it already counted the confirmation or equivalent action. Both can be treated as successful delivery. Vendors and affiliates can review credited actions and the agreed reward in **App verification**. ## Pay a credited reward Affiliates can save a Philippine mobile wallet from **My workspace**. A vendor can view the shared wallet provider, recipient name and mobile number after an app action was credited. Send the displayed amount from your wallet app, then record the transfer reference from **View payout details**. The affiliate can see that reference in **Payout history**. The development server at `http://127.0.0.1:8765` accepts local integration tests from the same computer. Use sample accounts and wallet details in the preview. A live app backend needs the public HTTPS Trim webhook URL when Trim is deployed.