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 browser monitoring or to get a list of your browser apps for a specific API key. This helps you manage deployment outside of New Relic One. These API calls are useful, for example, with larger organizations deploying multiple apps, or for integration partners who facilitate New Relic account creation and browser monitoring deployments.

Add browser apps

To add an app to New Relic One, replace ${APIKEY} with your New Relic API key, and replace ${STRING} with the app's name in the following command. To accomplish the same task from the API Explorer, use your API key and go to rpm.newrelic.com/api/explore > Browser Applications > POST Create.

Use the following command:

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 One.
App name (string) This is the app's name as it appears in the New Relic One.
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 One 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 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.

List 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. To accomplish the same task from the API Explorer, use your API key and go to rpm.newrelic.com/api/explore > Browser Applications > GET List.

Use the following command:

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

You can use the results to verify the account or name, and to get a copy of the loader script for the app, if needed.

View specific browser apps

View 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 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}"

View 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}'

View multiple browser apps:

To get information for multiple apps, separate the name or ID values with a comma in these commands; for example:

-d 'filter[ids]=12345,23456'

For more help

If you need more help, check out these support and learning resources: