/impersonate - Start impersonation (permission-based access)

Add MCP server to your AI tool

Allow AI tools and LLMs to interact with the API documentation portal through MCP.

MCP server URL

https://api.my.nethesis.it/mcp

Standard setup for AI tools providing an mcp.json file

mcp.json
{
  "my.nethesis.it MCP server": {
    "url": "https://api.my.nethesis.it/mcp"
  }
}

Close
POST /impersonate

Allows users with the impersonate:users permission (Staff and Owner roles, Owner organization only) to impersonate another active user, without the target's consent. An Owner-role account is never a target. The token expires after the IMPERSONATION_SESSION_DURATION of the backend (default 1 hour), and every session is audited.

application/json

Body Required

  • user_id string Required

    Logto ID of the user to impersonate

Responses

  • 200 application/json

    Impersonation started successfully

    Hide response attributes Show response attributes object
    • code integer
    • message string
    • data object
      Hide data attributes Show data attributes object
      • token string

        Impersonation JWT token with custom duration

      • expires_in integer

        Token expiration time in seconds (IMPERSONATION_SESSION_DURATION)

      • expires_at string(date-time)

        When the impersonation token expires

      • session_id string

        Unique session ID for audit tracking

      • is_impersonating boolean

        Flag indicating impersonation is active

      • impersonated_user object
        Hide impersonated_user attributes Show impersonated_user attributes object
        • id string

          User account ID

        • logto_id string | null

          Logto user ID

        • username string

          Username

        • email string(email)

          Email address

        • name string

          Full name

        • phone string | null

          Phone number

        • organization object

          Organization information (null when not assigned to an organization)

          Hide organization attributes Show organization attributes object
          • id string

            Local database organization ID

          • logto_id string

            Logto organization ID

          • name string

            Organization name

          • type string

            Organization type in the business hierarchy

            Values are owner, distributor, reseller, or customer.

        • roles array[object]

          User roles with names

          Hide roles attributes Show roles attributes object
          • id string

            Role ID

          • name string

            Role name

        • custom_data object

          Custom user data

          Additional properties are allowed.

        • created_at string(date-time)

          Account creation timestamp

        • updated_at string(date-time)

          Last update timestamp

        • logto_synced_at string(date-time) | null

          Last Logto synchronization timestamp

        • latest_login_at string(date-time) | null

          Timestamp of the last successful login via /auth/exchange endpoint. NULL means user has never logged in.

        • deleted_at string(date-time) | null

          Soft delete timestamp (null if not deleted)

        • suspended_at string(date-time) | null

          Suspension timestamp (null if not suspended)

        • created_by object

          Point-in-time snapshot of the user who created this user (omitted on accounts created before the snapshot was introduced). Display/filter only - RBAC is by organization.

          Hide created_by attributes Show created_by attributes object
          • user_id string

            Logto ID of the user who created the organization

          • username string

            Username of the creator

          • name string

            Full name of the creator

          • email string

            Email of the creator

          • organization_id string

            Organization ID the creator belongs to

          • organization_name string

            Organization name the creator belongs to

          • organization_type string

            Current level of the creator's organization, resolved on every read (never stored), so a promoted organization is reported at its current level. The Owner organization is reported as "owner", the same value the organization_type of users and systems carries for it, so a client draws it with the same icon. Omitted only for a deleted organization, which has no level to assert and no detail page to link to.

            Values are distributor, reseller, customer, or owner.

          • on_behalf_of boolean

            True when the organization was attributed to a different organization via created_by_organization_id (the user acted on behalf of organization_name rather than belonging to it). Omitted when false.

        • can_be_impersonated boolean

          Whether the caller can impersonate this user (only shown for users with impersonation permissions): an active user other than the caller, without the Owner user role

        • has_avatar boolean

          Whether the user has a profile picture stored. False means GET /public/users/{logto_id}/avatar has nothing to serve, so clients can render initials without issuing the request.

      • impersonator object
        Hide impersonator attributes Show impersonator attributes object
        • id string

          User account ID

        • logto_id string | null

          Logto user ID

        • username string

          Username

        • email string(email)

          Email address

        • name string

          Full name

        • phone string | null

          Phone number

        • organization object

          Organization information (null when not assigned to an organization)

          Hide organization attributes Show organization attributes object
          • id string

            Local database organization ID

          • logto_id string

            Logto organization ID

          • name string

            Organization name

          • type string

            Organization type in the business hierarchy

            Values are owner, distributor, reseller, or customer.

        • roles array[object]

          User roles with names

          Hide roles attributes Show roles attributes object
          • id string

            Role ID

          • name string

            Role name

        • custom_data object

          Custom user data

          Additional properties are allowed.

        • created_at string(date-time)

          Account creation timestamp

        • updated_at string(date-time)

          Last update timestamp

        • logto_synced_at string(date-time) | null

          Last Logto synchronization timestamp

        • latest_login_at string(date-time) | null

          Timestamp of the last successful login via /auth/exchange endpoint. NULL means user has never logged in.

        • deleted_at string(date-time) | null

          Soft delete timestamp (null if not deleted)

        • suspended_at string(date-time) | null

          Suspension timestamp (null if not suspended)

        • created_by object

          Point-in-time snapshot of the user who created this user (omitted on accounts created before the snapshot was introduced). Display/filter only - RBAC is by organization.

          Hide created_by attributes Show created_by attributes object
          • user_id string

            Logto ID of the user who created the organization

          • username string

            Username of the creator

          • name string

            Full name of the creator

          • email string

            Email of the creator

          • organization_id string

            Organization ID the creator belongs to

          • organization_name string

            Organization name the creator belongs to

          • organization_type string

            Current level of the creator's organization, resolved on every read (never stored), so a promoted organization is reported at its current level. The Owner organization is reported as "owner", the same value the organization_type of users and systems carries for it, so a client draws it with the same icon. Omitted only for a deleted organization, which has no level to assert and no detail page to link to.

            Values are distributor, reseller, customer, or owner.

          • on_behalf_of boolean

            True when the organization was attributed to a different organization via created_by_organization_id (the user acted on behalf of organization_name rather than belonging to it). Omitted when false.

        • can_be_impersonated boolean

          Whether the caller can impersonate this user (only shown for users with impersonation permissions): an active user other than the caller, without the Owner user role

        • has_avatar boolean

          Whether the user has a profile picture stored. False means GET /public/users/{logto_id}/avatar has nothing to serve, so clients can render initials without issuing the request.

  • 400 application/json

    Bad request (cannot impersonate yourself, user not found, etc.)

    Hide response attributes Show response attributes object
    • code integer

      HTTP error code

    • message string

      Error message

    • data object
      Hide data attributes Show data attributes object
      • type string

        Type of error

        Values are validation_error or external_api_error.

      • errors array[object]
        Hide errors attributes Show errors attributes object
        • key string

          Field name that failed validation

        • message string

          Error code or message

        • value string

          Value that failed validation

      • details

        Additional error details

  • 403 application/json

    Forbidden (insufficient permissions for impersonation, or already impersonating)

    Hide response attributes Show response attributes object
    • code integer

      HTTP error code

    • message string

      Error message

    • data object
      Hide data attributes Show data attributes object
      • type string

        Type of error

        Values are validation_error or external_api_error.

      • errors array[object]
        Hide errors attributes Show errors attributes object
        • key string

          Field name that failed validation

        • message string

          Error code or message

        • value string

          Value that failed validation

      • details

        Additional error details

  • 401 application/json

    Unauthorized - invalid or missing token

    Hide response attributes Show response attributes object
    • code integer
    • message string
    • data object | null
