# Managing and Creating Users through API

User management is an essential feature of the Fungies.io platform, enabling developers to handle user accounts programmatically. The user-related endpoints allow you to create new users, retrieve user information, update user details, and manage user inventory. These endpoints are designed to simplify user account management by providing necessary features like listing users, modifying their details, and archiving accounts.

To access these endpoints, authentication via API keys is required, you can go through the "[Getting Started with the API](https://help.fungies.io/for-saas-developers/getting-started-with-the-api)" guide in which you will learn how you can generate the `API-key` and `write-API-key`.

After generating the `API-key` and `write-API key` you can immediately start making requests to the Fungies User management API endpoints.

## GET /users/list (List All Users)

The `/users/list` endpoint is used to retrieve a list of all users on the Fungies.io platform. It allows developers to access details of every user in the system, including filtering options based on user creation dates and email.

> **Note:** This endpoint requires an `API-key` for authentication.

This is a `GET` API endpoint that accepts the following parameters:

* **`email`**: Filters users by their email address.
* **`createdAfter`**: Returns users created after a specified date.
* **`createdBefore`**: Returns users created before a specified date.
* **`page`**: Specifies which page of the user list you want to retrieve.
* **`limit`**: Defines the maximum number of users to return per page.

**Successful Response:**

When the request is successful, you will receive a response like this:

```
{
  "status": "<string>",
  "data": "<string>"
}
```

**Error Response:**

If the request fails, you will receive an error response like this:

```
{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}
```

## POST /users/create (Create a New User)

The `/users/create` endpoint allows developers to create a new user in the system by providing the necessary information such as email, password, and username.

> **Note:** This endpoint requires an `API-key` and `write-API key` (both) for authentication at the same time.

This is a `POST` API endpoint that requires the following in the request body:

* **`email`**: The email address of the new user.
* **`password`**: The password for the user account.
* **`username`**: The username for the user.

**Successful Response:**

When the request is successful, you will receive a response like this:

```
{
  "status": "<string>",
  "data": "<string>"
}
```

**Error Response:**

If the request fails, you will receive an error response like this:

```
{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}
```

## **GET /users/{userId} (Get User by ID)**

The `/users/{userId}` endpoint is used to retrieve details of a specific user by their unique user ID.

> **Note:** This endpoint requires an `API-key` for authentication.

This is a `GET` API endpoint that requires a single parameter:

* **`userId`**: The unique ID of the user you want to retrieve.

**Successful Response:**

When the request is successful, you will receive a response like this:

```
{
  "status": "<string>",
  "data": "<string>"
}
```

**Error Response:**

If the request fails, you will receive an error response like this:

```
{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}
```

## **PATCH /users/{userId}/update (Update User Details)**

The `/users/{userId}/update` endpoint allows developers to update a user's details, such as their email or username.

> **Note:** This endpoint requires an `API-key` and `write-API key` (both) for authentication at the same time.

This is a `PATCH` API endpoint that requires a single parameter and request body:

* `userId`: The unique ID of the user to update.
* **Request Body**:

  `email`: The updated email address for the user.

  `username`: The updated username for the user.

**Successful Response:**

When the request is successful, you will receive a response like this:

```
{
  "status": "<string>",
  "data": "<string>"
}
```

**Error Response:**

If the request fails, you will receive an error response like this:

```
{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}
```

## **PATCH /users/{userId}/archive (Archive User)**

The `/users/{userId}/archive` endpoint is used to archive a specific user account, effectively deactivating it while preserving its data.

> **Note:** This endpoint requires an `API-key` and `write-API key` (both) for authentication at the same time.

This is a `PATCH` API endpoint that requires a single parameter and request body:

* **`userId`**: The unique ID of the user to archive.
* **`Request`` ``Body`**: An object specifying any additional data needed for archiving the user.

**Successful Response:**

When the request is successful, you will receive a response like this:

```
{
  "status": "<string>",
  "data": "<string>"
}
```

**Error Response:**

If the request fails, you will receive an error response like this:

```
{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}
```

## **GET /users/{userId}/inventory (Get User Inventory)**

The `/users/{userId}/inventory` endpoint retrieves the inventory of digital products or subscriptions associated with a specific user.

> **Note:** This endpoint requires an `API-key` for authentication.

This is a `GET` API endpoint that requires the following parameters:

* **`userId`**: The unique ID of the user whose inventory you want to retrieve.
* **`productType`**: Filters inventory by the type of product. Available options-

  `DigitalDownload` ,`Game` ,`GiftCard` ,`SoftwareKey` ,`VirtualCurrency` ,`VirtualItem` ,`Subscription`.
* **`expiresAfter`**: Filters items that expire after a specific date.

**Successful Response:**

When the request is successful, you will receive a response like this:

```
{
  "status": "<string>",
  "data": "<string>"
}
```

**Error Response:**

If the request fails, you will receive an error response like this:

```
{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}
```


---

# 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://help.fungies.io/for-saas-developers/managing-and-creating-users-through-api.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.
