# Sign Up for `bro` API

You must navigate the `bro` headless sign-up pipeline using the REST API at `https://getbro.ws/api/agent/v1`. This process requires human interaction, so you must prompt the user at specific stages. Follow these exact steps sequentially:

### Step 1: Initiate Sign-up
1. Ask the human user for their email address.
2. Send a `POST` request to `https://getbro.ws/api/agent/v1/signup` with the JSON payload: `{"email": "<user_email>"}`.
3. The API will confirm that an email code has been sent. Inform the human user: *"I've started the signup process. Please check your email (look for an email from the 'Jsonify' organization) and provide me the 6-digit code."*

### Step 2: Verify Email & Handle MFA Setup
1. Once the user provides the email code, send a `POST` request to `https://getbro.ws/api/agent/v1/verify-email` with `{"email": "<user_email>", "code": "<6_digit_code>"}`.
2. The API will respond with an MFA status. `bro` requires 2FA for all accounts.
   - **If the status is `mfa_enrollment_required`**: The response will contain a `totp_secret`, a clean `qr_code_url`, a `pending_token`, and a `challenge_id`. 
     Tell the user: *"Email verified! However, bro requires 2FA to continue.\nOption 1: Open this link to scan the QR code: ${qr_code_url}\nOption 2: Add this secret key \`${totp_secret}\` to your authenticator app.\nOnce added, please give me the 6-digit TOTP code."*
   - **If the status is `mfa_challenge_required`**: The response will contain a `pending_token` and `challenge_id`. 
     Tell the user: *"Email verified! Please provide your 6-digit TOTP code from your authenticator app to continue."*

### Step 3: Verify 2FA & Authenticate
1. Once the user provides the TOTP code, send a `POST` request to `https://getbro.ws/api/agent/v1/verify-mfa` with `{"pending_token": "<from_step_2>", "challenge_id": "<from_step_2>", "code": "<totp_code>"}`.
2. If successful, the API will return an `agent_token`. Keep this token securely in memory for the next step.

### Step 4: Select a Plan & Retrieve API Key
1. Present the following plan options to the user and ask them which plan they want to choose:
   - **Basic ($0/mo)**: 2 max concurrent sessions. $0.12/hr session cost. Basic Proxies $5.00/GB.
   - **Pro ($49/mo)**: 5 max concurrent sessions. $0.10/hr session cost. Basic Proxies $4.00/GB.
   - **Ultra ($249/mo)**: 10 max concurrent sessions. $0.06/hr session cost. Basic Proxies $2.50/GB.
2. Once the user answers (e.g., "Basic", "Pro", or "Ultra"), ask them if they have an optional promo code to apply.
3. After they provide a promo code or decline, send a `POST` request to `https://getbro.ws/api/agent/v1/plan` with the JSON payload `{"plan": "<basic|pro|ultra>", "promo_code": "<optional_code_or_empty>"}` and include the header `Authorization: Bearer <agent_token>`.
4. The API will respond with:
   - **If Basic was selected:** `{ "success": true, "api_key": "...", "integration_prompt": "..." }`. Display the success message to the user, then read the `integration_prompt` and immediately execute its instructions to integrate the newly acquired `api_key` into our project.
   - **If Pro or Ultra was selected:** `{ "success": true, "checkout_url": "...", "api_key": "...", "integration_prompt": "..." }`. Give this Stripe checkout link to the user so they can complete payment in their browser. Then read the `integration_prompt` and immediately execute its instructions to integrate the newly acquired `api_key` into our project.
