Skip to content

/system/domains

Path: /system/domains
Namespace: system
Resource: domains

Overview

The Domain resource in the system namespace provides system administrators with access to domains across all tenants for system-wide domain management. Domains represent tenants in the multi-tenant system.

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 Domains for complete relationship documentation. System domains use the same Domain model with system-wide access.

Namespace-Specific Relationship Behavior

Cross-Tenant Access
  • Type: System-wide access
  • Description: In the system namespace, relationships are accessible across all tenants. System administrators can access resources from all domains without domain scoping.
  • API Access:
    • Filter: GET /system/domains.json?q[host_id_eq]=1 - All domains, not scoped to current domain
    • Direct: Can access any domain's resources regardless of host
  • Example: Get all domains across all tenants:
    javascript
    const allDomains = await fetch('/system/domains.json', {
      credentials: 'include',
      headers: { 'Accept': 'application/json' }
    }).then(r => r.json());
    // Returns domains from all tenants, not just current host
Unscoped Relationships
  • Type: Unscoped access
  • Description: All relationships are unscoped in the system namespace. Resources can be accessed without tenant restrictions.
  • API Access: Relationships work across tenant boundaries
  • Security: System administrators have full access to all tenant data
  • Related Documentation: Admin Domains - Relationships

Key Features

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

Available Operations

List Domains (GET)

Endpoint: GET /system/domains.json

Query Parameters:

  • q[field_predicate]=value - Ransack query filters for advanced filtering
  • scope=name - Apply named scope (e.g., active, inactive)
  • 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/domains.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"
bash
curl -X GET "https://your-company.erpax.com/system/domains.json?scope=active" \
  -H "Accept: application/json"

JavaScript Example:

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

Response (200 OK):

json
{
  "domains": [
    {
      "id": 1,
      "name": "company1.erpax.com",
      "host_id": null,
      "status": "active",
      "ssl_enabled": true,
      "created_at": "2024-01-10T10:00:00Z"
    },
    {
      "id": 2,
      "name": "company2.erpax.com",
      "host_id": null,
      "status": "active",
      "ssl_enabled": false,
      "created_at": "2024-01-11T10:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total_pages": 1,
    "total_count": 2
  }
}

Show Domain (GET /:id)

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

Request Example:

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

Response (200 OK):

json
{
  "domain": {
    "id": 1,
    "name": "company1.erpax.com",
    "host_id": null,
    "status": "active",
    "ssl_enabled": true,
    "address_id": 1,
    "locale": "en",
    "timezone": "UTC",
    "created_at": "2024-01-10T10:00:00Z",
    "updated_at": "2024-01-15T12:00:00Z"
  }
}

Create Domain (POST)

Endpoint: POST /system/domains.json

Request Example:

bash
curl -X POST "https://your-company.erpax.com/system/domains.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "domain": {
      "name": "newcompany.erpax.com",
      "status": "active",
      "address_id": 2,
      "locale": "en",
      "timezone": "America/New_York"
    }
  }'

Response (201 Created):

json
{
  "domain": {
    "id": 3,
    "name": "newcompany.erpax.com",
    "status": "active",
    "created_at": "2024-01-15T14:30:00Z"
  }
}

Update Domain (PATCH /:id)

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

Request Example:

bash
curl -X PATCH "https://your-company.erpax.com/system/domains/1.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "domain": {
      "status": "inactive"
    }
  }'

Response (200 OK):

json
{
  "domain": {
    "id": 1,
    "status": "inactive",
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Delete Domain (DELETE /:id)

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

Request Example:

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

Response (204 No Content):

(empty response)

Member Actions

Custom actions available on individual domains via API:

Enable SSL

Endpoint: POST /system/domains/:id/enable_ssl

Description: Enable SSL/TLS for a domain.

Request Example:

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

Response (200 OK):

json
{
  "domain": {
    "id": 1,
    "ssl_enabled": true,
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Disable SSL

Endpoint: POST /system/domains/:id/disable_ssl

Description: Disable SSL/TLS for a domain.

Request Example:

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

Response (200 OK):

json
{
  "domain": {
    "id": 1,
    "ssl_enabled": false,
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Scopes

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

Filters

See Admin Domains 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 domains across all tenants
  • Cross-Tenant Management: System administrators can manage domains from any tenant
  • Same Business Rules: Follows the same business rules as admin namespace domains
  • Security: System namespace access is restricted to system administrators

Released under an open source license.