# Create User

Use the `createUser` mutation to create a new account for an end-user on your organization's account.

{% hint style="info" %}
**Anonymization:** Kindly be aware that the essential fields for creating a user profile include the name and email. If you prefer a completely anonymous format, you are welcome to provide a generic user name, like "\<ORGANIZATION\_NAME> User," and a distinct email address, such as "\<USER\_ID>@\<ORGANIZATION\_DOMAIN>".
{% endhint %}

## **Arguments**

<table data-header-hidden><thead><tr><th>Argument</th><th width="150">Required</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>Argument</strong></td><td><strong>Required</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>name</code></td><td>True</td><td>String</td><td>User's name</td></tr><tr><td><code>email</code></td><td>True</td><td>String</td><td>User's email</td></tr><tr><td><code>phone</code></td><td>False</td><td>String</td><td>User's phone</td></tr><tr><td><code>password</code></td><td>False</td><td>String</td><td>Set up a user's password</td></tr><tr><td><code>program</code></td><td>False</td><td>String</td><td>Include the database ID of the Program. If this parameter is not sent, the program can be later assgined by using the <a href="https://docs.suggestic.com/graphql/query/mutations/user-profile/set-program"><code>updateUserProgram</code></a> mutation</td></tr><tr><td><code>restrictions</code></td><td>False</td><td>String</td><td>Restriction Base-64 ID. If this parameter is not sent, restrictions can be later assigned by using the <a href="https://docs.suggestic.com/graphql/query/mutations/user-profile/profilerestrictionsupdate"><code>profileRestrictionsUpdate</code></a> mutation</td></tr><tr><td><code>emailPasswordNotification</code></td><td>False</td><td>Boolean</td><td>Notification sent via email to set up a user's password</td></tr><tr><td><code>subscription</code></td><td>False</td><td>ID</td><td>Base-64 subscription ID which will be assigned to the created user.</td></tr></tbody></table>

## Available Fields

The following fields will be displayed in the response:

| Field     | Type                                                           | Description                                                                        |
| --------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `success` | string                                                         | **True** if the user has been created successfully. Otherwise, **False**           |
| `message` | string                                                         | Description of the result                                                          |
| `user`    | [user](https://docs.suggestic.com/graphql/objects/common/user) | A structured version of user information. It contains `id` and `databaseId` fields |

## **Examples**

### GraphQL

{% tabs %}
{% tab title="Mutation" %}

```graphql
mutation {
  createUser(
    name: "Ernesto"
    email: "ernesto@suggestic.com"
  ) {
    success
    message
    user {
      id
      databaseId
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "createUser": {
      "success": true,
      "message": "User created",
      "user": {
        "id": "VXNlcjpWWE5sY2pvMk16QXlORE5oTWkxaVl6Rm1MVFEzWkdNdFlqbGtOaTAyTldOak1qa3lOMkZrWW1NPQ==",
        "databaseId": "630243a2-bc1f-47dc-b9d6-65cc2927adbc"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Setup a user's password

The following example creates a user and sets up the password without sending an email notification.

{% tabs %}
{% tab title="Request" %}

```graphql
mutation {
  createUser(
    name: "userCTest"
    email: "userCTest@gmail.com"
    password: "F7YTu_ER#$" 
    program: "01bbd541-939b-4b85-8d90-48ff0b02d0ee"
    restrictions: [
      "UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1",
      "UmVzdHJpY3Rpb246ODU1ZjkzZjYtODQzOC00MTIzLTk3YzktM2U2YzU2MzllZjli"
    ] 
  ) {
    success
    message
    user {
      id
      databaseId
      profileId
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "createUser": {
      "success": true,
      "message": "User created",
      "user": {
        "id": "VXNlcjpWWE5sY2pvNE5USmhNV1ZpTWkwek1EWm1MVFJsWlRFdE9HVmlaUzB4WlROa016WTNNV014TXpFPQ==",
        "databaseId": "852a1eb2-306f-4ee1-8ebe-1e3d3671c131",
        "profileId": "97e4dd59-46bc-4f50-89b4-cdacbf57f515"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Send an email to set up a password

The following example creates a user and sends a password notification to the user's email to set up a password.

{% tabs %}
{% tab title="Mutation" %}

```php
mutation {
   createUser(
    name: "Liliana"
    email: "liliana@suggestic.com" emailPasswordNotification: true
  ) {
    success
    message
    user {
      id
      databaseId
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```php
{
  "data": {
    "createUser": {
      "success": true,
      "message": "User created",
      "user": {
        "id": "VXNlcjpWWE5sY2pwa05EYzFaR0ZpT0MwMFpESXpMVFJqTkRndFlXTTBNUzFsWkRJM1lqTXpZekZtWlRVPQ==",
        "databaseId": "d475dab8-4d23-4c48-ac41-ed27b33c1fe5"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

The following notification will arrive in the user's email:

![](/files/-Mc9hS3Oo3tZz5LCMtar)

Click on **this link** to set up the password, users are redirected to the following page where a new password must be introduced:

![](/files/-Mc9hltHauXMaQ_AgPBk)

### Assign a subscription to the user

{% tabs %}
{% tab title="Request" %}

```graphql
mutation {
  createUser(
    name: "userCTest"
    email: "userCTest@gmail.com"
    program: "01bbd541-939b-4b85-8d90-48ff0b02d0ee"
    subscription: "NjI2NzEwNDEtOTI5Yi00MzJlLWJhN2ItMDNjZjFmZWYzZGQ0"
  ) {
    success
    message
    user {
      id
      databaseId
      profileId
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```
{
  "data": {
    "createUser": {
      "success": true,
      "message": "User created",
      "user": {
        "id": "VXNlcjpWWE5sY2pvNE5USmhNV1ZpTWkwek1EWm1MVFJsWlRFdE9HVmlaUzB4WlROa016WTNNV014TXpFPQ==",
        "databaseId": "852a1eb2-306f-4ee1-8ebe-1e3d3671c131",
        "profileId": "97e4dd59-46bc-4f50-89b4-cdacbf57f515"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

The following message is displayed in case the subscription does not exist:

{% tabs %}
{% tab title="Response" %}

```graphql
{
  "data": {
    "createUser": {
      "success": false,
      "message": "Subscription doesn't exist",
      "user": null
    }
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.suggestic.com/graphql/query/mutations/user-profile/new-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
