This is the early access documentation preview for Custom Views. This documentation might not be in sync with our official documentation.

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
String
"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 key exists, it will be updated with the imported data.

MinLength: 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$
name

Maps to Type.name.

description

Maps to Type.description.

resourceTypeIds
Array of ResourceTypeId

Maps to Type.resourceTypeIds. This value cannot be changed after the Type is imported.

MinItems: 1
fieldDefinitions
Array of FieldDefinition

Maps to Type.fieldDefinitions.

ResourceTypeId

IDs indicating the customizable 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

BusinessUnit

cart-discount

CartDiscount

category

Category

channel

Channel

customer

Customer

customer-group

CustomerGroup

custom-line-item

CustomLineItem on Cart and Order

discount-code

DiscountCode

inventory-entry

InventoryEntry

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

OrderEdit

order-delivery

Delivery

order-parcel

Parcel

order-return-item

ReturnItem

payment

Payment

payment-interface-interaction

InterfaceInteraction on Payment

product-price

Embedded Price on ProductVariant

product-selection

ProductSelection

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

Review

shipping

Shipping

shipping-method

ShippingMethod

shopping-list

ShoppingList

shopping-list-text-line-item

TextLineItem on ShoppingList

standalone-price

StandalonePrice

store

Store

transaction

Transaction on Payment

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 name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

MinLength: 2MaxLength: 36Pattern: ^[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 of the specific field types have additional fields for meta-data, 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

Allowed values.

CustomFieldLocalizedEnumType

Field type for localized enum values.

name
String
"LocalizedEnum"
values

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
key-value-document
order
product
product-type
review
state
shipping-method
zone

Import Types

POST
https://import.{region}.commercetools.com/{projectKey}/types/import-containers/{importContainerKey}

Creates a request for creating new Type or updating existing ones.

OAuth 2.0 Scopes:
manage_project:{projectKey} , manage_types:{projectKey}
Path parameters:
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

Request Body:TypeImportRequestasapplication/json
Response:
201ImportResponseasapplication/json
Request Example:cURL
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" : "string-type-name",
"label" : {
"en" : "A label for the string field."
},
"required" : false,
"inputHint" : "SingleLine"
} ]
} ]
}
DATA