Each Swell store has an editable schema based on models. These are the building blocks that shape each store and house both content and business data. With models, you can customize and capture information within various namespaces of your choosing—allowing you to utilize or access that information in various locations.

Models can be customized by Swell Apps, and from within the Swell dashboard under Developer → Models. To begin customizing your models via API, you’ll need to authenticate your store:

Swell comes with a suite of standard ecommerce models and logic out of the box which serves as a foundation for further customization. You can add new fields to built-in models like products and orders, or create entirely new models for your store’s specific needs. Fields can be used to store all the kinds of data you’d expect from a CMS or database, can be rendered in the dashboard for admins to edit, and can utilize formulas for default values.

You can view your store’s schema in the Swell dashboard, and through API endpoints such as the following.

GET method
GET /:models

To retrieve a single model, append the model’s ID:

Retrieve a single model
GET /:models/products

That will return a result like this:

The product model
{
  "version": "1.0.147",
  "name": "products",
  "api": "com",
  "label": "Products",
  "fields": {
    "id": {
      "type": "objectid"
    },
    "date_created": {
      "type": "date",
      "auto": true
    },
    "date_updated": {
      "type": "date",
      "auto": "update"
    },
    "name": {
      "type": "string",
      "required": true,
      "localized": true
    },
    "slug": {
      "type": "string",
      "unique": true,
      "required": true,
      "format": "slug",
      "default": {
        "$formula": "slug(name)"
      }
    },
    "sku": {
      "type": "string",
      "unique": true,
      "label": "SKU"
    },
    "active": {
      "type": "bool",
      "default": false
    },
    "discontinued": {
      "type": "bool"
    },
    "tags": {
      "type": "array",
      "value_type": "string"
    },
    "popularity": {
      "type": "int"
    },
    "price": {
      "type": "currency",
      "localized": true,
      "default": 0
    },
    "sale": {
      "type": "bool"
    },
    "sale_price": {
      "type": "currency",
      "localized": true
    },
    ...
   }
  }

If you’d like a deep dive into customizing data models, be sure to check out our conceptual guide: Data model customization.