Update Classifier
Modify an existing Classifier — update its name, label set, model, or page range. Only the fields you include in the request body are updated; omitted fields retain their current values.
API Endpoint
PUT https://api.documentpro.ai/v1/classifiers/{classifier_id}
Path Parameters
classifier_id(required): The unique identifier of the Classifier to update.
Headers
x-api-key(required): Your API key for authentication.Content-Type: application/json
Request Body
All fields are optional. Include only the fields you want to change.
| Field | Type | Description |
|---|---|---|
name | string | New name for the classifier. |
configs | object | Updated classification settings. See Create Classifier for the full configs schema. |
Example Implementation
Using cURL
curl --location --request PUT 'https://api.documentpro.ai/v1/classifiers/f47ac10b-58cc-4372-a567-0e02b2c3d479' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"name": "Document Type Router v2",
"configs": {
"classes": [
{ "label": "invoice", "description": "A document requesting payment for goods or services rendered" },
{ "label": "purchase_order", "description": "A buyer-issued document authorizing a purchase from a supplier" },
{ "label": "contract", "description": "A legally binding agreement between two or more parties" },
{ "label": "receipt", "description": "A confirmation of payment already made" },
{ "label": "other", "description": "Any document that does not fit the above categories" }
],
"query_model": "gpt-4o"
}
}'
Using Python
import requests
import json
classifier_id = "f47ac10b-58cc-4372-a567-0e02b2c3d479"
url = f"https://api.documentpro.ai/v1/classifiers/{classifier_id}"
headers = {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
payload = {
"name": "Document Type Router v2",
"configs": {
"classes": [
{ "label": "invoice", "description": "A document requesting payment for goods or services rendered" },
{ "label": "purchase_order", "description": "A buyer-issued document authorizing a purchase from a supplier" },
{ "label": "contract", "description": "A legally binding agreement between two or more parties" },
{ "label": "receipt", "description": "A confirmation of payment already made" },
{ "label": "other", "description": "Any document that does not fit the above categories" }
],
"query_model": "gpt-4o"
}
}
response = requests.put(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
result = response.json()
print(f"Classifier updated: {result['name']}")
else:
print('Failed to update classifier')
print(response.text)
Response
Successful Response (Status Code: 200)
{
"classifier_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"name": "Document Type Router v2",
"user_id": "4449b25a-9bba-4de4-be67-c06233d2f305",
"configs": {
"classifier_type": "document",
"classes": [
{ "label": "invoice", "description": "A document requesting payment for goods or services rendered" },
{ "label": "purchase_order", "description": "A buyer-issued document authorizing a purchase from a supplier" },
{ "label": "contract", "description": "A legally binding agreement between two or more parties" },
{ "label": "receipt", "description": "A confirmation of payment already made" },
{ "label": "other", "description": "Any document that does not fit the above categories" }
],
"query_model": "gpt-4o",
"page_range": "1-2",
"use_ocr": true
},
"created_at": "2024-07-25T14:16:44.540197",
"updated_at": "2024-08-01T09:22:11.381004"
}
Error Response (Status Codes: 400, 403, 404, 500)
{
"success": false,
"error": "error_code",
"message": "descriptive error message"
}
Next Steps
- Run Classification with the updated classifier.
- Delete this Classifier if it is no longer needed.