The ActivitySubscriptions API provides endpoints to retrieve Activity entities from the Subscriptions and Activity Feed Framework.

This API requires activation of the Subscriptions and Activity Feed Framework (com.snc.activity_subscriptions) plugin. Activate the Customer Central (com.sn_csm_customer_central) plugin to seed configuration in all required tables. For more information on customer central configuration settings, see Configure customer central.

ActivitySubscriptions - GET /now/actsub/activities

Retrieves activity records from the Subscriptions and Activity Feed Framework.

No role is required to access this endpoint, but data returned is limited by user access settings.

URL format

Versioned URL: /api/now/{api_version}/actsub/activities

Default URL: /api/now/actsub/activities

Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.

Supported request parameters

Table 1. Path parameters
Name Description
api_version Optional. Version of the endpoint to access. For example, v1 or v2. Only specify this value to use an endpoint version other than the latest.

Data type: String

Table 3. Request body parameters (XML or JSON)
Name Description
None

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 4. Request headers
Header Description
Accept Data format of the response body. Supported types: application/json or application/xml.

Default: application/json

Table 5. Response headers
Header Description
None

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.

Response body parameters (JSON or XML)

Example: cURL request

Request the second and third activity records for a specific Contact, limiting to data from 2020:

curl "https://instance.servicenow.com/api/now/actsub/activities\
?context=4a6a035a73d30010e37d71ef64f6a714\
&context_instance=ddce70866f9331003b3c498f5d3ee417\
&stFrom=1&last=3\
&start_date=2020-01-01%2000:00:00&end_date=2020-12-31%2023:59:59" \
--request GET \
--header "Accept: application/json" \
--user "username:password"

The response body includes the two requested activity records for the specified Contact:

{
  "result": {
    "hasMoreRecords": true,
    "activities": [
      {
        "subobject_table_name": "sn_customerservice_case",
        "source_table_name": "sn_customerservice_case",
        "content_fields": [
          {
            "value": "Test",
            "show_label": "false",
            "type": "string",
            "label": "Short description",
            "display_as_timeago": "false",
            "deeplink_to_subobject": "false"
          }
        ],
        "created": "2020-05-29 18:42:16",
        "activity_type_id": "baf0aace73530010e37d71ef64f6a748",
        "title": "Lamar Wilson created case",
        "subobject_sys_id": "1687360e8d819010f87705a074e52ac9",
        "icon": "clipboard_outline",
        "sys_id": "1687360e8d819010f87705a074e52ac9",
        "subheader_fields": [
          {
            "value": "CS0001007",
            "show_label": "false",
            "type": "string",
            "label": "Number",
            "display_as_timeago": "false",
            "deeplink_to_subobject": "true"
          },
          {
            "value": "2020-05-29 18:42:16",
            "show_label": "false",
            "type": "glide_date_time",
            "label": "Created",
            "display_as_timeago": "true",
            "deeplink_to_subobject": "false"
          },
          {
            "value": "",
            "show_label": "false",
            "type": "reference",
            "label": "Assigned to",
            "display_as_timeago": "false",
            "deeplink_to_subobject": "false"
          },
          {
            "value": "Lamar Wilson",
            "show_label": "false",
            "type": "reference",
            "label": "Contact",
            "display_as_timeago": "false",
            "deeplink_to_subobject": "false"
          }
        ]
      },
      {
        "subobject_table_name": "kb_knowledge",
        "source_table_name": "kb_use",
        "content_fields": [
          {
            "value": "How to Set Up a Broadband Router",
            "show_label": "false",
            "type": "string",
            "label": "Short description",
            "display_as_timeago": "false",
            "deeplink_to_subobject": "false"
          }
        ],
        "created": "2020-05-26 10:00:00",
        "activity_type_id": "4a8c329273d30010e37d71ef64f6a7c1",
        "title": "Lamar Wilson viewed knowledge article",
        "subobject_sys_id": "f855a0a89f011200550bf7b6077fcf4f",
        "icon": "document_outline",
        "sys_id": "b929dd5873941010e37d71ef64f6a719",
        "subheader_fields": [
          {
            "value": "KB0000110",
            "show_label": "false",
            "type": "string",
            "label": "Number",
            "display_as_timeago": "false",
            "deeplink_to_subobject": "true"
          },
          {
            "value": "2020-05-26 10:00:00",
            "show_label": "false",
            "type": "glide_date_time",
            "label": "Created",
            "display_as_timeago": "true",
            "deeplink_to_subobject": "false"
          }
        ]
      }
    ]
  }
}

