Skip to content

/system/users

Path: /system/users
Namespace: system
Resource: users

Overview

The User resource in the system namespace provides system administrators with access to user accounts across all domains for system-wide user management.

Key Difference from Admin: The system namespace provides cross-tenant access for system administrators, while the admin namespace is scoped to a single domain.

Relationships

See Admin Users for complete relationship documentation. System users use the same User model with system-wide access.

Key Features

  • System-Wide Access: Access to all users across all tenants
  • Cross-Tenant Management: Manage users from all tenants
  • System Administration: Full administrative control over all users
  • Same User Model: Uses the same User model as admin namespace

Available Operations

List Users (GET)

Endpoint: GET /system/users.json

Query Parameters:

  • q[field_predicate]=value - Ransack query filters for advanced filtering
  • scope=name - Apply named scope (e.g., active, locked)
  • page=N - Page number for pagination
  • per_page=N - Items per page (default: 25)

Request Examples:

bash
curl -X GET "https://your-company.erpax.com/system/users.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"
bash
curl -X GET "https://your-company.erpax.com/system/users.json?scope=active" \
  -H "Accept: application/json"

JavaScript Example:

javascript
const response = await fetch('/system/users.json', {
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});
const data = await response.json();

Response (200 OK):

json
{
  "users": [
    {
      "id": 1,
      "email": "[email protected]",
      "name": "Admin User",
      "role": "admin",
      "host_id": 1,
      "locked": false,
      "created_at": "2024-01-10T10:00:00Z"
    },
    {
      "id": 2,
      "email": "[email protected]",
      "name": "Regular User",
      "role": "manager",
      "host_id": 2,
      "locked": false,
      "created_at": "2024-01-11T10:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total_pages": 2,
    "total_count": 45
  }
}

Show User (GET /:id)

Endpoint: GET /system/users/:id.json

Request Example:

bash
curl -X GET "https://your-company.erpax.com/system/users/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

Response (200 OK):

json
{
  "user": {
    "id": 1,
    "email": "[email protected]",
    "name": "Admin User",
    "role": "admin",
    "host_id": 1,
    "address_id": 1,
    "locked": false,
    "last_sign_in_at": "2024-01-15T10:00:00Z",
    "created_at": "2024-01-10T10:00:00Z"
  }
}

Create User (POST)

Endpoint: POST /system/users.json

Request Example:

bash
curl -X POST "https://your-company.erpax.com/system/users.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "user": {
      "email": "[email protected]",
      "password": "secure_password",
      "password_confirmation": "secure_password",
      "name": "New User",
      "role": "manager",
      "host_id": 1
    }
  }'

Response (201 Created):

json
{
  "user": {
    "id": 3,
    "email": "[email protected]",
    "name": "New User",
    "role": "manager",
    "created_at": "2024-01-15T14:30:00Z"
  }
}

Update User (PATCH /:id)

Endpoint: PATCH /system/users/:id.json

Request Example:

bash
curl -X PATCH "https://your-company.erpax.com/system/users/1.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "user": {
      "role": "accountant"
    }
  }'

Response (200 OK):

json
{
  "user": {
    "id": 1,
    "role": "accountant",
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Delete User (DELETE /:id)

Endpoint: DELETE /system/users/:id.json

Request Example:

bash
curl -X DELETE "https://your-company.erpax.com/system/users/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

Response (204 No Content):

(empty response)

Scopes

See Admin Users for complete scope documentation. System namespace supports the same scopes as admin namespace, but across all tenants.

Filters

See Admin Users for complete filter documentation. System namespace supports the same filters as admin namespace, but across all tenants.

Business Rules

  • System-Wide Access: System namespace provides access to all users across all tenants
  • Cross-Tenant Management: System administrators can manage users from any tenant
  • Same Business Rules: Follows the same business rules as admin namespace users
  • Security: System namespace access is restricted to system administrators

Released under an open source license.