> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # CreateDataExtensionSchema # Package: dataExtensionSchema # Namespace: DataExtensionSchemaService # Method link: https://dev.wix.com/docs/api-reference/business-management/data-extension-schema/create-data-extension-schema.md ## Permission Scopes: Manage Data Extensions Schemas: SCOPE.DATAEXTENSIONS.MANAGE-SCHEMAS ## Introduction Creates a user-defined data extension schema. --- ## REST API ### Schema ``` Method: createDataExtensionSchema Description: Creates a user-defined data extension schema. URL: https://www.wixapis.com/v1/schemas Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: dataExtensionSchema, dataExtensionSchema.jsonSchema, dataExtensionSchema.fqdn, dataExtensionSchema.namespace Method parameters: param name: dataExtensionSchema | type: DataExtensionSchema | description: A Data Extension Schema is the [JSON schema](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/the-json-schema.md) within a [schema plugin extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) defining `extendedFields` that are added to a Wix API's service object. | required: true - name: fqdn | type: string | description: FQDN of the entity this schema extends. Use a wildcard (`*`) in place of the version number, for example `wix.ecom.*.order`. See [Supported objects](https://dev.wix.com/docs/api-reference/business-management/data-extension-schema/introduction.md#supported-objects) for valid FQDNs. | required: true - name: namespace | type: string | description: Namespace for this schema. For example, an app creating schemas might use their app name as a namespace. When a site owner creates a user-defined schema, the namespace is: `_user_fields`. | required: true - name: jsonSchema | type: object | description: Schema definition in [JSON schema format](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/the-json-schema.md) with the following [vocab](https://docs.json-everything.net/schema/vocabs/) extension: ``` { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wixapis.com/v1/json-schema/extensions", "$vocabulary": { "https://wixapis.com/v1/json-schema/extensions/vocab/data-extensions": true }, "$dynamicAnchor": "meta", "title": "Wix' data-extensions vocabulary meta schema", "type": [ "object", "boolean" ], "properties": { "x-wix-permissions": { "type": "object", "description": "list of identity types that are allowed reading schema properties", "properties": { "read": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } }, "write": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } } } }, "x-wix-display": { "type": "object", "description": "field display properties", "schema": { "properties": { "placeholder": { "type": "string", "maxLength": 255, "description": "placeholder text for input fields" }, "label": { "type": "string", "maxLength": 255, "description": "label of the input fields" }, "hint": { "type": "string", "maxLength": 255, "description": "a short explanation that appears next to the input field" } } } } } } ``` | required: true Return type: CreateDataExtensionSchemaResponse - name: dataExtensionSchema | type: DataExtensionSchema | description: Created schema. - name: id | type: string | description: Schema GUID. - name: fqdn | type: string | description: FQDN of the entity this schema extends. Use a wildcard (`*`) in place of the version number, for example `wix.ecom.*.order`. See [Supported objects](https://dev.wix.com/docs/api-reference/business-management/data-extension-schema/introduction.md#supported-objects) for valid FQDNs. - name: namespace | type: string | description: Namespace for this schema. For example, an app creating schemas might use their app name as a namespace. When a site owner creates a user-defined schema, the namespace is: `_user_fields`. - name: jsonSchema | type: object | description: Schema definition in [JSON schema format](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/the-json-schema.md) with the following [vocab](https://docs.json-everything.net/schema/vocabs/) extension: ``` { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wixapis.com/v1/json-schema/extensions", "$vocabulary": { "https://wixapis.com/v1/json-schema/extensions/vocab/data-extensions": true }, "$dynamicAnchor": "meta", "title": "Wix' data-extensions vocabulary meta schema", "type": [ "object", "boolean" ], "properties": { "x-wix-permissions": { "type": "object", "description": "list of identity types that are allowed reading schema properties", "properties": { "read": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } }, "write": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } } } }, "x-wix-display": { "type": "object", "description": "field display properties", "schema": { "properties": { "placeholder": { "type": "string", "maxLength": 255, "description": "placeholder text for input fields" }, "label": { "type": "string", "maxLength": 255, "description": "label of the input fields" }, "hint": { "type": "string", "maxLength": 255, "description": "a short explanation that appears next to the input field" } } } } } } ``` - name: updatedDate | type: string | description: Date and time the schema was last updated. - name: createdDate | type: string | description: Date and time the schema was created. - name: revision | type: string | description: Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing revision must be used when updating a schema. - name: maxLimitBytes | type: integer | description: Maximum allowed schema size in bytes. - name: currentSizeBytes | type: integer | description: Current schema size in bytes. ``` ### Examples ### CreateDataExtensionSchema ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/schema-service/v1/schemas' \ -H 'Content-type: application/json' \ -H 'Authorization: ' \ -d '{ "dataExtensionSchema": { "id": "01ea0c8d-80b8-46e3-bfda-611b3678545b", "fqdn": "wix.ecom.*.order", "namespace": "_user_fields", "jsonSchema": { "additionalProperties": false, "properties": { "personalization": { "type": "object", "x-wix-permissions": { "read": [ "users-of-users", "users", "apps" ], "write": [ "users" ] }, "additionalProperties": false, "properties": { "giftMessage": { "maxLength": 50, "type": "string", "x-wix-permissions": { "read": [ "users-of-users", "users", "apps" ], "write": [ "users" ] } } } } } } } }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.dataExtensionSchema.DataExtensionSchemaService.createDataExtensionSchema(dataExtensionSchema) Description: Creates a user-defined data extension schema. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: dataExtensionSchema, dataExtensionSchema.jsonSchema, dataExtensionSchema.fqdn, dataExtensionSchema.namespace Method parameters: param name: dataExtensionSchema | type: DataExtensionSchema | description: A Data Extension Schema is the [JSON schema](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/the-json-schema.md) within a [schema plugin extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) defining `extendedFields` that are added to a Wix API's service object. | required: true - name: fqdn | type: string | description: FQDN of the entity this schema extends. Use a wildcard (`*`) in place of the version number, for example `wix.ecom.*.order`. See [Supported objects](https://dev.wix.com/docs/api-reference/business-management/data-extension-schema/introduction.md#supported-objects) for valid FQDNs. | required: true - name: namespace | type: string | description: Namespace for this schema. For example, an app creating schemas might use their app name as a namespace. When a site owner creates a user-defined schema, the namespace is: `_user_fields`. | required: true - name: jsonSchema | type: object | description: Schema definition in [JSON schema format](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/the-json-schema.md) with the following [vocab](https://docs.json-everything.net/schema/vocabs/) extension: ``` { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wixapis.com/v1/json-schema/extensions", "$vocabulary": { "https://wixapis.com/v1/json-schema/extensions/vocab/data-extensions": true }, "$dynamicAnchor": "meta", "title": "Wix' data-extensions vocabulary meta schema", "type": [ "object", "boolean" ], "properties": { "x-wix-permissions": { "type": "object", "description": "list of identity types that are allowed reading schema properties", "properties": { "read": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } }, "write": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } } } }, "x-wix-display": { "type": "object", "description": "field display properties", "schema": { "properties": { "placeholder": { "type": "string", "maxLength": 255, "description": "placeholder text for input fields" }, "label": { "type": "string", "maxLength": 255, "description": "label of the input fields" }, "hint": { "type": "string", "maxLength": 255, "description": "a short explanation that appears next to the input field" } } } } } } ``` | required: true Return type: PROMISE - name: _id | type: string | description: Schema GUID. - name: fqdn | type: string | description: FQDN of the entity this schema extends. Use a wildcard (`*`) in place of the version number, for example `wix.ecom.*.order`. See [Supported objects](https://dev.wix.com/docs/api-reference/business-management/data-extension-schema/introduction.md#supported-objects) for valid FQDNs. - name: namespace | type: string | description: Namespace for this schema. For example, an app creating schemas might use their app name as a namespace. When a site owner creates a user-defined schema, the namespace is: `_user_fields`. - name: jsonSchema | type: object | description: Schema definition in [JSON schema format](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/the-json-schema.md) with the following [vocab](https://docs.json-everything.net/schema/vocabs/) extension: ``` { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wixapis.com/v1/json-schema/extensions", "$vocabulary": { "https://wixapis.com/v1/json-schema/extensions/vocab/data-extensions": true }, "$dynamicAnchor": "meta", "title": "Wix' data-extensions vocabulary meta schema", "type": [ "object", "boolean" ], "properties": { "x-wix-permissions": { "type": "object", "description": "list of identity types that are allowed reading schema properties", "properties": { "read": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } }, "write": { "type": "array", "items": { "type": "string", "enum": [ "apps", "owning-app", "users", "users-of-users" ] } } } }, "x-wix-display": { "type": "object", "description": "field display properties", "schema": { "properties": { "placeholder": { "type": "string", "maxLength": 255, "description": "placeholder text for input fields" }, "label": { "type": "string", "maxLength": 255, "description": "label of the input fields" }, "hint": { "type": "string", "maxLength": 255, "description": "a short explanation that appears next to the input field" } } } } } } ``` - name: _updatedDate | type: Date | description: Date and time the schema was last updated. - name: _createdDate | type: Date | description: Date and time the schema was created. - name: revision | type: string | description: Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing revision must be used when updating a schema. - name: maxLimitBytes | type: integer | description: Maximum allowed schema size in bytes. - name: currentSizeBytes | type: integer | description: Current schema size in bytes. ``` ### Examples ### createDataExtensionSchema ```javascript import { schemas } from '@wix/data-extension-schema'; async function createDataExtensionSchema(dataExtensionSchema) { const response = await schemas.createDataExtensionSchema(dataExtensionSchema); }; ``` ### createDataExtensionSchema (with elevated permissions) ```javascript import { schemas } from '@wix/data-extension-schema'; import { auth } from '@wix/essentials'; async function myCreateDataExtensionSchemaMethod(dataExtensionSchema) { const elevatedCreateDataExtensionSchema = auth.elevate(schemas.createDataExtensionSchema); const response = await elevatedCreateDataExtensionSchema(dataExtensionSchema); } ``` ### createDataExtensionSchema (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { schemas } from '@wix/data-extension-schema'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { schemas }, // Include the auth strategy and host as relevant }); async function createDataExtensionSchema(dataExtensionSchema) { const response = await myWixClient.schemas.createDataExtensionSchema(dataExtensionSchema); }; ``` ---