# Delete usage

Use the **deleteSubscriptionUsages** method via JSON-RPC API 6.0 to delete usage entered for a specific subscription, price options group, and usage interval.

## Request parameters

<table><thead><tr><th width="221.4666748046875">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>merchantCode</code></td><td><p><strong>Required (string)</strong></p><p>The system-generated merchant ID.</p></td></tr><tr><td><code>sessionID</code></td><td><strong>Required (string)</strong><br>The system-generated code of the session.</td></tr><tr><td><code>hash</code></td><td><strong>Required (string)</strong><br>The MD5 hmac key for the request.</td></tr><tr><td><code>SubscriptionReference</code></td><td><strong>Required (string)</strong><br>Unique code that represents a subscription. Example: 83FE4FEF2.</td></tr><tr><td><code>UsageReference</code></td><td><strong>Optional (number)</strong><br>The system-generated reference code for the usage of the subscription.</td></tr><tr><td><code>OptionCode</code></td><td><p><strong>Optional (string)</strong></p><p>Unique 2Checkout option code. The pay-per-usage price options group for which the usage is uploaded. Example: metered pricing.</p></td></tr><tr><td><code>IntervalStart</code></td><td><p><strong>Optional (datetime)</strong></p><p><strong>(mandatory if IntervalEnd is provided)</strong></p><p>Deletes all usages where <code>UsageEnd</code> >= <code>IntervalStart</code>. Format "YYYY-MM-DD". The timezone used is the one on the server.</p></td></tr><tr><td><code>IntervalEnd</code></td><td><p><strong>Optional (datetime)</strong></p><p><strong>(mandatory if IntervalStart is provided)</strong></p><p>Deletes all usages where <code>UsageEnd</code> &#x3C;= <code>IntervalEnd</code>. Format "YYYY-MM-DD". The timezone used is the one on the server.</p></td></tr></tbody></table>

### Request Sample

```php
<?php
require ('PATH_TO_AUTH'); // authentication call
$SubscriptionReference = 'B7D8E72224';
$UsageReference = 120010776516;
$jsonRpcRequest = array('jsonrpc' => '2.0', 'method' => 'deleteSubscriptionUsages', 'params' => array($sessionID, 'SubscriptionReference' => $SubscriptionReference, array("UsageReference" => $UsageReference, "OptionCode" => 'USG_MN', "IntervalStart" => "2018-04-14 13:00:10", "IntervalEnd" => "2020-09-16 13:00:10")), 'id' => $i++);
var_dump ("deleteSubscriptionUsages", callRPC((Object)$jsonRpcRequest, $host));
```

## Response

The **deleteSubscriptionUsages** method via JSON-RPC APIv6 returns NULL when successful.

```php
class stdClass#3 (3) {
  public $code =>
  int(0)
  public $message =>
  string(46) ""
  public $data =>
  NULL
}
```

## Error handling

The **deleteSubscriptionUsages** via JSON-RPC APIv6 returns FALSE if:

| Error message code                                            | Error code            | Error message description                                                                                               |
| ------------------------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Provided parameters lack the required type or format.**     | 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.                                        |
| **The subscription or usage line are not found.**             | 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/json-rpc-api-reference/json-rpc-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.
