# Start afresh

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Restart the time machine. This will clear the "customer" data like customer details, subscriptions, invoices, transactions. Also a time travel is initiated to travel back to specified genesis time.

**Note:** This API call is asynchronous.

You need to check if the "start afresh" operation has completed by checking if the time travel status is **successful** by retrieving the time machine in a loop with a minimum delay of 3 secs between two retrieve requests. In case you are using any of the client libraries, use the **wait for time travel completion** function provided as a instance method in the library.

Use method **waitForTimeTravelCompletion()** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **waitForTimeTravelCompletion()** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **wait\_for\_time\_travel\_completion** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **wait\_for\_time\_travel\_completion** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **WaitForTimeTravelCompletion** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **wait\_for\_time\_travel\_completion** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **waitForTimeTravelCompletion** on the returned **time\_machine** resource which will block until the time travel completes.

Use method **wait\_for\_time\_travel\_completion** on the returned **time\_machine** resource which will block until the time travel completes.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/time_machines/delorean/start_afresh \
     -X POST  \
     -u {site_api_key}:
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = TimeMachine.StartAfresh("delorean").Request();

TimeMachine timeMachine = result.TimeMachine;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    timemachineAction "github.com/chargebee/chargebee-go/v3/actions/timemachine"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := timemachineAction.StartAfresh("delorean", nil).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        TimeMachine := res.TimeMachine
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.TimeMachineStartAfreshRequest{}
  res, err := client.TimeMachine.StartAfresh("delorean", req)
      if err != nil {
        fmt.Println(err)
    } else {
        TimeMachine := res.TimeMachine
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = TimeMachine.startAfresh("delorean").request();

        TimeMachine timeMachine = result.timeMachine();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.timeMachine.TimeMachine;
import com.chargebee.v4.models.timeMachine.params.TimeMachineStartAfreshParams;
import com.chargebee.v4.models.timeMachine.responses.TimeMachineStartAfreshResponse;

public class TimeMachineStartAfresh {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        TimeMachineStartAfreshResponse response = client.timeMachines().startAfresh("delorean");

        TimeMachine timeMachine = response.getTimeMachine();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.timeMachine.startAfresh("delorean");

    console.log(result);
    const timeMachine = result.time_machine;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->timeMachine()->startAfresh("delorean");
$timeMachine = $result->time_machine;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.TimeMachine.start_afresh("delorean")
time_machine = response.time_machine
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::TimeMachine.start_afresh("delorean")

time_machine = result.time_machine
```

## Sample Response

```json
{
  "time_machine": {
    "destination_time": 1585066228,
    "genesis_time": 1585066228,
    "name": "delorean",
    "object": "time_machine",
    "time_travel_status": "in_progress"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/time_machines/{time-machine-name}/start_afresh

## Input Parameters

- `genesis_time` (optional, timestamp(UTC) in seconds)
  The genesis time to travel back as part of the reset operation. If not provided, then the travel is set to 6 months in the past.
  
  **Note:** Can only be in the past.

## Returns

- `time_machine` (Time machine object)
  Resource object representing time\_machine
