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. |
resources Array 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.
key String | User-defined unique identifier for the Type. If a Type with this 2 MaxLength: 256 Pattern: ^[A-Za-z0-9_-]+$ |
name | Maps to |
description | Maps to |
resourceTypeIds Array of ResourceTypeId | Maps to 1 |
fieldDefinitions Array of FieldDefinition | Maps to |
ResourceTypeId
With Types, you can model your own Custom Fields on the following resources and data types. Maps to Type.resourceTypeId
.
address
Address on BusinessUnit, Cart, Order, OrderEdit, Customer, and Channel
asset
Asset on Category and ProductVariant
business-unit
cart-discount
category
channel
customer
customer-group
custom-line-item
CustomLineItem on Cart and Order
discount-code
inventory-entry
line-item
LineItem on Cart and Order, and LineItem on ShoppingList
order
Cart 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-edit
order-delivery
order-parcel
order-return-item
payment
payment-interface-interaction
product-price
product-selection
quote
Quote, 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
.review
shipping
shipping-method
shopping-list
shopping-list-text-line-item
standalone-price
store
transaction
FieldDefinition
Defines a Custom Field and its meta-information. Maps to Type.FieldDefinition
.
type | Data type of the Custom Field to define. |
name String | Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same 2 MaxLength: 36 Pattern: ^[A-Za-z0-9_-]+$ |
label | A human-readable label for the field. |
required Boolean | 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.
SingleLine
Hint for GUIs to display the field's content in a single line of text.
MultiLine
Hint 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.
name String | "Boolean" |
CustomFieldDateTimeType
Field type for DateTime values.
name String | "DateTime" |
CustomFieldDateType
Field type for Date values.
name String | "Date" |
CustomFieldEnumType
Field type for enum values.
name String | "Enum" |
values Array of CustomFieldEnumValue | Allowed values. |
CustomFieldLocalizedEnumType
Field type for localized enum values.
name String | "LocalizedEnum" |
values Array of CustomFieldLocalizedEnumValue | Allowed values. |
CustomFieldLocalizedStringType
Field type for LocalizedString values.
name String | "LocalizedString" |
CustomFieldMoneyType
Field type for CentPrecisionMoney values.
name String | "Money" |
CustomFieldNumberType
Field type for number values.
name String | "Number" |
CustomFieldReferenceType
Field type for Reference values.
name String | "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).
name String | "Set" |
elementType | Field type of the elements in the set. |
CustomFieldStringType
Field type for string values.
name String | "String" |
CustomFieldTimeType
Field type for Time values.
name String | "Time" |
CustomFieldEnumValue
Defines an allowed value of a CustomFieldEnumType field.
key String | Key of the value used as a programmatic identifier. |
label String | Descriptive label of the value. |
CustomFieldLocalizedEnumValue
Defines an allowed value of a CustomFieldLocalizedEnumType field.
key String | 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-role
business-unit
cart
category
channel
customer
customer-group
key-value-document
order
product
product-type
review
state
shipping-method
zone
Import Types
Creates a request for creating new Type or updating existing ones.
manage_project:{projectKey}
manage_types:{projectKey}
region String | The Region in which the Project is hosted. |
projectKey String | The Project key. |
importContainerKey String | The ImportContainer used to create the new resource |
application/json
application/json
curl 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