About Schema Plugin Extensions

Every Wix API has a service object with predefined fields, which can’t be removed or changed. Sometimes, you might want to add additional fields to an object. For example, if your app uses the Booking object to help outdoor adventure companies book their services, you may want to add a field to include equipment rental as part of the booking.

Schema plugins allow you to extend an object with additional fields. A schema plugin adds fields in an object’s extendedFields property.

Reading and writing schema plugin fields

Once added, you can read and write schema plugin fields using the object's regular endpoints, just like any other field in the object. Schema plugin fields your app can read or write to depend on the field permissions defined in the schema plugin.

Namespaces

Inside extendedFields is a nested object called namespaces. The namespaces object contains the namespaces of any apps that extend the same API object. The schema plugin fields defined by your app are found in your app's namespace object.

Learn more about namespaces

For example, you could create a schema plugin for the Booking object with the namespace myApp. This namespace will be listed in the namespaces object. Inside the namespace are the fields you defined in your schema plugin.

A site that installs your app could install another app that also extended the Booking object. In this case, your app needs to know which fields belong to it. This is where namespaces come in. The object separates your plugin data from the other app's. It contains two separate objects in namespaces and places your respective schema plugins in the appropriate object.

The extendedFields object looks something like this:

Copy

When your app reads or writes to a field defined by your schema plugin, it must include your namespace in the call to access the correct field.

Note: If a site owner has defined a schema plugin, that plugin is defined in a default namespace called user_defined. This namespace may appear in API calls.

Use cases

Here are a few possible use cases for schema plugins:

  • Include accessories, such as sports equipment, in the Booking object.
  • Add a warranty field to the eCommerce Order object.
  • Add a field to the Checkout object giving users the option to send products as a gift.

You’re not restricted to these examples. You can add a schema plugin to any object that supports it and use them in any way that you need.

Note: Only use a schema plugin when an object doesn’t have a field to support your data. Be aware that many objects contain nested fields that may already meet your app’s needs. Before creating a schema plugin, check the object to make sure you don’t add fields that already exist.

Supported objects

You can add a schema plugin to any object that has an extendedFields property.

See also

Did this help?