Skip to main content
POST
/
collections
JavaScript
import Moonbase from '@moonbaseai/sdk';

const client = new Moonbase({
  apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});

const collection = await client.collections.create({
  name: 'Leads',
  description: 'Inbound leads from marketing',
});

console.log(collection.id);
{
  "id": "1CLJt2v5pkpkAnvdgXfEcF",
  "type": "collection",
  "name": "Leads",
  "description": "Inbound leads from marketing",
  "ref": "leads",
  "kind": "custom",
  "fields": [
    {
      "id": "1CLJt2v6592N5WQzNpjpj2",
      "type": "field/text/single_line",
      "created_at": "2025-02-17T16:00:00.000Z",
      "updated_at": "2025-02-17T16:00:00.000Z",
      "default_values": [],
      "name": "Name",
      "ref": "name",
      "cardinality": "one",
      "required": false,
      "unique": false,
      "readonly": false,
      "kind": "system"
    },
    {
      "id": "1CLJt2v6KXDyzDuM57pQqo",
      "type": "field/datetime",
      "created_at": "2025-02-17T16:00:00.000Z",
      "updated_at": "2025-02-17T16:00:00.000Z",
      "default_values": [],
      "name": "Created At",
      "ref": "created_at",
      "cardinality": "one",
      "required": false,
      "unique": false,
      "readonly": true,
      "kind": "system"
    },
    {
      "id": "1CLJt2v6ZuRbtwPhmQtzxa",
      "type": "field/datetime",
      "created_at": "2025-02-17T16:00:00.000Z",
      "updated_at": "2025-02-17T16:00:00.000Z",
      "default_values": [],
      "name": "Updated At",
      "ref": "updated_at",
      "cardinality": "one",
      "required": false,
      "unique": false,
      "readonly": true,
      "kind": "system"
    }
  ],
  "created_at": "2025-02-17T16:00:00.000Z",
  "updated_at": "2025-02-17T16:00:00.000Z"
}

Documentation Index

Fetch the complete documentation index at: https://docs.moonbase.ai/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Body

application/json

The Collection object to be created.

Parameters for creating a Collection.

name
string
required

The user-facing name of the collection (e.g., "Leads"). A ref is automatically derived from the name.

description
string

An optional, longer-form description of the collection's purpose.

Response

Creation succeeded.

A Collection is a container for structured data, similar to a database table or spreadsheet. It defines a schema using a set of Fields and holds the data as a list of Items.

type
string
required

String representing the object’s type. Always collection for this object.

Allowed value: "collection"
id
string
required

Unique identifier for the object.

name
string
required

The user-facing name of the collection (e.g., “Organizations”).

ref
string
required

A unique, stable, machine-readable identifier for the collection. This reference is used in API requests and does not change even if the name is updated.

kind
enum<string>
required

system collections are managed by Moonbase (e.g., People, Organizations), form collections back a Form, and custom collections are user-created.

Available options:
system,
form,
custom
fields
(SingleLineTextField · object | MultiLineTextField · object | IdentifierField · object | IntegerField · object | FloatField · object | MonetaryField · object | PercentageField · object | BooleanField · object | EmailField · object | UrlField · object | DomainField · object | SocialXField · object | SocialLinkedInField · object | TelephoneNumberField · object | GeoField · object | DateField · object | DatetimeField · object | ChoiceField · object | StageField · object | RelationField · object)[]
required

A list of Field objects that define the schema for items in this collection.

A field definition, which varies by type

created_at
string<date-time>
required

Time at which the object was created, as an ISO 8601 timestamp in UTC.

updated_at
string<date-time>
required

Time at which the object was last updated, as an ISO 8601 timestamp in UTC.

description
string

An optional, longer-form description of the collection's purpose.

views
View · object[]

A list of saved View objects for presenting the collection's data.

Note: Only present when requested using the include query parameter.