POST /impersonate
curl \
 --request POST 'https://my.nethesis.it/backend/api/impersonate' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{
  "user_id": "jf584cz36kce"
}'
Request examples
{
  "user_id": "jf584cz36kce"
}
Response examples (200)
{
  "code": 200,
  "message": "impersonation started successfully",
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expires_in": 3600,
    "expires_at": "2025-09-04T14:30:00Z",
    "session_id": "session-uuid-here",
    "is_impersonating": true,
    "impersonated_user": {
      "id": "usr_123456789",
      "logto_id": "user_abc123def456",
      "username": "john.doe",
      "email": "john@example.com",
      "name": "John Doe",
      "phone": "+39 333 123456",
      "organization": {
        "id": "12345678-1234-1234-1234-123456789abc",
        "logto_id": "org_123456789",
        "name": "ACME Corp",
        "type": "customer"
      },
      "roles": [
        {
          "id": "rol_admin_123",
          "name": "Admin"
        }
      ],
      "custom_data": {
        "department": "IT",
        "position": "Senior Developer"
      },
      "created_at": "2025-06-20T14:30:00Z",
      "updated_at": "2025-06-21T10:45:00Z",
      "logto_synced_at": "2025-06-21T10:45:00Z",
      "latest_login_at": "2025-06-21T15:30:45Z",
      "deleted_at": "2026-05-04T09:42:00Z",
      "suspended_at": "2026-05-04T09:42:00Z",
      "created_by": {
        "user_id": "aa15fcvgzw1y",
        "username": "owner",
        "name": "Nethesis Owner",
        "email": "owner@nethesis.it",
        "organization_id": "2wl3iixbc8ua",
        "organization_name": "Owner",
        "organization_type": "owner",
        "on_behalf_of": true
      },
      "can_be_impersonated": true,
      "has_avatar": false
    },
    "impersonator": {
      "id": "usr_123456789",
      "logto_id": "user_abc123def456",
      "username": "john.doe",
      "email": "john@example.com",
      "name": "John Doe",
      "phone": "+39 333 123456",
      "organization": {
        "id": "12345678-1234-1234-1234-123456789abc",
        "logto_id": "org_123456789",
        "name": "ACME Corp",
        "type": "customer"
      },
      "roles": [
        {
          "id": "rol_admin_123",
          "name": "Admin"
        }
      ],
      "custom_data": {
        "department": "IT",
        "position": "Senior Developer"
      },
      "created_at": "2025-06-20T14:30:00Z",
      "updated_at": "2025-06-21T10:45:00Z",
      "logto_synced_at": "2025-06-21T10:45:00Z",
      "latest_login_at": "2025-06-21T15:30:45Z",
      "deleted_at": "2026-05-04T09:42:00Z",
      "suspended_at": "2026-05-04T09:42:00Z",
      "created_by": {
        "user_id": "aa15fcvgzw1y",
        "username": "owner",
        "name": "Nethesis Owner",
        "email": "owner@nethesis.it",
        "organization_id": "2wl3iixbc8ua",
        "organization_name": "Owner",
        "organization_type": "owner",
        "on_behalf_of": true
      },
      "can_be_impersonated": true,
      "has_avatar": false
    }
  }
}
Response examples (400)
{
  "code": 400,
  "message": "Cannot impersonate yourself"
}
{
  "code": 400,
  "message": "Target user not found or inaccessible"
}
Response examples (403)
{
  "code": 403,
  "message": "Insufficient permissions to impersonate users"
}
{
  "code": 403,
  "message": "Cannot impersonate while already impersonating another user. Exit current impersonation first."
}
Response examples (401)
{
  "code": 401,
  "message": "invalid token",
  "data": {}
}