ActivitySubscriptions - GET /now/actsub/facets/{activity_context}/{context_instance}

Retrieves facets configured for an activity context from the Subscriptions and Activity Feed Framework. Displays activity counts and data for each facet as determined by activity type, group, and context settings.

Users must have the actsub_user or admin role to access this endpoint. Data returned is limited by user access settings.

For more details on activity context facets, see Create facets for activity contexts.

URL format

Versioned URL: /api/now/{api_version}/actsub/facets/{activity_context}/{context_instance}

Default URL: /api/now/actsub/facets/{activity_context}/{context_instance}

Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.

Supported request parameters

Table 7. Path parameters
Name Description
activity_context Sys_id of an activity context.

Predefined activity contexts include Consumer and Contact. Navigate to Customer Central > Customer Activity > Activity Contexts to view the full list of activity contexts defined for your instance.

Data type: String

Table: Activity Contexts [sn_actsub_activity_context]

api_version Optional. Version of the endpoint to access. For example, v1 or v2. Only specify this value to use an endpoint version other than the latest.

Data type: String

context_instance Sys_id of an instance of the specified activity context, representing the initiator of the activities you want to retrieve facets for.

As an example, if you set activity_context to the sys_id of the Contact activity context, you should set this parameter to the sys_id of the Contact [customer_contact] record for the contact whose activity facets you want to retrieve.

Data type: String

Table: In the context table specified for the activity context record in the Activity Contexts [sn_actsub_activity_context] table.

Table 9. Request body parameters (XML or JSON)
Name Description
None

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 10. Request headers
Header Description
Accept Data format of the response body. Supported types: application/json or application/xml.

Default: application/json

Table 11. Response headers
Header Description
None

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.

Response body parameters (JSON or XML)

Example: cURL request

Retrieve Chat, Phone, and Knowledge articles facets and activity counts for a Contact:

curl "https://instance.servicenow.com/api/now/actsub/facets/4a6a035a73d30010e37d71ef64f6a714/ddce70866f9331003b3c498f5d3ee417\
?get_activity_count=true\
&facets=510d7e2e73570010e37d71ef64f6a70d,bc9bfaaa73570010e37d71ef64f6a771,c72d7e2e73570010e37d71ef64f6a7b8" \
--request GET \
--header "Accept: application/json" \
--user "username:password"

The response body includes the three requested facets as children of their facet groups, with activity counts displayed:

{
  "result": [
    {
      "is_dynamic": false,
      "name": "Interactions",
      "activity_count": 4.0,
      "facets": [
        "510d7e2e73570010e37d71ef64f6a70d",
        "bc9bfaaa73570010e37d71ef64f6a771"
      ],
      "children": [
        {
          "facet": "510d7e2e73570010e37d71ef64f6a70d",
          "icon": "chat_outline",
          "activity_count": 2.0,
          "title": "Chat"
        },
        {
          "facet": "bc9bfaaa73570010e37d71ef64f6a771",
          "icon": "phone_outline",
          "activity_count": 2.0,
          "title": "Phone"
        }
      ]
    },
    {
      "is_dynamic": false,
      "name": "Portal Activity",
      "activity_count": 5.0,
      "facets": [
        "c72d7e2e73570010e37d71ef64f6a7b8"
      ],
      "children": [
        {
          "facet": "c72d7e2e73570010e37d71ef64f6a7b8",
          "icon": "document_outline",
          "activity_count": 5.0,
          "title": "Knowledge articles"
        }
      ]
    }
  ]
}