# 4.1 Delete classification

<mark style="color:red;">`DELETE`</mark> `/documentClassification/deleteClassification`

This endpoint permanently deletes an entire document classification process, including all associated batches, results, and uploaded files.

You must provide only the `classificationId` in the request body. This action is irreversible and removes all data linked to the specified classification.

Use this endpoint when you intend to fully decommission a classification and all its related content. Separate endpoints are available for deleting individual batches or files.

## Server URL

```
https://api.extracta.ai/api/v1
```

## Headers

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

## Body

<table><thead><tr><th width="183">Name</th><th width="135">Type</th><th width="164">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>classificationId</code></td><td>string</td><td><code>true</code></td><td>The classification id.</td></tr></tbody></table>

## Body Example

```json
{
    "classificationId": "classificationId"
}
```

## Code Example

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

async function deleteClassification(token, classificationId) {
    const url = "https://api.extracta.ai/api/v1/documentClassification/deleteClassification";

    try {
        const response = await axios.delete(url, {
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${token}`
            },
            data: {
                classificationId: classificationId
            }
        });

        return response.data;
    } catch (error) {
        throw error.response ? error.response.data : new Error('An unknown error occurred');
    }
}

async function main() {
    const token = 'apiKey';
    const classificationId = 'classificationId';

    try {
        const response = await deleteClassification(token, classificationId);
        console.log("Classification Deleted:", response);
    } catch (error) {
        console.error("Failed to delete classification:", error);
    }
}

main();
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

def delete_classification(token, classification_id):
    url = "https://api.extracta.ai/api/v1/documentClassification/deleteClassification"
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {token}"
    }
    payload = {
        "classificationId": classification_id
    }

    try:
        response = requests.delete(url, json=payload, headers=headers)
        response.raise_for_status()
        return response.json()
    except requests.RequestException as e:
        print(f"Failed to delete classification: {e}")
        return None

# Example usage
if __name__ == "__main__":
    token = "apiKey"
    classification_id = "classificationId"

    response = delete_classification(token, classification_id)
    if response:
        print("Classification Deleted:", response)
    else:
        print("Failed to delete classification.")
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

function deleteClassification($token, $classificationId) {
    $url = 'https://api.extracta.ai/api/v1/documentClassification/deleteClassification';

    // Initialize cURL session
    $ch = curl_init($url);

    // Prepare the payload
    $payload = json_encode(['classificationId' => $classificationId]);

    // Set cURL options
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $token,
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    try {
        $response = curl_exec($ch);

        if (curl_errno($ch)) {
            throw new Exception('Curl error: ' . curl_error($ch));
        }

        return $response;
    } catch (Exception $e) {
        return 'Error: ' . $e->getMessage();
    } finally {
        curl_close($ch);
    }
}

// Example usage
$token = 'apiKey';
$classificationId = 'classificationId';

try {
    $response = deleteClassification($token, $classificationId);
    echo "Classification Deleted: " . $response;
} catch (Exception $e) {
    echo "Failed to delete classification: " . $e->getMessage();
}

?>
```

{% endtab %}
{% endtabs %}

## Responses

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "message": "Classification deleted"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "success",
    "message": "Classification deleted"
}
```

{% endtab %}

{% tab title="500" %}

```json
{
    "status": "error",
    "message": "Internal server error"
}
```

{% endtab %}
{% endtabs %}
