How to Create Cart Attribute

I have been seeing on APIs on how to retrieve cart attribute, but my question is how do I even create a cart attribute to store data? I don’t want this attribute to be visible to customers though. Thanks!

You could add cart’s line item attribute with the name start with “_”, for example, “_color”, this only visible in admin, not to the client.

jQuery.post('/cart/add.js', {
  quantity: 1,  
  id: 40362526310580,
  properties: {
    _color: "green",
  }
});

You post to the cart.js endpoint:

https://shopify.dev/docs/api/ajax/reference/cart

Looks like this: