Skip to main content
This guide walks you through migrating your existing user base to Snag’s loyalty system. Whether you’re moving from another platform or setting up Snag for the first time, this guide will help you successfully migrate your users.

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:
1

Prepare your user data

Export your user data and ensure you have wallet addresses for each user.
Users without wallet addresses cannot be created in Snag. If your users don’t have wallet addresses, see our wallet generation guide for guidance on how to create them.

Required Data

  • walletAddress (required) - The unique blockchain wallet address

Optional Metadata

  • externalIdentifier - Your internal user ID (highly recommended)
  • displayName - User’s display name
  • emailAddress - User’s email address
  • discordUser - Discord username
  • discordUserId - Discord user ID
  • twitterUser - Twitter/X username
  • twitterUserId - Twitter/X user ID
  • telegramUsername - Telegram username
  • telegramUserId - Telegram user ID
  • logoUrl - URL to user’s avatar/profile picture
2

Set up your migration script

Create a script to process your users in batches. Here’s a complete example:
3

Process in batches

For large migrations, process users in batches to avoid rate limits and make the process more manageable:
Start with a small batch (10-50 users) to verify your migration script works correctly before processing your entire user base.
4

Verify migration

After migration, verify that all users were created successfully:
5

Handle failed migrations

Review and retry failed migrations:
Common errors and solutions:
  • Invalid wallet address - Verify the wallet address format
  • Duplicate user - User already exists, use update instead
  • Rate limit - Increase delay between batches
  • Authentication error - Check your API key

Migration Best Practices

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.
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
Log all migration attempts with timestamps, user IDs, and results. This helps with debugging and provides an audit trail.
Have a rollback strategy in case something goes wrong. Keep track of which users were migrated so you can clean up if needed.
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.
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