# Delete usage

Use the **deleteSubscriptionUsages** method via SOAP API 6.0 to delete one or more usage entries based on the provided criteria.

## Request parameters

| Parameters                | Type   | Required                                          | Description                                                                                                          |
| ------------------------- | ------ | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **merchantCode**          | String | Required                                          | The system-generated merchant ID.                                                                                    |
| **sessionID**             | String | Required                                          | The system-generated code of the session.                                                                            |
| **hash**                  | String | Required                                          | The MD5 hmac key for the request.                                                                                    |
| **SubscriptionReference** | String | Required                                          | The system-generated reference code of the subscription.                                                             |
| **UsageReference**        | Number | Optional                                          | The system-generated code for usage.                                                                                 |
| **OptionCode**            | String | Optional                                          | Unique 2Checkout option code.                                                                                        |
| **IntervalStart**         | Number | Optional (mandatory if IntervalEnd is provided)   | Deletes all usages where UsageEnd >= IntervalStart. Format "YYYY-MM-DD". The timezone used is the one on the server. |
| **IntervalEnd**           | Number | Optional (mandatory if IntervalStart is provided) | Deletes all usages where UsageEnd <= IntervalEnd. Format "YYYY-MM-DD". The timezone used is the one on the server.   |

### Request sample

```php
<?php
require ('PATH_TO_AUTH'); // authentication call
$subscriptionReferencee = '4A1D733696';
$usageReference = 120010776516;

try {
    $subscriptionUsageRequest = new stdClass();
    $subscriptionUsageRequest->UsageReference = $usageReference;
    $subscriptionUsageRequest->OptionCode = 'Units 123';
    $subscriptionUsageRequest->IntervalStart = '2020-04-09 16:40:00';
    $subscriptionUsageRequest->IntervalEnd = '2020-04-12 15:40:00';
    $response = $client->deleteSubscriptionUsages($sessionID, $subscriptionReference, $subscriptionUsageRequest);
    var_dump($response);
} catch (SoapFault $ex) {
    $faultname = (isset($ex->faultname)) ? " $faultname" : '';
    echo "[$ex->faultcode]$faultname: $ex->faultstring" . PHP_EOL;
}

exit;
```

## Response

The **deleteSubscriptionUsages** method via SOAP APIv6 returns NULL when successful.

```
NULL
```

## Error Handling

The **deleteSubscriptionUsages** via SOAP APIv6 returns FALSE in error cases. Expand items below for details.

| Error message code                                                                                                                    | Error code            | Error message description                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------- |
| <p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p><strong>Provided parameters lack the required type or format.</strong></p> | MALFORMED\_PARAMETER  | One or more parameters lack the required format: SubscriptionReference must be a string.                              |
|                                                                                                                                       | MALFORMED\_PARAMETER  | One or more parameters lack the required format: UsageReference must be a positive integer higher than or equal to 1. |
|                                                                                                                                       | MALFORMED\_PARAMETER  | One or more parameters lack the required format: Units must be a positive integer higher than or equal to 1.          |
|                                                                                                                                       | MALFORMED\_PARAMETER  | One or more parameters lack the required format: IntervalStart must be a string.                                      |
|                                                                                                                                       | MALFORMED\_PARAMETER  | One or more parameters lack the required format: IntervalEnd must be a string.                                        |
| <p> </p><p><strong>The subscription or usage line are not found.</strong><br><br> </p>                                                | NOT\_FOUND            | Subscription not found.                                                                                               |
|                                                                                                                                       | NOT\_FOUND            | Usage line described does not exist.                                                                                  |
| **The usage line is already billed.**                                                                                                 | ALREADY\_BILLED       | Usage was not deleted as this usage was already billed.                                                               |
| **The renewal process is in progress for this subscription.**                                                                         | RENEWAL\_IN\_PROGRESS | There is a renewal in progress for the provided usage line.                                                           |
| **An unexpected error happens.**                                                                                                      | GENERIC               | There has been an error deleting the usage line. Please try again later.                                              |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.2checkout.com/soap-api-reference/soap-api-6.0/api-requests/usage-management/delete-usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
