# Users

## Create a User

This endpoint allows you to create a new user account within Forge. In order to properly use Forge, a user account must be created. Note that this endpoint requires both a `name` and `email` value and returns a `userId`. The `userId` value is unique for every user created. It is strongly advised that you save this `userId` in your database for use later on.

## Create a user

<mark style="color:green;">`POST`</mark> `https://api.runalloy.com/forge/2021-12/user`

Creates a new user in your Forge account

#### Headers

| Name                          | Type   | Description                          |
| ----------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey} | String | Your Forge API key for authorization |

#### Request Body

| Name                                    | Type   | Description                                         |
| --------------------------------------- | ------ | --------------------------------------------------- |
| name<mark style="color:red;">\*</mark>  | string | The name of the user. Typically a full name.        |
| email<mark style="color:red;">\*</mark> | string | The email associated with the user. Must be unique. |

{% tabs %}
{% tab title="200 OK" %}

```javascript
{
  "userId": "61ab8f99251cba0014437326"
}
```

{% endtab %}

{% tab title="401 Permission denied" %}

{% endtab %}
{% endtabs %}

## List all Users

This endpoint returns a list of users in your Forge account. It returns an `email`, `fullName` and `_id` value for every user.&#x20;

{% hint style="success" %}
The `_id` value is the user's unique identifier within Forge and is sometimes referred to in this API Reference as `userId`.
{% endhint %}

## List all users

<mark style="color:blue;">`GET`</mark> `https://api.runalloy.com/forge/2021-12/user`

Return a list of all users created in your Forge account.

#### Headers

| Name                                                            | Type   | Description                          |
| --------------------------------------------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey}<mark style="color:red;">\*</mark> | String | Your Forge API key for authorization |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "data": [
    {
      "_id": "6152859092c82a00151ef1ec",
      "email": "example-demo@runalloy.com",
      "fullName": "Jane Doe"
    },
    {
      "_id": "619964a069ac6f0015394700",
      "email": "joesmoe@email.com",
      "fullName": "Joe Smoe"
    },
    {
      "_id": "61ab8f99251cba0014437326",
      "email": "name@email.com",
      "fullName": "User Name"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Get a User

This endpoint returns a specific user object provided a `userId`. The `userId` value represents the unique identifier for each user and can be obtained from the **List all Users** endpoint.  It also returns any associated child workflows the user may have created.

## Get a user

<mark style="color:blue;">`GET`</mark> `https://api.runalloy.com/forge/2021-12/user/:userId`

Returns a specific user object given a `userId` and any workflows associated with the user.

#### Headers

| Name                                                            | Type   | Description                          |
| --------------------------------------------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey}<mark style="color:red;">\*</mark> | String | Your Forge API key for authorization |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "_id": "6152859092c82a00151ef1ec",
  "fullName": "Jane Doe",
  "email": "example-demo@runalloy.com",
  "workflows": [
    {
      "_id": "6152859092c82a00151ef1eb",
      "parentId": "6152859092c82a00151ef1ea",
      "name": "Add Customer To Shopify",
      "active": true,
      "blocks": [
        {
          "icon": "https://cdn.runalloy.com/icons/shopify.png",
          "displayName": "Shopify",
          "name": "alloy.shopify"
        }
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Update a User

This endpoint is used to update a specific user account provided a `userId`. The `userId` value represents the unique identifier for each user and can be obtained from the **List all Users** endpoint.

<mark style="color:purple;">`PATCH`</mark> `https://api.runalloy.com/forge/2021-12/user/:userId`

#### Headers

| Name                                                            | Type   | Description                          |
| --------------------------------------------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey}<mark style="color:red;">\*</mark> | String | Your Forge API key for authorization |

#### Request Body

| Name                                       | Type   | Description                    |
| ------------------------------------------ | ------ | ------------------------------ |
| email<mark style="color:red;">\*</mark>    | String | The email you want to update   |
| fullName<mark style="color:red;">\*</mark> | String | The name of the user to update |

{% tabs %}
{% tab title="200: OK " %}

```javascript
 {  
   "_id": "6152859092c82a00151ef1ec"
   "fullName": "Jane J Joe",
   "email": "jane@runalloy.com"
 }

```

{% endtab %}
{% endtabs %}

## Delete a User <a href="#deleteuser" id="deleteuser"></a>

This endpoint is used to delete a user account provided a `userId`.  The `userId` value represents the unique identifier for each user and can be obtained from the **List all Users** endpoint.\
\
Deleting a user removes their account and all associated workflows.&#x20;

## Delete a User

<mark style="color:red;">`DELETE`</mark> `https://api.runalloy.com/forge/2021-12/user/:userId`

This endpoint deletes a user account. It is most commonly used when a user stops being a customer of your platform or in conjunction with a GDPR [compliance request](/alloy-developer/reference/api-reference/compliance.md#delete-logs-for-a-user).

#### Headers

| Name                                                            | Type   | Description                          |
| --------------------------------------------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey}<mark style="color:red;">\*</mark> | String | Your Forge API key for authorization |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{ 
    "success": true 
}
```

{% endtab %}
{% endtabs %}

&#x20;

## User Token

This endpoint is used to retrieve a user token (in the form of a JWT). The user token is required to securely render the Forge Modal in your application and must be regenerated *every* time you want to show the Forge modal.

## User Token

<mark style="color:blue;">`GET`</mark> `https://api.runalloy.com/forge/2021-12/user/:userId/token`

This endpoint is used to retrieve a user token (in the form of a JWT) which is required to securely render the Forge Modal in your application.

#### Headers

| Name                                                                                         | Type   | Description                          |
| -------------------------------------------------------------------------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey}Authorization Bearer {apiKey}<mark style="color:red;">\*</mark> | String | Your Forge API key for authorization |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjYxNTI4NTkwOTJjODJhMDAxNTFlZjFlYyJ9LCJpYXQiOjE2Mzg2MzM0MjAsImV4cCI6MTYzODYzNzAyMH0.XaNSBu5rd25xQ00tye-7eNsowbDED-dOyW46qRauILQ"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Remember that you must invoke this endpoint *every* time you want to generate the Forge modal. For security, the JWT generated only lasts a maximum of 30 minutes. Therefore, you will need to actively regenerate this token to re-render the modal each time.
{% endhint %}


---

# 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://gregg.gitbook.io/alloy-developer/reference/api-reference/users.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.
