Is it possible to have multiple API keys per project in Bugsnag?

244 Views Asked by At

We have multiple applications in Bugsnag and each one is deployed in multiple stages (dev, qa, prod) and regions (US, EU). Security good practices say we should have an API key per deployment (one key for each stage-region combination, e.g., dev-us, dev-eu, prod-us, prod-eu), but in Bugsnag we only have one API key per project. We could have one Bugsnag project per deployment but a single project per application it's simpler to watch all errors and to filter.

  1. Is it possible to have multiple API keys per Bugsnag project?
  2. What's the common practice, one Bugsnag project per application or per deployment?
1

There are 1 best solutions below

0
On

Yes, it's possible to have multiple projects per staging environment in a single application.

First, you'd have to create a new project within Bugsnag's dashboard for each stage (e.g. dev-us, dev-eu, prod-us, etc). Now, you'll have a new API key per project.

I will share a Java example of how you can accomplish this:

switch (stage) {
  case "dev-us":
    Bugsnag bugsnag = new Bugsnag("your-devus-project-api-key-here");
    bugsnag.setReleaseStage("dev-us");
    break;
  case "dev-eu":
    Bugsnag bugsnag = new Bugsnag("your-deveu-project-api-key-here");
    bugsnag.setReleaseStage("dev-eu");
    break;
  case "prod-us":
    Bugsnag bugsnag = new Bugsnag("your-produs-project-api-key-here");
    bugsnag.setReleaseStage("prod-us");
    break;
}

You can find similar examples of how to accomplish this with the various Bugsnag notifiers here.