Skip to content

Create a metaobject entry

POST
/stores/{storeRef}/metaobjects/{type}/entries
curl --request POST \
--url https://apibase.ecomweb.app/api/v1/stores/example/metaobjects/example/entries \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '{ "handle": "example", "status": "active", "fields": {} }'

Creates an entry of the given type. fields is validated against the definition: required fields must be present, and unknown keys are rejected. The handle is generated from the display name when not given, and a handle already in use answers 409. status is only honoured when the definition has statuses.

Required scopes: write:metaobjects

type
required
string

The metaobject definition’s type handle.

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typeapplication/json
object
handle

The entry’s handle, 1 to 255 lowercase letters, digits or hyphens. Generated from the display name when left out on create.

string
status

Active or draft. Only used when the definition has a status; otherwise every entry is active. Defaults to active on create.

string
Allowed values: active draft
fields

Field values, keyed by field key. On update, values merge per key and null clears a field; on create, required fields must be present.

object
key
additional properties
any
Media typeapplication/json
object
id
required

Entry ID, as a string.

string
definition_id
required

ID of the metaobject definition the entry belongs to.

string
status
required

Active or draft. Always active when the definition has no status.

string
Allowed values: active draft
fields
required

The field values, keyed by field key. Fields without a value are left out.

object
key
additional properties
any
created_by
required

ID of the user who created the entry, or null.

string
nullable
updated_by
required

ID of the user who last updated the entry, or null.

string
nullable
created_at
required

When the entry was created, as an ISO 8601 timestamp.

string format: date-time
updated_at
required

When the entry was last updated, as an ISO 8601 timestamp.

string format: date-time
handle
required

The entry’s handle, unique within its type. Generated from the display name when not given on create.

string
display_name
required

The text that names the entry: the display-name field’s value, or the handle.

string
type
required

The type handle of the entry’s definition.

string

Example

{
"status": "active"
}

The request is malformed or failed validation.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The resource does not exist in this store.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The request conflicts with the resource’s current state.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}