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.upsert('collection_id', {
identifiers: { domain: [{ type: 'value/uri/domain', data: 'aperturescience.com' }] },
values: {
name: { type: 'value/text/single_line', data: 'Aperture Science' },
domain: [{ type: 'value/uri/domain', data: 'aperturescience.com' }],
linked_in: {
type: 'value/uri/social_linked_in',
data: { url: 'https://linkedin.com/company/aperturescience' },
},
},
});
console.log(item.id);require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
item = moonbase.collections.items.upsert(
"collection_id",
identifiers: {domain: [{data: "aperturescience.com", type: :"value/uri/domain"}]},
values: {
name: {data: "Aperture Science", type: :"value/text/single_line"},
domain: [{data: "aperturescience.com", type: :"value/uri/domain"}],
linked_in: {data: {}, type: :"value/uri/social_linked_in"}
}
)
puts(item)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
item = client.collections.items.upsert(
collection_id="1CLJt2uco2zG6pdjxS37sg",
identifiers={
"domain": [{
"type": "value/uri/domain",
"data": "aperturescience.com",
}]
},
values={
"name": {
"type": "value/text/single_line",
"data": "Aperture Science",
},
"domain": [{
"type": "value/uri/domain",
"data": "aperturescience.com",
}],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"url": "https://linkedin.com/company/aperturescience"
},
},
},
)
print(item.id)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
item, err := client.Collections.Items.Upsert(
context.TODO(),
"1CLJt2uco2zG6pdjxS37sg",
moonbase.CollectionItemUpsertParams{
Identifiers: map[string]moonbase.FieldValueParamUnion{
"domain": {
OfArrayOfValues: []moonbase.ValueParamUnion{{
OfValueUriDomain: &moonbase.DomainValueParam{
Data: "aperturescience.com",
},
}},
},
},
Values: map[string]moonbase.FieldValueParamUnion{
"name": {
OfSingleLineText: &moonbase.SingleLineTextValueParam{
Data: "Aperture Science",
},
},
"domain": {
OfArrayOfValues: []moonbase.ValueParamUnion{{
OfValueUriDomain: &moonbase.DomainValueParam{
Data: "aperturescience.com",
},
}},
},
"linked_in": {
OfLinkedIn: &moonbase.SocialLinkedInValueParam{
Data: moonbase.SocialProfileLinkedInParam{
URL: moonbase.String("https://linkedin.com/company/aperturescience"),
},
},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", item.ID)
}
curl --request POST \
--url https://api.moonbase.ai/v0/collections/{collection_id}/items/upsert \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"collection_id": "1CLJt2uco2zG6pdjxS37sg",
"identifiers": {
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
]
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Aperture Science"
},
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"url": "https://linkedin.com/company/aperturescience"
}
}
}
}
'{
"id": "1CLJt2v5aNd8G5SGzEaeVU",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Aperture Science"
},
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"username": "company/aperturescience",
"url": "https://linkedin.com/company/aperturescience"
}
},
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}{
"id": "1CLJt2v6592N5WQzNpjpj2",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Aperture Science"
},
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"username": "company/aperturescience",
"url": "https://linkedin.com/company/aperturescience"
}
},
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "400",
"title": "Bad Request",
"detail": "The request could not be understood due to malformed syntax or invalid parameters."
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or missing API key or JWT. You should provide your Moonbase API Key or JWT in the authorization header, in the format: \"Authorization: Bearer MOONBASE_API_KEY\""
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "403",
"title": "Forbidden"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "409",
"title": "Conflict",
"detail": "Multiple items match the identifiers."
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "Phone is not a valid E.164 formatted telephone number",
"source": {
"pointer": "/values/phone"
}
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "429",
"title": "Too Many Requests"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "500",
"title": "Internal Server Error"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "503",
"title": "Service Unavailable",
"detail": "The service is temporarily unavailable, please try again later."
}
]
}Create or Update an Item
Find and update an existing item, or create a new one.
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.upsert('collection_id', {
identifiers: { domain: [{ type: 'value/uri/domain', data: 'aperturescience.com' }] },
values: {
name: { type: 'value/text/single_line', data: 'Aperture Science' },
domain: [{ type: 'value/uri/domain', data: 'aperturescience.com' }],
linked_in: {
type: 'value/uri/social_linked_in',
data: { url: 'https://linkedin.com/company/aperturescience' },
},
},
});
console.log(item.id);require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
item = moonbase.collections.items.upsert(
"collection_id",
identifiers: {domain: [{data: "aperturescience.com", type: :"value/uri/domain"}]},
values: {
name: {data: "Aperture Science", type: :"value/text/single_line"},
domain: [{data: "aperturescience.com", type: :"value/uri/domain"}],
linked_in: {data: {}, type: :"value/uri/social_linked_in"}
}
)
puts(item)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
item = client.collections.items.upsert(
collection_id="1CLJt2uco2zG6pdjxS37sg",
identifiers={
"domain": [{
"type": "value/uri/domain",
"data": "aperturescience.com",
}]
},
values={
"name": {
"type": "value/text/single_line",
"data": "Aperture Science",
},
"domain": [{
"type": "value/uri/domain",
"data": "aperturescience.com",
}],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"url": "https://linkedin.com/company/aperturescience"
},
},
},
)
print(item.id)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
item, err := client.Collections.Items.Upsert(
context.TODO(),
"1CLJt2uco2zG6pdjxS37sg",
moonbase.CollectionItemUpsertParams{
Identifiers: map[string]moonbase.FieldValueParamUnion{
"domain": {
OfArrayOfValues: []moonbase.ValueParamUnion{{
OfValueUriDomain: &moonbase.DomainValueParam{
Data: "aperturescience.com",
},
}},
},
},
Values: map[string]moonbase.FieldValueParamUnion{
"name": {
OfSingleLineText: &moonbase.SingleLineTextValueParam{
Data: "Aperture Science",
},
},
"domain": {
OfArrayOfValues: []moonbase.ValueParamUnion{{
OfValueUriDomain: &moonbase.DomainValueParam{
Data: "aperturescience.com",
},
}},
},
"linked_in": {
OfLinkedIn: &moonbase.SocialLinkedInValueParam{
Data: moonbase.SocialProfileLinkedInParam{
URL: moonbase.String("https://linkedin.com/company/aperturescience"),
},
},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", item.ID)
}
curl --request POST \
--url https://api.moonbase.ai/v0/collections/{collection_id}/items/upsert \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"collection_id": "1CLJt2uco2zG6pdjxS37sg",
"identifiers": {
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
]
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Aperture Science"
},
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"url": "https://linkedin.com/company/aperturescience"
}
}
}
}
'{
"id": "1CLJt2v5aNd8G5SGzEaeVU",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Aperture Science"
},
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"username": "company/aperturescience",
"url": "https://linkedin.com/company/aperturescience"
}
},
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}{
"id": "1CLJt2v6592N5WQzNpjpj2",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Aperture Science"
},
"domain": [
{
"type": "value/uri/domain",
"data": "aperturescience.com"
}
],
"linked_in": {
"type": "value/uri/social_linked_in",
"data": {
"username": "company/aperturescience",
"url": "https://linkedin.com/company/aperturescience"
}
},
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "400",
"title": "Bad Request",
"detail": "The request could not be understood due to malformed syntax or invalid parameters."
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or missing API key or JWT. You should provide your Moonbase API Key or JWT in the authorization header, in the format: \"Authorization: Bearer MOONBASE_API_KEY\""
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "403",
"title": "Forbidden"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "409",
"title": "Conflict",
"detail": "Multiple items match the identifiers."
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "Phone is not a valid E.164 formatted telephone number",
"source": {
"pointer": "/values/phone"
}
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "429",
"title": "Too Many Requests"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "500",
"title": "Internal Server Error"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "503",
"title": "Service Unavailable",
"detail": "The service is temporarily unavailable, please try again later."
}
]
}Authorizations
Your Moonbase API key.
Headers
Specifies how to update fields that have a single value. 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.
replace, preserve Specifies how to update fields that allow multiple values. 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.
replace, preserve, merge Path Parameters
Body
The Item object to be created or updated.
Parameters for creating or updating an Item.
A hash where keys are the ref of a Field and values are used to identify the item to update. When multiple identifiers are provided, the update will find items that match any of the identifiers.
Show child attributes
Show child attributes
A hash where keys are the ref of a Field and values are the data to be set.
Show child attributes
Show child attributes
Response
Successful response.
An Item represents a single record or row within a Collection. It holds a set of values corresponding to the Collection's fields.
String representing the object’s type. Always item for this object.
"item"Unique identifier for the object.
A lightweight reference to a Collection, containing the minimal information needed to identify it.
Show child attributes
Show child attributes
A hash where keys are the ref of a Field and values are the data stored for that field.
Show child attributes
Show child attributes

