> For the complete documentation index, see [llms.txt](https://docs.suggestic.com/telewellness-portal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.suggestic.com/telewellness-portal/api-reference/coaches/create-a-coach.md).

# Create a Coach

In order to create a coach we require to use a combination of two mutations `createUser` and `makeCoach`.&#x20;

`createUser` will create the new user inside the console while `makeCoach` will grant access to the coaching portal.

Both should be run on our "[console API](https://production.suggestic.com/pcp/graphql)", so you will need to generate the "Authorization Token" which is required as an authorization header (example below).

## Generate Token

| **Argument Name** | **Is required?** | **Type** |              **Description**              |
| :---------------: | :--------------: | :------: | :---------------------------------------: |
|       email       |        Yes       |  string  |            Console Admin email            |
|      password     |        Yes       |  string  | Object that contains the password fields. |

## Create User

<table data-header-hidden><thead><tr><th align="center">Field Name</th><th width="324.3333333333333" align="center">Type</th><th align="center">Description</th></tr></thead><tbody><tr><td align="center"><strong>Field Name</strong></td><td align="center"><strong>Type</strong></td><td align="center"><strong>Description</strong></td></tr><tr><td align="center">email</td><td align="center">String</td><td align="center">Coach user email</td></tr><tr><td align="center">name</td><td align="center">String</td><td align="center">Coach name</td></tr><tr><td align="center">password</td><td align="center">String</td><td align="center">Coach password</td></tr><tr><td align="center">roles</td><td align="center">Array</td><td align="center">Viewer</td></tr><tr><td align="center">active</td><td align="center">Boolean</td><td align="center"><strong>True</strong> if the coach will be active. Otherwise, <strong>False</strong></td></tr></tbody></table>

## Make Coach

| **Field Name** | **Type** |        **Description**        |
| :------------: | :------: | :---------------------------: |
|      email     |  String  |        Coach user email       |
|      name      |  String  |           Coach name          |
|  isCoachAdmin  |  Boolean | Set to **True** to make coach |

## Available Fields

The following fields will be displayed in the response:

| **Field Name** | **Type** |                                                       **Description**                                                      |
| :------------: | :------: | :------------------------------------------------------------------------------------------------------------------------: |
|    `success`   |  Boolean | <p><strong>True</strong> if the coach information has been created successfully. Otherwise, <strong>False</strong><br></p> |
|    `message`   |  String  |                                                  Description of the result                                                 |

## Examples

**Generate access token**

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

```graphql
mutation {
  login(email: "admin@gmail.com" password: "pp455word") {
    success accessToken
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "login": {
      "success": true,
      "accessToken": "eyJ0eXAiOiJKV1QiJCJhbGciOiJIUzI1NiJ9.EyJleHAiUjE2NjA4NDMwMzMsImlzcyI6InNnOnBvcnRhbCIsImlhdCI6MTY1ODI1MTAzMywidWlkIjoiMTA2NCIsImVtYWlsIjoicmV2ZXJzZWhlYWx0aEBzdWdnZXN0aWMuY29tIiwidGhpcmRwYXJ0eSI6IjIxNjAiLCJyb2xlcyI6WyJBRE1JTiIsIkNPQUNIX0FETUlOIiwiQ09BQ0hfQUxMX01FTUJFUlMiLCJDT0FDSCJdLCJzZXNzaW9uIjoiZko3bDVldTIzYUhnIn0.T9MtDLrw-l1086R4qNcD3S3HxRZV5HamlVzX_BPMT3s"
    }
  }
}
```

{% endtab %}
{% endtabs %}

**Create coach**

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

```graphql
mutation {
    createUser(
        email: "user@gmail.com"
        name: "Scott Pilgrim"
        password: "pp455w0rd"
        roles: ["VIEWER"]
        active: true
    ) {
        success message
    }
    makeCoach(
        email: "user@gmail.com"
        name: "Scott Pilgrim"
        isCoachAdmin: true
    ) {
        success message
    }
}
```

{% endtab %}

{% tab title="Headers" %}

```graphql
{
Authorization: "JWT eyJ0eXAiOiJKV1QiJCJhbGciOiJIUzI1NiJ9.EyJleHAiUjE2NjA4NDMwMzMsImlzcyI6InNnOnBvcnRhbCIsImlhdCI6MTY1ODI1MTAzMywidWlkIjoiMTA2NCIsImVtYWlsIjoicmV2ZXJzZWhlYWx0aEBzdWdnZXN0aWMuY29tIiwidGhpcmRwYXJ0eSI6IjIxNjAiLCJyb2xlcyI6WyJBRE1JTiIsIkNPQUNIX0FETUlOIiwiQ09BQ0hfQUxMX01FTUJFUlMiLCJDT0FDSCJdLCJzZXNzaW9uIjoiZko3bDVldTIzYUhnIn0.T9MtDLrw-l1086R4qNcD3S3HxRZV5HamlVzX_BPMT3s"
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "createCoach": {
      "success": true
    }
    "makeCoach":{
      "success": true
    }
  }
}
```

{% endtab %}
{% endtabs %}
