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

# Clients

API for managing Clients (Sub-User Accounts)

## List Clients

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/clients/`

This endpoint **returns** a list of `clients`

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

```javascript
{
  "total": 1,
  "page": 1,
  "records": [
    {
      "id": 1234,
      "firstname": "Amelia",
      "lastname": "Earhart",
      "email": "user@magloft.com",
      "created_at": "2018-01-24 10:55:35",
      "updated_at": "2018-01-24 10:55:35",
      "last_seen_at": "2018-01-24 10:55:35",
      "sign_in_count": 6,
      "gravatar_url": "//secure.gravatar.com/avatar/123456789987654321",
      "roles": [
        {
          "id": 1234,
          "user_id": 1211,
          "publication_id": 123,
          "access_level": "author",
          "created_at": "2018-01-24 10:55:35",
          "updated_at": "2018-01-24 10:55:35"
        }
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Retrieve paginated list of clients

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/clients/page/:page`

This endpoint **returns** a page list of all `clients`

#### Path Parameters

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| page | Integer | The page number to list |

#### Query Parameters

| Name            | Type    | Description                              |
| --------------- | ------- | ---------------------------------------- |
| per\_page       | Integer | Number of items to show per page         |
| order\_by       | Symbol  | Field to sort results by                 |
| order\_dir      | Symbol  | Direction (asc, desc) to sort results by |
| filter          | String  | Text filter to search results by         |
| publication\_id | Integer | Filter by publications ID                |

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

```javascript
{
  "total": 1,
  "page": 1,
  "records": [
    {
      "id": 1234,
      "firstname": "Amelia",
      "lastname": "Earhart",
      "email": "user@magloft.com",
      "created_at": "2018-01-24 10:55:35",
      "updated_at": "2018-01-24 10:55:35",
      "last_seen_at": "2018-01-24 10:55:35",
      "sign_in_count": 6,
      "gravatar_url": "//secure.gravatar.com/avatar/123456789987654321",
      "roles": [
        {
          "id": 1234,
          "user_id": 1211,
          "publication_id": 123,
          "access_level": "author",
          "created_at": "2018-01-24 10:55:35",
          "updated_at": "2018-01-24 10:55:35"
        }
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## GET Client

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/clients/:id`

This endpoint **returns** a specific `client` by `id`

#### Path Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| id   | Integer | Client ID   |

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

```javascript
{
  "id": 1234,
  "firstname": "Amelia",
  "lastname": "Earhart",
  "email": "user@magloft.com",
  "created_at": "2018-01-24 10:55:35",
  "updated_at": "2018-01-24 10:55:35",
  "last_seen_at": "2018-01-24 10:55:35",
  "sign_in_count": 6,
  "gravatar_url": "//secure.gravatar.com/avatar/123456789987654321",
  "roles": [
    {
      "id": 1234,
      "user_id": 1211,
      "publication_id": 123,
      "access_level": "author",
      "created_at": "2018-01-24 10:55:35",
      "updated_at": "2018-01-24 10:55:35"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Create new client

<mark style="color:green;">`POST`</mark> `https://www.magloft.com/api/portal/v1/clients/`

This endpoint **creates** a new `client` and **returns** the saved `client`

#### Request Body

| Name      | Type   | Description          |
| --------- | ------ | -------------------- |
| email     | String | Client email address |
| firstname | String | Client Firstname     |
| lastname  | String | Client Lastname      |
| password  | String | Client Password      |

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

```javascript
{
  "id": 1234,
  "firstname": "Amelia",
  "lastname": "Earhart",
  "email": "user@magloft.com",
  "created_at": "2018-01-24 10:55:35",
  "updated_at": "2018-01-24 10:55:35",
  "last_seen_at": "2018-01-24 10:55:35",
  "sign_in_count": 6,
  "gravatar_url": "//secure.gravatar.com/avatar/123456789987654321",
  "roles": [
    {
      "id": 1234,
      "user_id": 1211,
      "publication_id": 123,
      "access_level": "author",
      "created_at": "2018-01-24 10:55:35",
      "updated_at": "2018-01-24 10:55:35"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Update Client

<mark style="color:orange;">`PUT`</mark> `https://www.magloft.com/api/portal/v1/clients/:id`

This endpoint **updates** a specific `client` by `id` and **returns** the updated `client`

#### Path Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| id   | Integer | Client ID   |

#### Request Body

| Name                   | Type   | Description                  |
| ---------------------- | ------ | ---------------------------- |
| firstname              | String | Client Firstname             |
| lastname               | String | Client Lastname              |
| password               | String | Client Password              |
| password\_confirmation | String | Client Password Confirmation |

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

```javascript
null
```

{% endtab %}
{% endtabs %}

## Delete Client

<mark style="color:red;">`DELETE`</mark> `https://www.magloft.com/api/portal/v1/clients/:id`

This endpoint **deletes** a specific `client` by `id` and **returns** an `empty response` with status `204`

#### Path Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| id   | Integer | Client ID   |

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

```javascript
null
```

{% endtab %}
{% endtabs %}

## Become Client

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/clients/:id/become`

This endpoint **logs in** as a `client` by `id` and **returns** the new `client` user

#### Path Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| id   | Integer | Client ID   |

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

```javascript
null
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://api.docs.magloft.com/portal-api/clients.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.
