Skip to content

Create attributes

POST
/merchants/{merchantCode}/attributes
curl --request POST \
--url https://customer.shopgate.io/v1/merchants/example/attributes \
--header 'Content-Type: application/json' \
--data '{ "attributes": [ { "type": "text", "isRequired": true, "name": "Favorite Pet", "code": "favoritePet", "visibility": "public", "displayGroup": "default", "values": [ { "name": "Dog", "code": "dog", "sequenceId": 0 }, { "name": "Fish", "code": "fish", "sequenceId": 1 }, { "name": "Cat", "code": "cat", "sequenceId": 2 }, { "name": "Rabbit", "code": "rabbit", "sequenceId": 3 } ] } ] }'

Create attributes

merchantCode
required
string
localeCode
string

Locale code to change the language of the attributes

Media typeapplication/json
object
attributes
required
Array<object>
object
type
required

Describes which type of validation to apply to an attribute’s value. “collectionOfValues” will check for an existing attribute value, the others will check for customer inputs to meet validation criteria of the suggested type (e.g. for type “boolean”, passing “123” will fail validation). The type cannot be changed once an attribute has been created.

string
Allowed values: text number boolean date collectionOfValues callingNumber
name
required

Name of the attribute which will be shown to the customer. It’s saved in the language of the passed locale.

string
Example
Color
isRequired
boolean
values
Array
object
code
required

Unique identifier for the attribute value

string
Example
black
sequenceId
required

Sequence id of the order of the values. The lowest number is at the top and the highest number is at the bottom.

number
Example
0
name
required

Name of the attribute value which will be shown to the customer. It’s saved in the language of the passed locale.

string
Example
Black
Example
{
"name": "Rabbit",
"code": "rabbit",
"sequenceId": 3
}
visibility

Controls the visibility of attributes on a customer

string
default: public
Allowed values: internal public
displayGroup

Controls display grouping of attributes

string | null
Example
[
{
"type": "text",
"isRequired": true,
"name": "Favorite Pet",
"code": "favoritePet",
"visibility": "public",
"displayGroup": "default",
"values": [
{
"name": "Dog",
"code": "dog",
"sequenceId": 0
},
{
"name": "Fish",
"code": "fish",
"sequenceId": 1
},
{
"name": "Cat",
"code": "cat",
"sequenceId": 2
},
{
"name": "Rabbit",
"code": "rabbit",
"sequenceId": 3
}
]
}
]

Attributes were created

Media typeapplication/json
object
errors
Array<object>
object
code
number
message
string
validationError

(optional) The original validation error that occured.

object
code
string
message
string
paramName
string
paramValue
string
entity
string
entityIndex

The index of the element the error refers to in the list of elements passed, starting from 0.

number
entityId
string
Example
{
"errors": [
{
"code": 409,
"message": "customer already exists",
"entity": "customer",
"entityIndex": 0,
"entityId": "7a81af64-a25d-11e9-8352-0bb2329f4819"
},
{
"code": 400,
"message": "Validation error.",
"validationError": {
"code": "INVALID_TYPE",
"message": "Request validation failed: Parameter (externalUpdateDate) at index 1 is not a valid date: today",
"paramName": "externalUpdateDate",
"paramValue": "today"
},
"entity": "customer",
"entityIndex": 1,
"entityId": null
}
]
}

Validation error

Media typeapplication/json
object
errors
Array<object>
object
field
required

The parameter-field, that failed to validate, like “shopNumber”

string
value

The value, that was sent, like “xxx”

string
code
required

Machine readable error code

string
Allowed values: ENUM_MISMATCH MAXIMUM MAXIMUM_EXCLUSIVE MINIMUM MINIMUM_EXCLUSIVE MULTIPLE_OF ARRAY_LENGTH_LONG ARRAY_LENGTH_SHORT ARRAY_ADDITIONAL_ITEMS ARRAY_UNIQUE MAX_LENGTH MIN_LENGTH MAX_PROPERTIES MIN_PROPERTIES OBJECT_MISSING_REQUIRED_PROPERTY OBJECT_PROPERTIES_MAXIMUM OBJECT_PROPERTIES_MINIMUM OBJECT_ADDITIONAL_PROPERTIES OBJECT_DEPENDENCY_KEY ONE_OF_MISSING ONE_OF_MULTIPLE NOT_PASSED INVALID_FORMAT UNKNOWN_FORMAT PATTERN
message
required

Human readable error code

string
Example
{
"errors": [
{
"code": "ENUM_MISMATCH"
}
]
}

Merchant not found

Media typeapplication/json

Unexpected error

Media typeapplication/json
object
code

Machine readable error code

string
message
required

Human readable error code

string
Examplegenerated
{
"code": "example",
"message": "example"
}