Skip to content

Create Attribute

Create a new product attribute for a category.

Endpoint

POST /v1/products/attribute/

Authentication

Required (Admin role)

Request Body

{
  "name_az": "Rəng",
  "name_en": "Color",
  "name_es": "Color",
  "name_de": "Farbe",
  "type": "2",
  "values_az": "[{\"name\":\"Qırmızı\"},{\"name\":\"Mavi\"},{\"name\":\"Yaşıl\"}]",
  "values_en": "[{\"name\":\"Red\"},{\"name\":\"Blue\"},{\"name\":\"Green\"}]",
  "values_es": "[{\"name\":\"Rojo\"},{\"name\":\"Azul\"},{\"name\":\"Verde\"}]",
  "values_de": "[{\"name\":\"Rot\"},{\"name\":\"Blau\"},{\"name\":\"Grün\"}]",
  "options_api": "",
  "category_id": 1,
  "is_filter": true,
  "is_view": true
}

Parameters

Field Type Required Description Validation
name string No Deprecated fallback (API derives from name_en) -
name_az string No Attribute name in Azerbaijani -
name_en string Yes Attribute name in English (stored as fallback name) Not empty
name_es string No Attribute name in Spanish -
name_de string No Attribute name in German -
type string Yes Attribute type One of: "1" (text), "2" (select), "3" (checkbox), "4" (date)
values string No JSON array of values (legacy fallback) -
values_az string No JSON array of values in Azerbaijani -
values_en string No JSON array of values in English (stored as fallback) -
values_es string No JSON array of values in Spanish -
values_de string No JSON array of values in German -
options_api string No API endpoint for dynamic options -
category_id integer Yes Category ID Must exist
is_filter boolean No Whether attribute can be used for filtering Default: true
is_view boolean No Whether attribute should be displayed Default: false

Response

Success (200 OK)

{
  "id": 1,
  "name": "Color",
  "name_az": "Rəng",
  "name_en": "Color",
  "name_es": "Color",
  "name_de": "Farbe",
  "type": "select",
  "values": [
    {"name": "Qırmızı"},
    {"name": "Mavi"},
    {"name": "Yaşıl"}
  ],
  "options_api": "",
  "category_id": 1,
  "category": {
    "id": 1,
    "name": "Elektronika",
    "name_az": "Elektronika",
    "name_en": "Electronics",
    "name_es": "Electrónica",
    "name_de": "Elektronik",
    "image": "https://...",
    "parent_id": null
  },
  "is_filter": true,
  "is_view": true,
  "created": "2025-01-15T10:30:00Z"
}

Error Responses

Category Not Found (404)

{
  "error": "Category Not Found"
}

Invalid Type (400)

{
  "message": "Type Not Found!"
}

Example Request

curl -X POST "https://api.luxmart.site/v1/products/attribute/" \
  -H "Authorization: Token your_access_token" \
  -H "Content-Type: application/json" \
  -d '{
    "name_az": "Rəng",
    "name_en": "Color",
    "name_es": "Color",
    "name_de": "Farbe",
    "type": "2",
    "values": "[{\"name\":\"Qırmızı\"},{\"name\":\"Mavi\"},{\"name\":\"Yaşıl\"}]",
    "category_id": 1,
    "is_filter": true,
    "is_view": true
  }'

Notes

  • Attribute type must be one of the valid types: "1", "2", "3", "4"
  • Category must exist and not be deleted
  • Values fields are JSON array strings for select/checkbox attributes. Provide values_en (preferred) and optional values_az, values_es, values_de. The API stores English as the fallback values and also returns values, values_en, values_az, values_es, values_de.
  • Translation Support: Provide name_en (required) plus optional name_az, name_es, name_de. The API stores English as the fallback name automatically.
  • The name field is kept for backward compatibility; you do not need to send it.