# Reset the test data

`POST https://api.fiscalisto.com/v1/test_data/reset`

Leaves test mode as new: each test issuer keeps its RFC and its test CSD but loses its invoices, customers, products, batches, links and downloads, and the test events and request log are deleted. Keys and webhooks stay. With seed (the default) it leaves 2 sample customers and 3 sample products. Only with an fk_test_ key; production is never touched.

## Before you call

- **A test key** (`fk_test_`): this doesn't exist in production.
- **A key for the whole account**: not limited to some issuers or to a test environment.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header |  | Optional (the SDKs send it on their own). If the response is lost, repeat the request with the same value within 24 hours: it answers the same, with idempotent-replayed: true, and doesn't do it twice (it doesn't create, send emails or charge). |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `seed` | boolean |  | true (the default) to leave each test issuer 2 sample customers and 3 sample products. false to leave it empty. (default true) |

Example:

```json
{
  "seed": true
}
```

## With the TypeScript SDK

```ts
import { Fiscalisto } from "fiscalisto";

// La llave viene de FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const testDataReset = await fiscalisto.testData.reset({ seed: true }, { idempotencyKey: "pedido-A-1042" });
```

## With the Python SDK

```python
from fiscalisto import Fiscalisto

# La llave viene de FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

test_data_reset = fiscalisto.test_data.reset({"seed": True}, idempotency_key="pedido-A-1042")
```

## With the PHP SDK

```php
<?php

use Fiscalisto\Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$testDataReset = $fiscalisto->testData->reset(['seed' => true], ['idempotency_key' => 'pedido-A-1042']);
```

## With the .NET SDK

```csharp
using Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var testDataReset = await fiscalisto.TestData.ResetAsync(new ResetTestDataParams { Seed = true }, new RequestOptions { IdempotencyKey = "pedido-A-1042" });
```

## With the Go SDK

```go
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// La llave viene de FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	testDataReset, err := client.TestData.Reset(ctx, &fiscalisto.ResetTestDataParams{Seed: fiscalisto.Bool(true)}, fiscalisto.WithIdempotencyKey("pedido-A-1042"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", *testDataReset)
}
```

## With the Java SDK

```java
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.ResetTestDataParams;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var testDataReset = fiscalisto.testData().reset(new ResetTestDataParams().setSeed(true), RequestOptions.idempotencyKey("pedido-A-1042"));
System.out.println(testDataReset);
```

## Response 200

OK.

A `TestDataReset` object:

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `object` | `"test_data_reset"` | yes | What kind of object it is («invoice», «customer»…). |
| `livemode` | `false` | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `issuers` | integer | yes | How many test issuers were emptied (archived ones included). (from -9007199254740991 to 9007199254740991) |
| `deleted_rows` | integer | yes | How many records were deleted: invoices, customers, products, batches, links, downloads… (from -9007199254740991 to 9007199254740991) |
| `deleted_events` | integer | yes | How many test events were deleted (with their deliveries). (from -9007199254740991 to 9007199254740991) |
| `customers_created` | integer | yes | Sample customers created (with seed). (from -9007199254740991 to 9007199254740991) |
| `products_created` | integer | yes | Sample products created (with seed). (from -9007199254740991 to 9007199254740991) |

```json
{
  "object": "test_data_reset",
  "livemode": false,
  "issuers": 1,
  "deleted_rows": 214,
  "deleted_events": 37,
  "customers_created": 2,
  "products_created": 3
}
```

## Errors

- `daily_limit` (429): You reached today's limit of something not paid with stamps. Retry-After says how many seconds until midnight in Mexico City.
- `key_restricted` (403): This key is limited to some issuers and the request touches another one (or creates one, or uses something of the whole account, like webhooks).
- `test_mode_only` (400): This exists only in test mode: use your fk_test_ key.

Plus those of any call (key, fields, limits): https://fiscalisto.com/en/docs/api/errores.md.
