> ## Documentation Index
> Fetch the complete documentation index at: https://doc-dev.weir.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# User Registration

> Register new users with organization creation

# User Registration

Register new users with automatic organization creation for platform or agency accounts.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.weir.ai/auth/register' \
    -H 'Content-Type: application/json' \
    -d '{
      "fullname": "John Doe",
      "email": "john.doe@example.com",
      "password": "SecurePassword123!",
      "organization": {
        "name": "Acme Corporation",
        "type": "Platform",
        "description": "A business platform for NIL management"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "data": {
      "otpSession": "otp_session_123456789",
      "email": "john.doe@example.com",
      "expiresIn": 300
    },
    "message": "Registration successful. Please verify your email with the OTP sent.",
    "status": "success"
  }
  ```
</ResponseExample>

## Authentication

This endpoint does not require authentication as it's used for new user registration.

## Request Body

<ParamField body="fullname" type="string" required>
  User's full name. Must be between 2-100 characters.
</ParamField>

<ParamField body="email" type="string" required>
  User's email address. Must be a valid email format and unique in the system.
</ParamField>

<ParamField body="password" type="string" required>
  User's password. Must meet security requirements (min 8 characters, uppercase, lowercase, number, special character).
</ParamField>

<ParamField body="organization" type="object" required>
  Organization information for the new account.

  <Expandable title="Organization Properties">
    <ParamField body="organization.name" type="string" required>
      Organization name. Must be unique and between 2-100 characters.
    </ParamField>

    <ParamField body="organization.type" type="string" required>
      Organization type. Must be one of: "Platform", "Agency", "Brand".
    </ParamField>

    <ParamField body="organization.description" type="string">
      Optional description of the organization. Maximum 500 characters.
    </ParamField>
  </Expandable>
</ParamField>

## Response Fields

<ResponseField name="data" type="object" required>
  Registration data object containing OTP session information.

  <Expandable title="Registration Data Properties">
    <ResponseField name="data.otpSession" type="string" required>
      OTP session identifier used for email verification. Valid for 5 minutes.
    </ResponseField>

    <ResponseField name="data.email" type="string" required>
      Email address where the OTP was sent.
    </ResponseField>

    <ResponseField name="data.expiresIn" type="integer" required>
      OTP expiration time in seconds. Always 300 (5 minutes).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="message" type="string" required>
  Human-readable message describing the result of the operation.
</ResponseField>

<ResponseField name="status" type="string" required>
  Operation status. Always "success" for successful registration.
</ResponseField>

## Error Responses

<AccordionGroup>
  <Accordion title="400 Bad Request" icon="exclamation-triangle">
    ```json theme={null}
    {
      "error": {
        "code": "VALIDATION_ERROR",
        "message": "Invalid request parameters",
        "details": {
          "email": "Invalid email format",
          "password": "Password must be at least 8 characters with uppercase, lowercase, number, and special character",
          "organization.name": "Organization name is required"
        }
      },
      "status": "error"
    }
    ```

    **Causes**:

    * Invalid email format
    * Weak password
    * Missing required fields
    * Invalid organization type
  </Accordion>

  <Accordion title="409 Conflict" icon="exclamation">
    ```json theme={null}
    {
      "error": {
        "code": "EMAIL_EXISTS",
        "message": "Email already registered",
        "details": "An account with this email already exists"
      },
      "status": "error"
    }
    ```

    **Causes**:

    * Email already registered in the system
    * Duplicate registration attempt
  </Accordion>

  <Accordion title="429 Too Many Requests" icon="clock">
    ```json theme={null}
    {
      "error": {
        "code": "RATE_LIMIT_EXCEEDED",
        "message": "Too many registration attempts",
        "details": "Rate limit exceeded. Please try again later."
      },
      "status": "error"
    }
    ```

    **Solution**: Wait for the rate limit window to reset before trying again.
  </Accordion>
</AccordionGroup>

## Usage Examples

<CodeGroup>
  ```javascript JavaScript theme={null}
  const register = async (userData) => {
    try {
      const response = await fetch('https://api.weir.ai/auth/register', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(userData)
      });
      
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
      
      const data = await response.json();
      return data.data;
    } catch (error) {
      console.error('Registration error:', error);
      throw error;
    }
  };

  // Usage
  const registrationData = await register({
    fullname: "John Doe",
    email: "john.doe@example.com",
    password: "SecurePassword123!",
    organization: {
      name: "Acme Corporation",
      type: "Platform",
      description: "A business platform for NIL management"
    }
  });
  console.log('OTP Session:', registrationData.otpSession);
  ```

  ```python Python theme={null}
  import requests

  def register(user_data):
      try:
          response = requests.post(
              'https://api.weir.ai/auth/register',
              json=user_data
          )
          response.raise_for_status()
          
          data = response.json()
          return data['data']
      except requests.exceptions.RequestException as e:
          print(f'Registration error: {e}')
          raise

  # Usage
  registration_data = register({
      'fullname': 'John Doe',
      'email': 'john.doe@example.com',
      'password': 'SecurePassword123!',
      'organization': {
          'name': 'Acme Corporation',
          'type': 'Platform',
          'description': 'A business platform for NIL management'
      }
  })
  print(f'OTP Session: {registration_data["otpSession"]}')
  ```

  ```php PHP theme={null}
  function register($userData) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, 'https://api.weir.ai/auth/register');
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      
      $response = curl_exec($ch);
      $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
      curl_close($ch);
      
      if ($httpCode !== 200) {
          throw new Exception("HTTP error: $httpCode");
      }
      
      $data = json_decode($response, true);
      return $data['data'];
  }

  // Usage
  $registrationData = register([
      'fullname' => 'John Doe',
      'email' => 'john.doe@example.com',
      'password' => 'SecurePassword123!',
      'organization' => [
          'name' => 'Acme Corporation',
          'type' => 'Platform',
          'description' => 'A business platform for NIL management'
      ]
  ]);
  echo "OTP Session: " . $registrationData['otpSession'];
  ```
</CodeGroup>

## Registration Flow

<Steps>
  <Step title="User Registration" icon="user-plus">
    User submits registration form with email, password, and organization details.
  </Step>

  <Step title="OTP Sent" icon="envelope">
    System sends OTP to the provided email address and returns OTP session ID.
  </Step>

  <Step title="Email Verification" icon="check">
    User enters OTP using the validate registration endpoint with the OTP session ID.
  </Step>

  <Step title="Account Activated" icon="check-circle">
    Upon successful verification, the account is activated and user can login.
  </Step>
</Steps>

## Password Requirements

<AccordionGroup>
  <Accordion title="Minimum Requirements" icon="lock">
    * Minimum 8 characters
    * At least one uppercase letter (A-Z)
    * At least one lowercase letter (a-z)
    * At least one number (0-9)
    * At least one special character (!@#\$%^&\*)
  </Accordion>

  <Accordion title="Recommended Practices" icon="shield">
    * Use 12+ characters for better security
    * Avoid common words and patterns
    * Don't reuse passwords from other services
    * Use a password manager
  </Accordion>
</AccordionGroup>

## Organization Types

<AccordionGroup>
  <Accordion title="Platform" icon="server">
    For platform businesses that host content and need NIL management capabilities.
  </Accordion>

  <Accordion title="Agency" icon="building">
    For talent agencies managing multiple talent rosters and licensing.
  </Accordion>

  <Accordion title="Brand" icon="tag">
    For brands that need to manage NIL rights for advertising and marketing.
  </Accordion>
</AccordionGroup>

## Best Practices

<Steps>
  <Step title="Validate Input" icon="check">
    Validate all input fields on the client side before submission.
  </Step>

  <Step title="Secure Password" icon="lock">
    Implement password strength indicators and requirements.
  </Step>

  <Step title="Handle Errors" icon="exclamation-triangle">
    Display clear error messages for validation failures.
  </Step>

  <Step title="Complete Verification" icon="envelope">
    Guide users through the email verification process.
  </Step>
</Steps>

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Validate Registration" icon="check" href="/v1.0.1/api-reference/console-apis/auth/validate-registration">
    Verify email with OTP to activate account.
  </Card>

  <Card title="Resend OTP" icon="refresh" href="/v1.0.1/api-reference/console-apis/auth/resend-otp">
    Resend OTP if it expires or wasn't received.
  </Card>

  <Card title="Login" icon="sign-in-alt" href="/v1.0.1/api-reference/console-apis/auth/login">
    Login after successful registration and verification.
  </Card>

  <Card title="Mobile Registration" icon="mobile" href="/v1.0.1/api-reference/console-apis/auth/mobile-register">
    Simplified registration for mobile apps.
  </Card>
</CardGroup>

<Tip>
  **Pro Tip**: Store the OTP session ID securely and guide users to check their email immediately after registration. The OTP expires in 5 minutes.
</Tip>
