Getting Started
Quickstart
Pick your language once - every snippet below switches with you. Four steps, and you have created a collection and written and read back your first real data.
1
Install the SDK
Every SDK is generated from the same OpenAPI spec, so the shapes match across languages.
bashterminal
npm install mudbase-sdknpm install mudbase-sdk2
Initialize the client
There is no unified client wrapper - build a Configuration once, then the API classes you need, and share them across your app.
javascriptmudbase.js
import { Configuration, CollectionsApi, DataApi } from "mudbase-sdk";
// There is no unified client wrapper - build a Configuration, then the
// API classes you need. Your project API key goes out as X-API-Key on
// every request via baseOptions.
const config = new Configuration({
basePath: "https://cloud.mudbase.dev",
baseOptions: {
headers: { "X-API-Key": process.env.MUDBASE_API_KEY },
},
});
export const collections = new CollectionsApi(config);
export const data = new DataApi(config);import { Configuration, CollectionsApi, DataApi } from "mudbase-sdk";
// There is no unified client wrapper - build a Configuration, then the
// API classes you need. Your project API key goes out as X-API-Key on
// every request via baseOptions.
const config = new Configuration({
basePath: "https://cloud.mudbase.dev",
baseOptions: {
headers: { "X-API-Key": process.env.MUDBASE_API_KEY },
},
});
export const collections = new CollectionsApi(config);
export const data = new DataApi(config);3
Make your first request
Create a collection, write a document, and read it back - a real authenticated call against your project that returns a 2xx.
javascriptexample.js
const projectId = process.env.MUDBASE_PROJECT_ID;
// 1. Create your first collection
const { data: created } = await collections.createCollection({
projectId,
createCollectionRequest: {
name: "tasks",
fields: [
{ name: "title", type: "string", required: true },
{ name: "done", type: "boolean" },
],
},
});
const collectionId = created.collection._id;
// 2. Write a document to it
await data.createData({
projectId,
collectionId,
body: { title: "Ship my first Mudbase feature", done: false },
});
// 3. Read it back - your first real, authenticated data call
const { data: result } = await data.listData({ projectId, collectionId });
console.log(result.data); // [{ _id, title, done, createdAt, ... }]const projectId = process.env.MUDBASE_PROJECT_ID;
// 1. Create your first collection
const { data: created } = await collections.createCollection({
projectId,
createCollectionRequest: {
name: "tasks",
fields: [
{ name: "title", type: "string", required: true },
{ name: "done", type: "boolean" },
],
},
});
const collectionId = created.collection._id;
// 2. Write a document to it
await data.createData({
projectId,
collectionId,
body: { title: "Ship my first Mudbase feature", done: false },
});
// 3. Read it back - your first real, authenticated data call
const { data: result } = await data.listData({ projectId, collectionId });
console.log(result.data); // [{ _id, title, done, createdAt, ... }]4
Set environment variables
Find these in the Console under Settings → API Keys. Never commit them.
bash.env
MUDBASE_API_KEY=ak_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MUDBASE_PROJECT_ID=685ad30be129932fbb7a1047MUDBASE_API_KEY=ak_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MUDBASE_PROJECT_ID=685ad30be129932fbb7a1047Note
Find your
projectId and API key in the MUDBASE Console under Settings → API Keys.Warning
Never expose your API key in client-side code. Always use environment variables or a secrets manager.
Last updated: September 2026
Edit this page on GitHub