> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.warelycorp.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.warelycorp.com/_mcp/server.

# Archive Voucher

POST https://dev.warelypos.com/api/sp/vouchers/delete

Archives a voucher definition without removing historical usage.

Example curl:

```bash
curl --request POST '{{base_url}}/sp/vouchers/delete' \
  --header 'Authorization: Bearer {{access_token}}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "idempotency_key": "{{$timestamp}}-voucher-delete",
    "voucher_id": {{voucher_id}}
  }'
```

Example success response shape:

```json
{
  "success": true,
  "message": "Voucher archived successfully.",
  "data": {
    "voucher_id": 10,
    "archived": true
  },
  "meta": {}
}
```

Example error response shape:

```json
{
  "success": false,
  "message": "The same idempotency_key cannot be reused with a different payload.",
  "error": {
    "code": "idempotency_key_reused_with_different_payload",
    "details": {}
  }
}
```

Common platform errors:

* `idempotency_key_required`
* `sp_scope_not_granted`
* `sp_token_scope_missing`
* `sp_location_not_allowed`
* `legacy_field_not_allowed`
* `query_parameters_not_allowed`
* `invalid_content_type`

Reference: https://docs.warelycorp.com/api-reference/vouchers/archive-voucher

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `Authorization` (string, optional)

## Response

### 200

200 OK Example

- `success` (boolean, optional)
- `message` (string, optional)
- `data` (SpVouchersDeletePostResponsesContentApplicationJsonSchemaData, optional)
- `meta` (SpVouchersDeletePostResponsesContentApplicationJsonSchemaMeta, optional)

## Types

### SpVouchersDeletePostResponsesContentApplicationJsonSchemaData

- `voucher_id` (integer, optional)
- `archived` (boolean, optional)

### SpVouchersDeletePostResponsesContentApplicationJsonSchemaMeta

## Examples

**Response**

```json
{
  "success": true,
  "message": "Voucher archived successfully.",
  "data": {
    "voucher_id": 10,
    "archived": true
  },
  "meta": {}
}
```

**SDK Code**

```python Vouchers_archiveVoucher_example
import requests

url = "https://dev.warelypos.com/api/sp/vouchers/delete"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Vouchers_archiveVoucher_example
const url = 'https://dev.warelypos.com/api/sp/vouchers/delete';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Vouchers_archiveVoucher_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://dev.warelypos.com/api/sp/vouchers/delete"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Vouchers_archiveVoucher_example
require 'uri'
require 'net/http'

url = URI("https://dev.warelypos.com/api/sp/vouchers/delete")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Vouchers_archiveVoucher_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://dev.warelypos.com/api/sp/vouchers/delete")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Vouchers_archiveVoucher_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://dev.warelypos.com/api/sp/vouchers/delete', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Vouchers_archiveVoucher_example
using RestSharp;

var client = new RestClient("https://dev.warelypos.com/api/sp/vouchers/delete");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Vouchers_archiveVoucher_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://dev.warelypos.com/api/sp/vouchers/delete")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```