Importing Types
Create and update Types in your Project.
The Type data to import is represented by TypeImport and included in a TypeImportRequest, which is imported using Import Types.
Representations
TypeImportRequest
The request body to import Types. Contains data for Types to be created or updated in a Project.
type | "type"The Type import resource type. |
resourcesArray of TypeImport | The type import resources of this request. MaxItems:20 |
TypeImport
The data representation for a Type to be imported that is persisted as a Type in the Project.
keyString | User-defined unique identifier for the Type. If a Type with this 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
name | Maps to |
description | Maps to |
resourceTypeIdsArray of ResourceTypeId | Maps to 1 |
fieldDefinitionsArray of FieldDefinition | Maps to |
ResourceTypeId
IDs indicating the type of resource. Maps to Type.resourceTypeIds.
addressAddress on BusinessUnit, Cart, Order, OrderEdit, Customer, and Channel
assetAsset on Category and ProductVariant
business-unitcart-discountcategorychannelcustomercustomer-groupcustom-line-itemCustomLineItem on Cart and Order
discount-codeinventory-entryline-itemLineItem on Cart and Order, and on ShoppingListLineItem.
orderCart and Order. When a Cart is ordered, the CustomFields need to be copied to the Order. For this reason, the Types for Carts are also valid for Orders, and hence both have the same identifier:
order.order-editorder-deliveryorder-parcelorder-return-itempaymentpayment-interface-interactionproduct-priceproduct-selectionquoteQuote, QuoteRequest and StagedQuote. When a StagedQuote is created, the CustomFields will be copied from the QuoteRequest and when a Quote is created, the CustomFields will be copied from the StagedQuote. For this reason, the Types for Quotes are also valid for QuoteRequests and StagedQuotes, and hence all have the same identifier:
quote.reviewshippingshipping-methodshopping-listshopping-list-text-line-itemstandalone-pricestoretransaction
FieldDefinition
Defines a Custom Field and its meta-information. Maps to Type.FieldDefinition.
type | Data type of the Custom Field to define. |
nameString | Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same 2MaxLength: 36Pattern: ^[A-Za-z0-9_-]+$ |
label | A human-readable label for the field. |
requiredBoolean | Defines whether the field is required to have a value. This value cannot be changed after the Type is imported. |
inputHint | Provides a visual representation type for this field. It is only relevant for string-based field types like CustomFieldStringType and CustomFieldLocalizedStringType. Default:SingleLine |
TypeTextInputHint
Provides a visual representation type for this field. It is only relevant for string-based field types like CustomFieldStringType and CustomFieldLocalizedStringType.
SingleLineHint for GUIs to display the field's content in a single line of text.
MultiLineHint for GUIs to display the field's content over multiple lines of text.
FieldType
Abstract parent type for the specific field types with the common name field.
Some FieldTypes have additional fields for metadata. For example, allowed values for enum types or elementType for set type fields.
CustomFieldBooleanType
Field type for Boolean values.
nameString | "Boolean" |
CustomFieldDateTimeType
Field type for DateTime values.
nameString | "DateTime" |
CustomFieldDateType
Field type for Date values.
nameString | "Date" |
CustomFieldEnumType
Field type for enum values.
nameString | "Enum" |
valuesArray of CustomFieldEnumValue | Allowed values. |
CustomFieldLocalizedEnumType
Field type for localized enum values.
nameString | "LocalizedEnum" |
valuesArray of CustomFieldLocalizedEnumValue | Allowed values. |
CustomFieldLocalizedStringType
Field type for LocalizedString values.
nameString | "LocalizedString" |
CustomFieldMoneyType
Field type for CentPrecisionMoney values.
nameString | "Money" |
CustomFieldNumberType
Field type for number values.
nameString | "Number" |
CustomFieldReferenceType
Field type for Reference values.
nameString | "Reference" |
referenceTypeId | Resource type the Custom Field can reference. |
CustomFieldSetType
Values of a SetType Custom Field are sets of values of the specified elementType (without duplicate elements).
nameString | "Set" |
elementType | Field type of the elements in the set. |
CustomFieldStringType
Field type for string values.
nameString | "String" |
CustomFieldTimeType
Field type for Time values.
nameString | "Time" |
CustomFieldEnumValue
Defines an allowed value of a CustomFieldEnumType field.
keyString | Key of the value used as a programmatic identifier. |
labelString | Descriptive label of the value. |
CustomFieldLocalizedEnumValue
Defines an allowed value of a CustomFieldLocalizedEnumType field.
keyString | Key of the value used as a programmatic identifier. |
label | Descriptive localized label of the value. |
CustomFieldReferenceValue
Defines which resource type a CustomFieldReferenceType can reference.
associate-rolebusiness-unitcartcategorychannelcustomercustomer-groupkey-value-documentorderproductproduct-typereviewstateshipping-methodzone
Import Types
Creates a request for creating new Type or updating existing ones.
manage_project:{projectKey}manage_types:{projectKey}regionString | The Region in which the Project is hosted. |
projectKeyString | The Project key. |
importContainerKeyString | The ImportContainer used to create the new resource |
application/jsonapplication/jsoncurl https://import.{region}.commercetools.com/{projectKey}/types/import-containers/{importContainerKey} -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"type" : "type","resources" : [ {"key" : "type-key","name" : {"en" : "Name of type"},"description" : {"en" : "Description of type"},"resourceTypeIds" : [ "customer" ],"fieldDefinitions" : [ {"type" : {"name" : "String"},"name" : "exampleStringField","label" : {"en" : "Example string field."},"required" : false,"inputHint" : "SingleLine"} ]} ]}DATA