Email address of the specific user to generate a login link for. If not provided, generates a link for the primary account holder.Validation: Must be an existing user on the account Example: [email protected]
URL to redirect the client to after successful login. Must be a permitted domain for your partner account.Format: Valid HTTPS URL Example: https://yourplatform.com/tax-dashboard
The generated secure login link for the client.Format: https://app.fifteenth.com/auth/partner-login/{token} Security: Token is cryptographically secure and single-use for initial access
data = { "user_email": "[email protected]", "expiry_hours": 48, # 2 days "purpose": "support_request", "redirect_url": "https://yourplatform.com/tax-dashboard", "send_notification": True, "notification_settings": { "partner_branded": True, "custom_subject": "New Access Link for Your Tax Account", "custom_message": "We've generated a new login link at your request. This link expires in 48 hours for security.", "include_instructions": True }}response = requests.post(url, headers=headers, json=data)link_data = response.json()print(f"Custom Login Link Generated:")print(f"- Link: {link_data['login_link']}")print(f"- Expires in: {link_data['expires_in_hours']} hours")print(f"- Redirect: {link_data['redirect_url']}")print(f"- Purpose: {link_data['purpose']}")
# Generate login link for a specific user (like an accountant)data = { "user_email": "[email protected]", "expiry_hours": 24, # 1 day for security "purpose": "additional_user", "send_notification": True, "notification_settings": { "custom_message": "Your client has granted you access to their Fifteenth account for the 2024 tax preparation." }}response = requests.post(url, headers=headers, json=data)link_data = response.json()print(f"Generated link for: {link_data['user_email']}")print(f"Link expires: {link_data['expires_at']}")
# Generate link without sending email (for manual delivery)data = { "expiry_hours": 72, # 3 days "purpose": "manual_delivery", "send_notification": False}response = requests.post(url, headers=headers, json=data)link_data = response.json()print(f"Login Link (for manual delivery): {link_data['login_link']}")print(f"No notification sent: {not link_data['notification_sent']}")# You would now deliver this link through your secure channelsecure_delivery_system.send_link( recipient=client_email, link=link_data['login_link'], expires_at=link_data['expires_at'])
def replace_expired_links(): """Automatically replace expired links for active accounts""" expired_accounts = get_accounts_with_expired_links() for account in expired_accounts: try: # Generate new link new_link = generate_login_link(account['id'], { 'purpose': 'automated_renewal', 'expiry_hours': 168, # 7 days 'send_notification': True, 'notification_settings': { 'custom_message': 'Your previous login link has expired. Here is your new access link.' } }) print(f"Renewed link for account {account['id']}") except Exception as e: print(f"Failed to renew link for {account['id']}: {e}") # Respect rate limits time.sleep(1)
def generate_support_link(ticket_id, account_id, agent_name): """Generate login link for support ticket resolution""" link_data = generate_login_link(account_id, { 'purpose': 'support_request', 'expiry_hours': 4, # Short expiry for security 'send_notification': True, 'notification_settings': { 'custom_subject': f'Support Access Link - Ticket #{ticket_id}', 'custom_message': f'Our support team has generated a secure access link to help resolve your inquiry. This link expires in 4 hours.', 'partner_branded': True }, }) # Update support ticket with link info update_ticket(ticket_id, { 'login_link_generated': True, 'link_expires_at': link_data['expires_at'], 'agent': agent_name }) return link_data