This section provides instructions for using the Create Attribute endpoint. This endpoint allows for the creation of attributes that can be assigned to a product or category.
Prerequisites
- Generate the access token by following the instructions in the "Getting Started with Ommni APIs" section.
Procedure
-
Open your preferred API testing tool or command-line interface.
-
To execute the API call, set the following headers in the request with their corresponding values and add the payload as in the example below:
Authorization
: Replace<Generated-access-token>
with the access token obtained from the previous steps.Content-Type
: Set this header toapplication/json
.
curl --location 'https://api.ommni.io/api-pim/v1/attributes' \
--header 'Authorization: Bearer <Generated-access-token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "exampleAttribute",
"description": "Example attribute for demonstration purposes",
"target": "PRODUCT",
"type": "TEXT",
"subType": "SMALL_TEXT",
"validations": {
"mandatory": false
},
"active": true,
"order": 0
}'
- This payload is just an example; you can edit it as required for your needs.
- Send a POST request to the https://api.ommni.io/api-pim/v1/attributes endpoint.
Upon successful request, a 201
status code response is returned, along with information about the newly created attribute, including its ID, name, description, and other details specified in the request.
{
"success": true,
"data": {
"name": "Product Name",
"description": "The name of the product",
"target": "PRODUCT",
"type": "TEXT",
"subType": "SMALL_TEXT",
"valueType": "string",
"optionsValues": [],
"validations": {
"mandatory": true,
"range": {
"min": 0,
"max": 0
}
},
"units": [],
"currencies": [],
"active": true,
"order": 1,
"createdAt": "2024-02-21T08:33:29.000Z",
"updatedAt": "2024-02-21T08:33:29.000Z",
"id": "65d5b558ed5dfe88f5e31277"
}
}
Note: Ensure to replace placeholder value like <Generated-access-token>
with actual value from your Ommni setup.