Agent Autonomous Sign Up
If you want your AI agents to automatically sign up for an account, navigate 2FA enrollment and choose a pricing tier autonomously, you can use the built-in BroAgentAuth helper class. It automatically manages state (like pending tokens and challenge IDs) across the multi-step sign-up process.
pythonfrom bro.auth import BroAgentAuth auth = BroAgentAuth()
1. Request Email Code
Start the sign-up process by requesting an email login code.
pythonresponse = auth.request_email_code(email="[email protected]")
Returns (Dictionary):
python{ "success": True, "message": "Email code sent. You will receive an email from the 'Jsonify' organization." }
2. Verify Email Code
Verify the OTP code received in the email. Depending on your account state, this returns an MFA challenge or an MFA enrollment payload. BroAgentAuth stores the tokens for the next step.
pythonresponse = auth.verify_email_code(code="123456")
Returns (Dictionary) - Enrollment Required Example:
python{ "status": "mfa_enrollment_required", "message": "Email verified! However, bro requires 2FA to continue...", "totp_secret": "JBSWY3DPEHPK3PXP", "qr_code_url": "https://getbro.ws/auth/qr?token=...", "pending_token": "pt_...", "challenge_id": "auth_challenge_..." }
Returns (Dictionary) - Challenge Required Example:
python{ "status": "mfa_challenge_required", "message": "Email verified! Please provide your 6-digit TOTP code to continue.", "pending_token": "pt_...", "challenge_id": "auth_challenge_..." }
3. Verify MFA
Submit the TOTP code to complete authentication. The BroAgentAuth instance automatically handles passing the necessary tokens from the previous step.
pythonresponse = auth.verify_mfa_code(code="654321")
Returns (Dictionary):
python{ "status": "authenticated", "agent_token": "ey...", "message": "Auth successful. Pick a plan by POSTing to /api/agent/v1/plan..." }
4. Choose Plan
Complete the setup by choosing a plan ("basic", "pro", or "ultra"). This provisions the user and returns the final api_key for the basic plan or a Stripe checkout URL for paid plans.
pythonresponse = auth.choose_plan(plan="basic", promo_code="PROMO") print("API Key:", response.get("api_key"))
Returns (Dictionary) - Basic Plan Example:
python{ "success": True, "api_key": "sk_...", "message": "You are ready! Here is your api_key.", "integration_prompt": "I have successfully created an account..." }
Returns (Dictionary) - Paid Plan Example:
python{ "success": True, "checkout_url": "https://checkout.stripe.com/...", "message": "Payment is required for the selected plan..." }