Add user invitation functionality using Turalogin. This allows admins to invite users via email with a custom message.
How it works:
1. Admin enters the user's email and a custom welcome message
2. Your backend calls Turalogin's invite API
3. Turalogin sends a branded invite email with the admin's message
4. User clicks the link, which redirects to your app with a token
5. Your backend verifies the token (same as login flow)
6. User is now authenticated and onboarded
API Details:
- Base URL: https://api.turalogin.com/api/v1
- IMPORTANT: Every API request MUST include the Authorization header:
Authorization: Bearer <TURALOGIN_API_KEY>
Environment Variables:
- TURALOGIN_API_KEY: Your API key from the dashboard
- APP_INVITE_VALIDATION_URL: The URL where invite links redirect to
- Development: http://localhost:3000/auth/callback
- Production: https://myapp.com/auth/callback
Example fetch call:
fetch('https://api.turalogin.com/api/v1/auth/invite', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.TURALOGIN_API_KEY}`
},
body: JSON.stringify({
email: 'newuser@example.com',
message: 'Welcome to our team! Click below to get started.',
validationUrl: process.env.APP_INVITE_VALIDATION_URL
})
})
Endpoint:
POST /auth/invite
Body: { email, message, validationUrl }
- email: The user's email address to invite
- message: Custom message from admin (max 500 chars, shown in invite email)
- validationUrl: The URL where the invite link redirects (e.g., https://myapp.com/auth/callback)
Returns: { success, sessionId, message, expiresAt }
Verification (same as login):
POST /auth/verify - Body: { sessionId } → Returns: { token, user: { email, id } }
Please create:
1. Admin invite form with email input and message textarea
2. API endpoint to send invites (calls Turalogin /auth/invite)
3. The callback page can be shared with your login flow (same /auth/verify process)
4. Show success/error states after sending invite
5. Optionally track pending invites in your database