Administration (GQL)

Logs

๐Ÿ“˜

API traffic logs

For logs related to API request/responses, see API Traffic Logs.

Obtain user login audit logs

This query obtains the login history for a user and includes details such as the login time, user agent, and location of the user login.

Note that once a user has logged in and receives a browser cookie, that cookie is used until it has expired. (Contact your Rapid representative if you would like to change the maximum age of cookies related to your Enterprise Hub.) Logins using a browser cookie are not listed in this audit log.

Specify the user's userId in the variables and optionally specify a from value. The results are returned in descending order. A non-zero value of from means that logins below the number are not returned. For example, if a user has 20 login entries and the from value is set to 15, only the most recent 5 logins will be returned.

query AuditLogin($userId: String, $from: Int) {
  auditLogin(userId: $userId, from: $from) {
    total
    audits {
      time
      actorRole
      action
      eventName
      user {
        id
        name
        type
      }
      params {
        input
      }
      attributes {
        userAgent
      }
      geo {
        country
        city
        region
        timezone
        ll
      }
    }
  }
}
{
  "userId": "5713300",
  "from": 0
}

Obtain environment audit logs

This query is used to obtain logs of actions that Environment Admin users have made in the Admin Panel. These logs are also available in the Audit Trails tab of the Admin Panel.

The value of where.query is a text-based search string. Leaving this empty (as in the example below) returns all entries. Additionally, this query uses Pagination and order by arguments.

query getAdminAuditLogs ($pagination: PaginationArgs, $orderBy: AdminAuditLogSortablesInput, $where: AdminAuditLogInput) {
  adminAuditLogs(pagination: $pagination, orderBy: $orderBy, where: $where)
 {
    edges {
      node {
        id
        action
        eventName
            auditText
        statusCode
        highlight
        createdAt
      }
      cursor
    }
    nodes {
      id
      action
      eventName
      auditText
      statusCode
      highlight
      createdAt
    }
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
  }
}
{
  "pagination": {
      "after": "",
      "first": 10
    },
  "orderBy": { "sortingFields": [{
        "fieldName": "CREATED_AT",
        "order": "DESC"
  }]},
  "where": {
    "query": ""
  }
}

Obtain event (webhook) logs

This query obtains event logs if Events / Webhooks are configured on your Enterprise Hub. The returned data is similar to what is shown in the Events Log tab.

query getEventLogs {
  eventLogs(
  	pagination: {
      first: 20
    },
    orderBy: {
      sortingFields: [{
        fieldName: CREATED_AT,
        order: ASC
        }]
    },
    where: {
      query: "Update"
    }
  ) {
    edges {
      node {
        id
        url
        eventType
    	    eventText
        eventData
        statusCode
        highlight
        createdAt
      }
      cursor
    }
    nodes {
        id
        url
        eventType
    	    eventText
        eventData
        statusCode
        highlight
        createdAt
    }
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
  }
}

Events (webhooks)

Obtain the current event (webhook) configuration

This obtains the information displayed on the Events > Event configuration tab in the Admin Panel. See Events / Webhooks.

query getEventConfig {
  eventConfig {
    id,
    isActive,
    secret,
    urls {
      id
      url
    },
    types{
      id
      name
      label
      example
    } 
  }
}

Add or update the event (webhook) configuration

This mutation can be used to enable or disable event triggers, or to generate a new secret key. This can also be done manually on the Events > Event configuration tab in the Admin Panel. See Events / Webhooks. Modifying callback URLs done using createEventUrl, updateEventUrl or deleteEventUrl, as described below.

"Upsert" is a combination of "update" and "insert".

In the variables, use isActive to enable or disable event triggers. Use shouldGenerateSecretto create a new secret that can be checked by the external system to verify that the request is authentic.

mutation upsertEventConfig($updateInput: EventConfigUpdateInput!) {
  upsertEventConfig(input: $updateInput) {
    secret
    __typename
  }
}
{
  "updateInput": {
    "isActive": false,
    "shouldGenerateSecret": true
  }
}

Add an event (webhook) callback URL

This mutation adds a callback URL to the event configuration. This can also be done manually on the Events > Event configuration tab in the Admin Panel. See Events / Webhooks.

mutation createEventUrl($createDto: EventUrlCreateInput!) {
  createEventUrl(createDto: $createDto) {
    id
    url
  }
}
{
  "createDto": {
    "url": "https://example.com/webhooks"
  }
}

Update an event (webhook) callback URL

This mutation updates a callback URL in the event configuration. This can also be done manually on the Events > Event configuration tab in the Admin Panel. See Events / Webhooks.

In the variables, the id of the existing callback URL can be obtained using query.eventConfig as shown above.

mutation updateEventUrl($updateDto: EventUrlUpdateInput!, $id: ID!) {
  updateEventUrl(updateDto: $updateDto, id: $id) {
    id
    url
  }
}
{
  "id": "537",
  "updateDto": {
    "url": "https://example.com/webhooks2"
  }
}

Delete an event (webhook) callback URL

This mutation deletes a callback URL in the event configuration. This can also be done manually on the Events > Event configuration tab in the Admin Panel. See Events / Webhooks.

In the variables, the id of the existing callback URL can be obtained using query.eventConfig as shown above.

mutation deleteEventUrl($id: ID!) {
  deleteEventUrl(id: $id)
}
{
  "id": "537"
}