Add or list Browser apps via API (v2)

Here are examples of how to use the New Relic REST API (v2) to add apps to New Relic Browser or to obtain a list of your Browser apps for a specific API key. This provides a method to manage deployment outside of the New Relic Browser user interface. This is useful, for example, with larger organizations deploying multiple apps, or for integration partners that are facilitating New Relic account creation and Browser monitoring deployment.

To accomplish the same tasks from the API Explorer, use your API key and go to:

Adding Browser apps

To add an app to New Relic Browser, replace ${APIKEY} with your New Relic API key, and replace ${STRING} with the Browser app's name.

curl -X POST 'https://api.newrelic.com/v2/browser_applications.json' \
     -H "X-Api-Key:${APIKEY}" -i 
     -H 'Content-Type: application/json' \
     -d \
'{
  "browser_application": {
    "name": ${STRING}
  }
}'

The API returns an array of data where the element is a Browser application and the data associated with it:

{
  "browser_application": {
    "id": "integer",
    "name": "string",
    "browser_monitoring_key": "string",
    "loader_script": "string"
  }
API (v2) output Description
Browser app id (integer) This is the unique identification code for each app in New Relic Browser.
App name (string) This is the Browser app's name as it appears in the New Relic Browser user interface.
The browser_monitoring_key (string) This a unique key that is linked to (but is not the same as) the account license key. It is used to indicate the account in New Relic Browser where data will be reported. It cannot be used to determine your New Relic account's license key.
Browser monitoring loader_script (string)

The returned loader script is a JSON-encoded JavaScript snippet that is configured with the New Relic Browser monitoring license key and application ID. The rest of the script is static and is approximately 10k in size.

The loader script must be inserted into the user’s HTML pages correctly:

  • It must appear in the page's <head> tag before the first script tag. If there are no script tags, put the JavaScript immediately before the </head> (end of head) tag.
  • The entire loader script must be inserted in-line, not as a link to the .js file.

Listing all Browser apps

To view a list of your apps in New Relic Browser, replace ${APIKEY} with your New Relic API key in the following command:

curl -X GET 'https://api.newrelic.com/v2/browser_applications.json' \
     -H "X-Api-Key:${APIKEY}" -i

This may be used to verify the account or name, and to get a copy of the loader script for the Browser app, if needed.

Viewing specific Browser apps

Viewing by name:

To view a specific Browser app if you know its name, replace ${APIKEY} with your New Relic API key, and replace ${NAME} with your Browser app's name in the following command:

curl -X GET 'https://api.newrelic.com/v2/browser_applications.json' \
     -H "X-Api-Key:${APIKEY}" -i 
     -d "filter[name]=${NAME}"

Viewing by Browser application ID:

To view a specific Browser app if you know its ID, replace ${APIKEY} with your New Relic API key, and replace ${ID} with your Browser application ID in the following command:

curl -X GET 'https://api.newrelic.com/v2/browser_applications.json' \
     -H "X-Api-Key:${APIKEY}" -i 
     -d 'filter[ids]=${ID}'

To obtain information for multiple Browser apps, separate the name or ID values with a comma in these commands; for example, -d 'filter[ids]=12345,23456'.

For more help

Additional documentation resources include:

Recommendations for learning more: