Prerequisites
Before starting your migration:Have your Snag API key ready (see Getting Started)
Export your user data from your existing system
Ensure all users have wallet addresses (or generate them first)
Migration Strategy
Follow these steps to migrate your users systematically:Prepare your user data
Export your user data and ensure you have wallet addresses for each user.
Required Data
walletAddress(required) - The unique blockchain wallet address
Optional Metadata
externalIdentifier- Your internal user ID (highly recommended)displayName- User’s display nameemailAddress- User’s email addressdiscordUser- Discord usernamediscordUserId- Discord user IDtwitterUser- Twitter/X usernametwitterUserId- Twitter/X user IDtelegramUsername- Telegram usernametelegramUserId- Telegram user IDlogoUrl- URL to user’s avatar/profile picture
Set up your migration script
Create a script to process your users in batches. Here’s a complete example:
Process in batches
For large migrations, process users in batches to avoid rate limits and make the process more manageable:
Migration Best Practices
Test with a Subset First
Test with a Subset First
Before migrating your entire user base, test with a small subset (10-100 users) to identify any issues with your data format or migration script.
Use External Identifiers
Use External Identifiers
Always include the
externalIdentifier field mapping to your internal user ID. This makes it easy to:- Query Snag users from your system
- Link Snag data back to your users
- Debug migration issues
- Avoid duplicate migrations
Keep a Migration Log
Keep a Migration Log
Log all migration attempts with timestamps, user IDs, and results. This helps with debugging and provides an audit trail.
Plan for Rollback
Plan for Rollback
Have a rollback strategy in case something goes wrong. Keep track of which users were migrated so you can clean up if needed.
Handle Idempotency
Handle Idempotency
The metadata endpoint is idempotent - calling it multiple times with the same wallet address updates the user. This means you can safely re-run your migration script.
Monitor During Migration
Monitor During Migration
Watch for errors, rate limits, and performance issues during migration. Be prepared to pause and adjust your approach if needed.
Handling Users Without Wallet Addresses
If some of your users don’t have wallet addresses, you have several options:Generate Wallets
Generate wallet addresses programmatically using viem or smart wallet providers
Prompt Users
Ask users to connect their wallets during their next login
Gradual Migration
Migrate users as they connect wallets, rather than all at once
Email-Based
Use email-to-wallet services to create wallets tied to email addresses
Complete Migration Example
Here’s a complete, production-ready migration script:Next Steps
Generate Wallet Addresses
Learn how to generate wallet addresses for users who don’t have them
Manage User Groups
Connect multiple wallets to a single user using user groups
Connect Social Accounts
Integrate social media platforms with your users
Create Users
Learn more about creating and managing individual users