Embed a Claim Button
How-To Guide: Add a credential claim button to any website using the LearnCard Embed SDK
Add a "Claim Credential" button to any webpage. When a user clicks it, a modal walks them through email verification and deposits the credential into their LearnCard wallet.
The one-line version
npx @learncard/cli embed --domains https://yoursite.comSets up LearnCard to sign for you, registers an integration whitelisted to your origins, saves the publishable key to .env, and writes claim-button.html โ a working page with the key filled in. Serve it from a whitelisted origin (not file://) and click the button.
The rest of this page is the same setup by hand.
Step 1: Get a publishable key
The button is keyed to an integration โ a record that holds your allowed origins and a publishable key (pk_โฆ). Either:
run
npx @learncard/cli embed --domains https://yoursite.com(creates it and savesPUBLISHABLE_KEYto.env), orin the Developer Portal open Guides โ Embed Claim Button, follow the setup, and copy the key from the Embed Code tab.
Credentials claimed through the button are signed by your primary signing authority; the CLI sets one up if you don't have one.
Step 2: Add the SDK
<script src="https://cdn.jsdelivr.net/npm/@learncard/embed-sdk@latest/dist/learncard.js"></script>npm install @learncard/embed-sdkimport { init } from '@learncard/embed-sdk';Step 3: Initialize the SDK
Add a target element and call init():
The credential name must match a template you created in the Developer Portal. The SDK resolves it server-side.
Step 4: Customize Branding (Optional)
Step 5: Handle Success (Optional)
After claiming, the SDK opens the wallet in a new tab (deep-linked to the credential via handoffUrl) and shows a success screen. Hook into this with onSuccess:
To suppress the automatic wallet redirect entirely, set branding.walletUrl: '':
Complete Example
This is the file npx @learncard/cli embed writes, with PUBLISHABLE_KEY_PLACEHOLDER replaced by your key:
Whitelisted Domains
The API only accepts claims from domains whitelisted in the Embed Code tab of your Developer Portal. Add your production domain before going live.
During local development, localhost is allowed automatically.
Troubleshooting
"This integration could not be found" Your publishableKey doesn't match an active integration. Check the key from your Developer Portal Embed Code tab and ensure your domain is whitelisted.
Credential not appearing after claim The credential lands in the user's inbox and is finalized when they open their wallet. To verify immediately, check the Developer Portal's activity tab.
Embedded claims stay claimable for 720 days by default. For transcripts, CLRs, or other sensitive learner records, pass a shorter expiresInDays (1โ720) in the /inbox/claim configuration, e.g. configuration: { publishableKey, expiresInDays: 7 }. This controls how long the encrypted payload can be claimed, not the credential's own validity dates.
OTP not arriving In local dev, check your brain-service logs โ OTP codes are printed there when no email provider is configured.
See Also
Connect a User's LearnCard to Your Platform โ for an ongoing link instead of one-off claims
Build an App Inside LearnCard โ for apps inside LearnCard
Last updated
Was this helpful?