# User Management API

## Overview

{% hint style="info" %}

* This feature is available with the [**Paradime Enterprise pack**](https://www.paradime.io/enterprise).&#x20;
* Your API keys ***must*** have either [User Management Admin or User Metadata Viewer capabilities](https://docs.paradime.io/app-help/developers/generate-api-keys).
  {% endhint %}

The User Management API enables you to efficiently administer and regulate user access within your workspace.

## List Users

This endpoint will return a list of all the current active and invited users in your workspace.

**Example Request**

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

```python
import requests
import os

# API credentials
api_endpoint = "<YOUR_API_ENDPOINT>"
api_key = "<YOUR_API_KEY>"
api_secret = "<YOUR_API_SECRET>"

graphql_query = """
query ListUsers {
    listUsers {
        ok
        activeUsers {
            uid
            email
            name
            accountType
        }
        invitedUsers {
            email
            accountType
            inviteStatus
        }
    }
}
  """
  
response = requests.post(api_endpoint, json={"query": graphql_query}, headers={
      "Content-Type": "application/json",
      "X-API-KEY": api_key,
      "X-API-SECRET": api_secret,
  })

print(response.json())
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl -X POST "<YOUR_API_ENDPOINT>" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: <YOUR_API_KEY>" \
     -H "X-API-SECRET: <YOUR_API_SECRET>" \
     -d '{
       "query": "query ListUsers { listUsers { ok activeUsers { uid email name accountType } invitedUsers { email accountType inviteStatus } } }"
     }'
```

{% endtab %}
{% endtabs %}

<details>

<summary><strong>Example response</strong></summary>

```json
{
  "data": {
    "listUsers": {
      "ok": true,
      "activeUsers": [
        {
          "uid": "1b051b1e1aaf70773789c250cd0cc40a5bf27c104d1ca2c6b765767eb53c4772",
          "email": "alexandra@acme.io",
          "name": "Alexandra James",
          "accountType": "ADMIN"
        },
        {
          "uid": "0b02bde0691e9a220f8fdbff93d992a7826c7ce7b0ea33ffc4709c6a2d219a49",
          "email": "jonny@acme.io",
          "name": "Jonathan Maxwell",
          "accountType": "ADMIN"
        },
        {
          "uid": "07673b48d2206dad7a150dd258ea1e049df036356f1730e30304e38ca648b175",
          "email": "matt@acme.io",
          "name": "Matt McDonald",
          "accountType": "DEVELOPER"
        }
      ],
      "invitedUsers": [
        {
          "email": "max@acme.io",
          "accountType": "ADMIN",
          "inviteStatus": "EXPIRED"
        },
        {
          "email": "john@acme.io",
          "accountType": "ADMIN",
          "inviteStatus": "ACTIVE"
        }
      ]
    }
  }
}
```

</details>

## Invite Users

This endpoint will enable you to invite users to your workspace.

**Example Request**

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

```python
import requests
import os

# API credentials
api_endpoint = "<YOUR_API_ENDPOINT>"
api_key = "<YOUR_API_KEY>"
api_secret = "<YOUR_API_SECRET>"

graphql_query = """
mutation InviteUser {
    inviteUser(email: "alice@acme.io", accountType: DEVELOPER) {
        ok
    }
}
  """
  
response = requests.post(api_endpoint, json={"query": graphql_query}, headers={
      "Content-Type": "application/json",
      "X-API-KEY": api_key,
      "X-API-SECRET": api_secret,
  })

print(response.json())
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl -X POST "<YOUR_API_ENDPOINT>" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: <YOUR_API_KEY>" \
     -H "X-API-SECRET: <YOUR_API_SECRET>" \
     -d '{
       "query": "mutation InviteUser($email: String!, $accountType: UserAccountType!) { inviteUser(email: $email, accountType: $accountType) { ok } }",
       "variables": {
         "email": "alice@acme.io",
         "accountType": "DEVELOPER"
       }
     }'
```

{% endtab %}
{% endtabs %}

<details>

<summary><strong>Example response</strong></summary>

```json
{
  "data": {
    "inviteUser": {
      "ok": true
    }
  }
}
```

</details>

## Update User Role

This endpoint will enable you to update the role of a current signed up user in your workspace.

**Example Request**

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

```python
import requests
import os

# API credentials
api_endpoint = "<YOUR_API_ENDPOINT>"
api_key = "<YOUR_API_KEY>"
api_secret = "<YOUR_API_SECRET>"

graphql_query = """
mutation UpdateUserAccountType {
    updateUserAccountType(
        uid: "b6982657f4f7f796945a5c9ca8980e5a2ddf9f94fd7a54fb98b7740fdd54821b"
        accountType: DEVELOPER
    ) {
        ok
    }
}
  """
  
response = requests.post(api_endpoint, json={"query": graphql_query}, headers={
      "Content-Type": "application/json",
      "X-API-KEY": api_key,
      "X-API-SECRET": api_secret,
  })

print(response.json())
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl -X POST "<YOUR_API_ENDPOINT>" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: <YOUR_API_KEY>" \
     -H "X-API-SECRET: <YOUR_API_SECRET>" \
     -d '{
       "query": "mutation UpdateUserAccountType($uid: String!, $accountType: UserAccountType!) { updateUserAccountType(uid: $uid, accountType: $accountType) { ok } }",
       "variables": {
         "uid": "b6982657f4f7f796945a5c9ca8980e5a2ddf9f94fd7a54fb98b7740fdd54821b",
         "accountType": "DEVELOPER"
       }
     }'
```

{% endtab %}
{% endtabs %}

<details>

<summary><strong>Example response</strong></summary>

```json
{
  "data": {
    "updateUserAccountType": {
      "ok": true
    }
  }
}
```

</details>

## Disable User

This endpoint will enable you to disable a user from your workspace.

**Example Request**

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

```python
import requests
import os

# API credentials
api_endpoint = "<YOUR_API_ENDPOINT>"
api_key = "<YOUR_API_KEY>"
api_secret = "<YOUR_API_SECRET>"

graphql_query = """
mutation DisableUser {
    disableUser(uid: "c24d93ba3f6e743bf97a7b5b48c2b7931f6d57d022501cdb2fb983264efc0c29") {
        ok
    }
}
  """
  
response = requests.post(api_endpoint, json={"query": graphql_query}, headers={
      "Content-Type": "application/json",
      "X-API-KEY": api_key,
      "X-API-SECRET": api_secret,
  })

print(response.json())
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl -X POST "<YOUR_API_ENDPOINT>" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: <YOUR_API_KEY>" \
     -H "X-API-SECRET: <YOUR_API_SECRET>" \
     -d '{
       "query": "mutation DisableUser($uid: String!) { disableUser(uid: $uid) { ok } }",
       "variables": {
         "uid": "c24d93ba3f6e743bf97a7b5b48c2b7931f6d57d022501cdb2fb983264efc0c29"
       }
     }'
```

{% endtab %}
{% endtabs %}

<details>

<summary><strong>Example response</strong></summary>

```json
{
  "data": {
    "disableUser": {
      "ok": true
    }
  }
}
```

</details>
