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

# User Registration

Create a new user account programmatically via the API.

Create a new user account programmatically via the API. This mutation provisions a complete user with account, network seat, balances, and referral capabilities.

<Warning>
  **Restricted Access**

  This endpoint requires special permission from Fluz. Contact your account manager to enable user registration for your application.
</Warning>

```graphql theme={null}
mutation RegisterUser(
  $firstName: String!
  $lastName: String!
  $phoneNumber: String!
  $regionCode: String!
  $emailAddress: String!
  $dateOfBirth: String!
) {
  registerUser(
    firstName: $firstName
    lastName: $lastName
    phoneNumber: $phoneNumber
    regionCode: $regionCode
    emailAddress: $emailAddress
    dateOfBirth: $dateOfBirth
  ) {
    success
    error
  }
}
```

<br />

### Parameters

| Parameter    | Type   | Required | Description                                                                                 |
| :----------- | :----- | :------- | :------------------------------------------------------------------------------------------ |
| firstName    | String | Yes      | The user's first name                                                                       |
| lastName     | String | Yes      | The user's last name                                                                        |
| phoneNumber  | String | Yes      | The user's phone number (digits and `-` accepted). e.g., `"5551234567"` or `"555-123-4567"` |
| regionCode   | String | YES      | ISO 3166-1 alpha-2 country code for the phone number (e.g., `"US"`, `"CA"`)                 |
| emailAddress | String | Yes      | The user's email address                                                                    |
| dateOfBirth  | String | Yes      | The user's date of birth in `YYYY-MM-DD` format                                             |

<br />

### Response

#### Success Response

```json theme={null}
{
  "data": {
    "registerUser": {
      "success": true,
      "error": null
    }
  }
}
```

<br />

### Response Fields

| Field     | Type              | Description                                                                            |
| :-------- | :---------------- | :------------------------------------------------------------------------------------- |
| `success` | Boolean           | `true` if the user was successfully registered                                         |
| `error`   | RegisterUserError | If `success` is false, will return an Error object that holds the `message` and `code` |

<br />

> Note: This mutation returns errors in the response data, not as GraphQL errors. Always check the success field and handle the error object when success is false.

### Example Request

```curl theme={null}
curl -X POST https://transactional-graph.staging.fluzapp.com/api/v1/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "query": "mutation RegisterUser($firstName: String!, $lastName: String!, $phoneNumber: String!, $regionCode: String!, $emailAddress: String!, $dateOfBirth: String!) { registerUser(firstName: $firstName, lastName: $lastName, phoneNumber: $phoneNumber, regionCode: $regionCode, emailAddress: $emailAddress, dateOfBirth: $dateOfBirth) { success error { code message } } }",
  "variables": {
    "firstName": "Jane",
    "lastName": "Doe",
    "phoneNumber": "5551234567",
    "regionCode": "US",
    "emailAddress": "jane.doe@example.com",
    "dateOfBirth": "1990-05-15"
  }
}'
```

```typescript theme={null}
const response = await fetch('https://transactional-graph.staging.fluzapp.com/api/v1/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`
  },
  body: JSON.stringify({
    query: `
      mutation RegisterUser(
        $firstName: String!
        $lastName: String!
        $phoneNumber: String!
        $regionCode: String!
        $emailAddress: String!
        $dateOfBirth: String!
      ) {
        registerUser(
          firstName: $firstName
          lastName: $lastName
          phoneNumber: $phoneNumber
          regionCode: $regionCode
          emailAddress: $emailAddress
          dateOfBirth: $dateOfBirth
        ) {
          success
          error {
            code
            message
          }
        }
      }
    `,
    variables: {
      firstName: "Jane",
      lastName: "Doe",
      phoneNumber: "5551234567",
      regionCode: "US",
      emailAddress: "jane.doe@example.com",
      dateOfBirth: "1990-05-15"
    }
  })
});

const data = await response.json();

if (data.data.registerUser.success) {
  console.log('User registered successfully!');
} else {
  console.error('Registration failed:', data.data.registerUser.error);
}
```

### Error Codes

| Code        | Message                                                    | Description                                                                                                  |
| :---------- | :--------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------- |
| `AUTH-0004` | Invalid phone number                                       | The phone number format is invalid or cannot be parsed with the given region code.                           |
| `AUTH-0022` | Registration not allowed, please contact customer support! | Your application does not have permission to register users. Contact Fluz support to enable this capability. |
| `AUTH-0025` | Please try again or contact support.                       | A general registration failure occurred. Please retry or contact support.                                    |
| `AUTH-0026` | The phone number you chose is already in use.              | The phone number is already associated with an existing account.                                             |
| `AUTH-0027` | The email address you chose is already in use.             | The email address is already associated with an existing account.                                            |
| `AUTH-0030` | Your application is not active.                            | Your application is not active and cannot register users.                                                    |

<br />
