Verify API is associated with a live agent

  • Release version: Australia
  • Updated March 12, 2026
  • 1 minute to read
  • Call the AgentNowHandler.hasAgent API to determine if the CI is associated with a live agent. The API gets a sys_id of the CI and returns a true/false result.

    The hasAgent() method takes a sys_id of the CI as a string parameter and returns true when the CI fulfills one of the following conditions:

    • The CI is sn_agent_cmdb_ci_agent and this agent is alive.
    • The CI is a host (extends cmdb_ci_hardware) and is associated with a live agent.
    • The CI is an application (extends cmdb_ci_appl) and has a runs-on relation to a host associated with a live agent.

    For example:

    var agentNow = new sn_agent.AgentNowHandler(); 
    gs.info(‘Agent assocation with CI? ‘ + 
    agentNow.hasAgent(‘158279505372b30034b8ddeeff7b1270’); // sys_id of agent