Skip to main content
PATCH
/
collections
/
{collection_id}
/
items
/
{id}
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 item = await client.collections.items.update('id', {
  collection_id: 'collection_id',
  values: { name: { type: 'value/text/single_line', data: 'Jony Appleseed' } },
});

console.log(item.id);
{
  "id": "1CLJt2v17V1yuCdrUwA4PW",
  "type": "item",
  "collection": {
    "id": "1CLJt2ubZ7zAZFBxUxeBHo",
    "type": "collection",
    "ref": "people"
  },
  "values": {
    "name": {
      "type": "value/text/single_line",
      "data": "Jony Appleseed"
    },
    "email": [
      {
        "type": "value/email",
        "data": "[email protected]"
      }
    ],
    "created_at": {
      "type": "value/datetime",
      "data": "2025-02-17T16:00:00.000Z"
    },
    "updated_at": {
      "type": "value/datetime",
      "data": "2025-02-17T16:00:00.000Z"
    }
  }
}

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Headers

update-one-strategy
enum<string>

Specifies how to update fields with a single (one) value during a PATCH or update request. Use replace (default) to overwrite the existing value with the new value. Use preserve to leave the existing value unchanged if one is already present.

Available options:
replace,
preserve
update-many-strategy
enum<string>

Specifies how to update fields that allow multiple values during a PATCH or update request. Use replace (default) to overwrite all existing values with the new values. Use preserve to leave the existing values unchanged when already present. Use merge to merge the new values with existing values.

Available options:
replace,
preserve,
merge

Path Parameters

collection_id
string
required
id
string
required

The ID of the Item to update.

Body

application/json

The Item values to update.

Parameters for updating an Item.

values
object
required

A hash where keys are the ref of a Field and values are the new data to be set.

Response

Update succeeded.

An Item represents a single record or row within a Collection. It holds a set of values corresponding to the Collection's fields.

type
string
required

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

Allowed value: "item"
id
string
required

Unique identifier for the object.

collection
CollectionPointer · object
required

A lightweight reference to a Collection, containing the minimal information needed to identify it.

values
object
required

A hash where keys are the ref of a Field and values are the data stored for that field.