> ## Documentation Index
> Fetch the complete documentation index at: https://docs.productflo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign Up

> Create new user accounts

# Sign Up API

The signup endpoints allow new users to create accounts on the ProductFlo platform. Multiple registration methods are supported, including email, phone number, and OAuth providers.

## Email Signup

<Card title="POST /auth/signup" icon="user-plus" iconType="duotone">
  Create a new user account with email and password
</Card>

Creates a new user account with email and password authentication.

### Request

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST https://api.productflo.io/auth/signup \
      -H "Content-Type: application/json" \
      -d '{
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "john.doe@example.com",
        "password": "secure-password",
        "confirm_password": "secure-password"
      }'
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch('https://api.productflo.io/auth/signup', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        first_name: 'John',
        last_name: 'Doe',
        username: 'johndoe',
        email: 'john.doe@example.com',
        password: 'secure-password',
        confirm_password: 'secure-password'
      }),
      credentials: 'include'
    });

    const data = await response.json();
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    response = requests.post(
        'https://api.productflo.io/auth/signup',
        json={
            'first_name': 'John',
            'last_name': 'Doe',
            'username': 'johndoe',
            'email': 'john.doe@example.com',
            'password': 'secure-password',
            'confirm_password': 'secure-password'
        }
    )

    data = response.json()
    ```
  </Tab>
</Tabs>

### Request Body

<ParamField body="first_name" type="string">
  The user's first name
</ParamField>

<ParamField body="last_name" type="string">
  The user's last name
</ParamField>

<ParamField body="full_name" type="string">
  The user's full name (alternative to providing first\_name and last\_name separately)
</ParamField>

<ParamField body="username" type="string" required>
  The user's username
</ParamField>

<ParamField body="email" type="string" required>
  The user's email address
</ParamField>

<ParamField body="password" type="string" required>
  The user's password
</ParamField>

<ParamField body="confirm_password" type="string" required>
  Confirmation of the password (must match password)
</ParamField>

### Response

<ResponseField name="user" type="object">
  User information

  <Expandable title="User properties">
    <ResponseField name="id" type="string">
      The user's unique identifier
    </ResponseField>

    <ResponseField name="aud" type="string">
      The audience the token is intended for
    </ResponseField>

    <ResponseField name="role" type="string">
      The user's role (usually "authenticated")
    </ResponseField>

    <ResponseField name="email" type="string">
      The user's email address
    </ResponseField>

    <ResponseField name="email_confirmed_at" type="string">
      Timestamp when the email was confirmed (or null if not confirmed)
    </ResponseField>

    <ResponseField name="user_metadata" type="object">
      User-specific metadata including profile information

      <Expandable title="User metadata properties">
        <ResponseField name="first_name" type="string">
          User's first name
        </ResponseField>

        <ResponseField name="last_name" type="string">
          User's last name
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="session" type="object">
  Session information if auto-login is enabled
</ResponseField>

<RequestExample>
  ```json theme={null}
  {
    "first_name": "John",
    "last_name": "Doe",
    "username": "johndoe",
    "email": "john.doe@example.com",
    "password": "secure-password",
    "confirm_password": "secure-password"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "user": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "aud": "authenticated",
      "role": "authenticated",
      "email": "john.doe@example.com",
      "email_confirmed_at": null,
      "phone": "",
      "confirmed_at": null,
      "last_sign_in_at": "2023-05-01T12:34:56.789Z",
      "app_metadata": {
        "provider": "email",
        "providers": ["email"]
      },
      "user_metadata": {
        "first_name": "John",
        "last_name": "Doe"
      },
      "identities": [],
      "created_at": "2023-05-01T12:34:56.789Z",
      "updated_at": "2023-05-01T12:34:56.789Z"
    }
  }
  ```
</ResponseExample>

## Phone Signup

<Card title="POST /auth/phone-signup" icon="mobile" iconType="duotone">
  Create a new user account with phone number and password
</Card>

Creates a new user account with phone number and password authentication.

### Request

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST https://api.productflo.io/auth/phone-signup \
      -H "Content-Type: application/json" \
      -d '{
        "username": "johndoe",
        "phone_number": "+12345678901",
        "password": "secure-password",
        "confirm_password": "secure-password"
      }'
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch('https://api.productflo.io/auth/phone-signup', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        username: 'johndoe',
        phone_number: '+12345678901',
        password: 'secure-password',
        confirm_password: 'secure-password'
      }),
      credentials: 'include'
    });

    const data = await response.json();
    ```
  </Tab>
</Tabs>

### Request Body

<ParamField body="username" type="string" required>
  The user's username
</ParamField>

<ParamField body="phone_number" type="string" required>
  The user's phone number in international format (e.g., +12345678901)
</ParamField>

<ParamField body="password" type="string" required>
  The user's password
</ParamField>

<ParamField body="confirm_password" type="string" required>
  Confirmation of the password (must match password)
</ParamField>

### Response

Similar to email signup response, with phone number instead of email.

## OAuth Provider Signup

<Card title="POST /auth/provider" icon="brands-google" iconType="duotone">
  Create or login with an OAuth provider
</Card>

Initiates the OAuth flow with an external provider like Google, GitHub, etc.

### Request

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST https://api.productflo.io/auth/provider \
      -H "Content-Type: application/json" \
      -d '{
        "provider": "google"
      }'
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch('https://api.productflo.io/auth/provider', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        provider: 'google'
      })
    });

    const data = await response.json();
    // Redirect user to the provider URL
    window.location.href = data.url;
    ```
  </Tab>
</Tabs>

### Request Body

<ParamField body="provider" type="string" required>
  The OAuth provider to use (e.g., google, github, apple)
</ParamField>

### Response

<ResponseField name="url" type="string">
  URL to redirect the user to for OAuth authentication
</ResponseField>

<RequestExample>
  ```json theme={null}
  {
    "provider": "google"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=..."
  }
  ```
</ResponseExample>

## OAuth Callback

<Card title="GET /auth/callback" icon="arrow-right-to-bracket" iconType="duotone">
  Handle OAuth provider callback
</Card>

This endpoint is called by the OAuth provider after the user authenticates. It completes the OAuth flow and creates or logs in the user.

### Request

This endpoint is not typically called directly. The OAuth provider redirects to this URL with an authorization code.

```
GET /auth/callback?code=AUTHORIZATION_CODE&state=STATE
```

### Response

After successful authentication, the user is redirected to the application with an authenticated session.
