Metafields

Get Cart Metafields

GET /carts/{cart_id}/metafields

Request

Get a cart's metafields.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • cart_id in path - string
    required
    The ID of the Cart to which the transactions belong.
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • page in query - integer

    Specifies the page number in a limited (paginated) list of products.

  • limit in query - integer

    Controls the number of items per page in a limited (paginated) list of products.

  • key in query - string
    Filter based on a metafieldʼs key.
  • namespace in query - string
    Filter based on a metafieldʼs namespaces.
  • direction in query - string

    Sort direction. Acceptable values are: asc, desc.

    Allowed: asc | desc

example

curl --request GET \
--url 'https://api.bigcommerce.com/stores/[store_hash]/v3/carts/[cart_id]/metafields' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: {{token}}'

Response

An array of metafields and metadata.

Body

object | application/json

Response payload for the BigCommerce API.

  • data
    object

    Allows app partners to write custom data to various resources in the API.

example

{
"data": {
"permission_set": "app_only",
"namespace": "Sales Department",
"key": "Staff Name",
"value": "Ronaldo",
"description": "order",
"resource_type": "cart",
"id": "string",
"date_created": "2022-06-16T18:39:00+00:00",
"date_modified": "2022-06-16T18:39:00+00:00"
}
}

Create a Cart Metafield

POST /carts/{cart_id}/metafields

Request

Create a cart Metafield.

If you create an order from a Cart, you can continue referencing the Cart Metafields even if you delete the original Cart. Use the cart_id field on the Order to construct the Cart Metafield endpoint.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • cart_id in path - string
    required
    The ID of the Cart to which the transactions belong.
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • Content-Type in header with default of application/json - string
    required

Body

object | application/json

Common Metafield properties.

  • permission_set
    string
    required

    Determines the visibility and writeability of the field by other API consumers.

    ValueDescription
    app_onlyPrivate to the app that owns the field.
    readVisible to other API consumers.
    writeOpen for reading and writing by other API consumers.
    read_and_sf_accessVisible to other API consumers, including on the storefront.
    write_and_sf_accessOpen for reading and writing by other API consumers, including on the storefront.

    Allowed: app_only | read | write | read_and_sf_access | write_and_sf_access

  • namespace
    string
    required

    Namespace for the metafield, for organizational purposes.

    >= 1 characters<= 64 characters
    Example: Sales Department
  • key
    string
    required

    The name of the field, for example: location_id, color.

    >= 1 characters<= 64 characters
    Example: Staff Name
  • value
    string
    required

    The value of the field, for example: 1, blue.

    >= 1 characters<= 65535 characters
    Example: Ronaldo
  • description
    string

    Description for the metafields.

    >= 0 characters<= 255 characters
    Example: Name of Staff Member

example

{
"permission_set": "app_only",
"namespace": "Sales Department",
"key": "Staff Name",
"value": "Sam",
"description": "Name of staff member"
}

Response

A Metafield object.

Body

object | application/json

Response payload for the BigCommerce API.

  • data
    object

    Allows app partners to write custom data to various resources in the API.

  • meta
    object

    Response metadata.

example

{
"data": {
"id": "24",
"key": "Staff Name",
"value": "Sam",
"namespace": "Sales Department",
"permission_set": "app_only",
"resource_type": "cart",
"resource_id": "b810114d-9926-45b7-bba5-7633b251154b",
"description": "Name of staff member",
"date_created": "2023-11-15T15:16:35+00:00",
"date_modified": "2023-11-15T15:16:35+00:00"
},
"meta": {}
}

Get a Cart Metafield

GET /carts/{cart_id}/metafields/{metafield_id}

Request

Gets a cart metafield.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • cart_id in path - string
    required
    The ID of the Cart to which the transactions belong.
  • metafield_id in path - integer
    required
    The unique ID of the subject Metafield.
  • page in query - integer

    Specifies the page number in a limited (paginated) list of products.

  • limit in query - integer

    Controls the number of items per page in a limited (paginated) list of products.

  • key in query - string
    Filter based on a metafieldʼs key.
  • namespace in query - string
    Filter based on a metafieldʼs namespaces.
  • direction in query - string

    Sort direction. Acceptable values are: asc, desc.

    Allowed: asc | desc

example

curl --request GET \
--url 'https://api.bigcommerce.com/stores/[store_hash]/v3/carts/[cart_id]/metafields/[metafield_id]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: {{token}}'

Response

A Metafield object.

Body

object | application/json

Response payload for the BigCommerce API.

  • data
    object

    Allows app partners to write custom data to various resources in the API.

example

{
"data": {
"permission_set": "app_only",
"namespace": "Sales Department",
"key": "Staff Name",
"value": "Ronaldo",
"description": "order",
"resource_type": "cart",
"id": "string",
"date_created": "2022-06-16T18:39:00+00:00",
"date_modified": "2022-06-16T18:39:00+00:00"
}
}

Update a Cart Metafield

PUT /carts/{cart_id}/metafields/{metafield_id}

Request

Update a Metafield, by cart_id.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • cart_id in path - string
    required
    The ID of the Cart to which the transactions belong.
  • metafield_id in path - integer
    required
    The unique ID of the subject Metafield.
  • Content-Type in header with default of application/json - string
    required

A Metafield object.

Body

object | application/json

Common Metafield properties.

  • permission_set
    string
    required

    Determines the visibility and writeability of the field by other API consumers.

    ValueDescription
    app_onlyPrivate to the app that owns the field.
    readVisible to other API consumers.
    writeOpen for reading and writing by other API consumers.
    read_and_sf_accessVisible to other API consumers, including on the storefront.
    write_and_sf_accessOpen for reading and writing by other API consumers, including on the storefront.

    Allowed: app_only | read | write | read_and_sf_access | write_and_sf_access

  • namespace
    string
    required

    Namespace for the metafield, for organizational purposes.

    >= 1 characters<= 64 characters
    Example: Sales Department
  • key
    string
    required

    The name of the field, for example: location_id, color.

    >= 1 characters<= 64 characters
    Example: Staff Name
  • value
    string
    required

    The value of the field, for example: 1, blue.

    >= 1 characters<= 65535 characters
    Example: Ronaldo
  • description
    string

    Description for the metafields.

    >= 0 characters<= 255 characters
    Example: Name of Staff Member

Response

A Metafield and metadata.

Body

object | application/json

Response payload for the BigCommerce API.

  • data
    object

    Allows app partners to write custom data to various resources in the API.

  • meta
    object

    Response metadata.

Delete a Metafield

DELETE /carts/{cart_id}/metafields/{metafield_id}

Request

Deletes a Metafield.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • cart_id in path - string
    required
    The ID of the Cart to which the transactions belong.
  • metafield_id in path - integer
    required
    The unique ID of the subject Metafield.

example

curl --request DELETE \
--url 'https://api.bigcommerce.com/stores/[store_hash]/v3/carts/[cart_id]/metafields/[metafield_id]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: {{token}}'

Response

An empty response.

Did you find what you were looking for?