# Push classification tree

By
The Quable Team
Published 2023-09-10

Classification synchronisation
Create classifications
Edit classifications
Delete classifications


In order to import the hierarchy from your ERP, you will need to create and manage each of the individual classification hierarchy levels. To create the hierarchy shown below, you need to create the top levels first and the lower (sub)levels second.

This is a documents classification example
This is a documents classification example

This is an assets classification example
This is an assets classification example


# Classifications synchronisation

In accordance with the implementation you define, your hierarchy in Quable PIM will possibily be identical to your ERP categories.
Once this is set, you should consider synchronizing your classification hierarchy in order to place your documents in it.
There are two typical scenarios:

Use case Solution Pros / Cons
Your classification hierarchy is fixed or changes very little You don't need to run an automatic synchronization job, you can manage this manually. Less code and more human processing.
You can run a synchronization job but launch it manually More human processing but more reliable synchronization
Your classification hierarchy is not fixed or you want total control over the uploads You can synchronize your classifications before pushing the documents and variants Maximum control over imports

# Available endpoints overview

Let's say your ERP has documents in the breadcrumb "Tops > Sweaters". You can choose to create 2 classifications :

  • classification_tops
  • classification_sweaters

Below are the available endpoints to add, get or edit classifications:

Gather all the classifications for the PIM catalog:
GET /api/classifications?catalogs.id[]=PIM

Get a specific classification, if it already exists:
GET /api/classifications/classification_sweaters

Create a new classification, if it does not exist already:
POST /api/classifications

Update an existing classification:
PUT /api/classifications/classification_sweaters

Delete an existing classification:
DELETE /api/classifications/classification_sweaters


# Create classifications

To create classifications, you must know :

  • where it will be located in the hierarchy,
  • its unique identifier
  • its parent classification's unique identifier

You can also include attributes' values for the classification, in every locale.

# Endpoint

POST /api/classifications


# Body parameters

Attribute status Attribute name Type Description
Required id string The unique identifier of the classification to be created.
Required parent.id string The unique identifier of the parent classification. It defines its location in the hierarchy and is only required during classification creation
Accepted active boolean Usually, true
Accepted attributes object Any attribute code with its value(s) (e.g., name in the example below)

# Example

Create classifications
import requests
import json

url= "https://{{instance}}.quable.com.quable.com/api/classifications"
payload=json.dumps({
  "id": "classification_sweaters",
  "parent": {
    "id": "classification_tops"
  },
  "active": True,
  "attributes": {
    "quable_classification_name": {
      "en_US": "Sweaters",
      "fr_FR": "Pulls"
    }
  }
})
headers= {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer ...'
}

response= requests.request("POST", url, headers=headers, data=payload)

# Edit Classifications

To edit a classification, you must know the classification's unique identifier.

# Endpoint

PUT /api/classifications/[identifier]


# Query parameters

Query Parameter name Type Description
identifier string Current unique identifier of the classification to update.

# Body parameters

Attribute status Attribute name Type Description
Required id string The current or new identifier of the classification
Accepted parent.id string The unique identifier of the parent classification.
Accepted active boolean Usually, true
Accepted attributes object Any attribute code with its value(s) (e.g., name in the example below)

# Example

Edit classification
import requests
import json

url = "https://{{instance}}.quable.com/api/classifications/classification_sweaters"
payload = json.dumps({
  "id": "classification_sweaters",
  "active": True,
  "attributes": {
    "quable_classification_name": {
      "en_US": "Jumpers",
      "fr_FR": "Pullover"
    }
  }
})
headers = {
		'Content-Type': 'application/json',
		'Authorization': 'Bearer ...'
}

response = requests.request("PUT", url, headers=headers, data=payload)

# Delete Classifications

It may become necessary at some point to delete a classifcation from Quable PIM (e.g., to synchronize with a change in your ERP).
To delete a classification, you must identify the classification's unique identifier.


# Endpoint

/DELETE /api/classifications/[identifier]
'identifier' being the unique code of the classification to delete.


# Example

Delete classification
import requests

url = "https://{{instance}}.quable.com/api/classifications/classification_sweaters"
headers= {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer ...'
}

response= requests.request("DELETE", url, headers=headers)