Skip to content
API
Managing your game
API keys

API keys

When you've received your Beam accounts API key, you're received three different keys:

  • a read-only key - this key allows you use read-only endpoints
  • a read & write key - this key allows you to read and manage data
  • a regenerate key - this allows you to regenerate your api keys

The regenerate key is reserved for one specific action - to invalidate, and re-create the API keys we provided to you. This could come in handy if you are looking to implement a rotating key solution where you would like to invalidate the API key being used in your backend every x hours/days.

Note that, as soon as you regenerate the keys, your existing keys will be invalidated as soon as you retrieve your new keys. When you use the method, the response will contain a new set of three keys - store them securely!

Below you'll find an example on how to regenerate your API keys.

import { Beam } from "@onbeam/node";
 
const beam = new Beam("x-regenerate-api-key");
 
const keys = beam.game.regenerateApiKeys();
 
// {
//   "id": "string",
//   "createdAt": "string",
//   "updatedAt": "string",
//   "name": "string",
//   "description": "string",
//   "coverImageUrl": "string",
//   "logoImageUrl": "string",
//   "chainIds": [
//     0
//   ],
//   "apiKeys": [
//     {
//       "type": "ReadOnly",
//       "createdAt": "string",
//       "apiKey": "string",
//     },
//     {
//       "type": "ReadWrite",
//       "createdAt": "string",
//       "apiKey": "string",
//     }
//     {
//       "type": "Regenerate",
//       "createdAt": "string",
//       "apiKey": "string",
//     }
//   ]
// }