By Paul Scanlon

What Is the CockroachDB Cloud API?

Project Overview

My first task after joining Cockroach Labs was to design and build something that demonstrates the capabilities of the new CockroachDB Cloud API. I read the docs, tested out some endpoints and my mind went immediately to, “Dashboard”.

The snag however is, CockroachDB already has the Cockroach Cloud Console which can be used to create new Clusters and perform a number of operational tasks. So, I needed an angle.


Like most, if not all Cloud UI interfaces they cater for customer’s most common needs and often require user authentication. User authentication typically comes in the form of “paid for seats” which means there’s usually only a few folks who can access what might actually be some super helpful information.


The solution to this is of course, make this information publicly available, and without authorization. By using the CockroachDB Cloud API you can authorize the application, rather than the user, and choose which information to surface publicly. Creating an app that lives on a live URL means anyone with the link can see what’s going on with your database infrastructure, (without first needing to navigate the painful internal processes of requesting access).


When thinking about database infrastructure it’s fair to assume only the super technical would ever need to know the details but, when you introduce FinOps (folks in charge of spend budgets etc) it becomes crystal clear that the cost of infrastructure would absolutely be something that decision makers would want to be aware of!

The Idea

Using Next.js I securely make server-side requests to the CockroachDB Cloud API, retrieve the required information then, display it in user friendly way. I also mutate one of the endpoints and add up the total spend for each cluster to provide a quick way for FinOps to determine monthly costs.


… but wait there’s more.

Using NextAuth I created what I’m calling conditional authorization. NextAuth is free (Open Source) and can be hooked up via GitHub’s oAuth apps (also free) and can be used to determine levels of access based on a users email address.

Admin Access

In this demo app I gave myself and Rob the role of Admin. With Admin access to the app we can perform operational updates to the infrastructure right there in the same UI. An Admin user could be given control to increase or decrease spend limits or, the ability to create or delete databases.

Admin Access

User Access

A non Admin user isn’t permitted the same level of access but can still see all this information, they just can’t change it.

User Access

Video Walk through

Here’s a short video by my colleague Rob Reid that explains a little more about how this works.


Or, if you’d prefer, here’s a full write up about the project: What is the CockroachDB Cloud API and why should you use It?

Further Reading