Time Machine is a simulation feature which imitates the key characteristics, behaviours and functions of the billing configurations. It is a virtual time travelling tool which facilitates the integration testing process by carrying out subscription renewals, dunning, webhooks etc on a hypothetical time frame.

You can use Time Machine in the test site to verify if the billing rules configured in your site adhere to your expectations before executing them in real time. This feature can be used in both API and UI versions.

View this doc for more details.

Note: Inorder to use the TimeMachine via API , you need to first "enable" the Time Travel option which is available under the "Settings"-> "Configuration & Data" option.

Sample time machine [ JSON ]

{ "name": "delorean", "time_travel_status": "succeeded", "genesis_time": 1490020019, "destination_time": 1505917619, "object": "time_machine" }

API Index URL GET

https://{site}.chargebee.com/api/v2/time_machines
name
The name of the time machine. Currently only delorean is allowed.
string, default=delorean, max chars=50
time_travel_status
The current status of time travel.
enumerated string, default=not_enabled
Possible values are
not_enabledTime travel has not been enabled for the site.in_progressTime travel is in progress.succeededTime travel has succeeded.failedTime travel has failed. Check the failure code and failure reason attributes for further details.
Note: The time machine needs to be reset by starting afresh again.
genesis_time
The start time of the time machine. Specified when 'starting afresh'.
timestamp(UTC) in seconds
destination_time
The destination time to which the time machine is travelling (or has traveled).
timestamp(UTC) in seconds
failure_code
The failure code. This will follow the api error code convention.
optional, string, max chars=250
failure_reason
The more descriptive failure reason.
optional, string, max chars=250
error_json
The failure details as error json.
optional, string, max chars=1000
Retrieves the time machine. Currently only one time machine is available per site and is named 'delorean'.
Sample Request
curl  https://{site}.chargebee.com/api/v2/time_machines/delorean \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/time_machines/delorean \
     -u {site_api_key}:

Sample Response [ JSON ]

{"time_machine": { "name": "delorean", "time_travel_status": "succeeded", "genesis_time": 1490020064, "destination_time": 1505917664, "object": "time_machine" }}

URL Format GET

https://{site}.chargebee.com/api/v2/time_machines/{time_machine_name}
Resource object representing time_machine.
always returned

Restart the timemachine. 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 TimeMachine resource which will block until the time travel completes. Use method waitForTimeTravelCompletion() on the returned TimeMachine 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 TimeMachine 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  https://{site}.chargebee.com/api/v2/time_machines/delorean/start_afresh \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/time_machines/delorean/start_afresh \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"time_machine": { "name": "delorean", "time_travel_status": "in_progress", "genesis_time": 1490020064, "destination_time": 1505917664, "object": "time_machine" }}

URL Format POST

https://{site}.chargebee.com/api/v2/time_machines/{time_machine_name}/start_afresh
genesis_time
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.
optional, timestamp(UTC) in seconds
Resource object representing time_machine.
always returned

Travel forward in time. This operation 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. Use method waitForTimeTravelCompletion() on the returned time_machine resource which will block until the time travel completes.

Sample Request
curl  https://{site}.chargebee.com/api/v2/time_machines/delorean/travel_forward \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/time_machines/delorean/travel_forward \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"time_machine": { "name": "delorean", "time_travel_status": "in_progress", "genesis_time": 1490020064, "destination_time": 1505917664, "object": "time_machine" }}

URL Format POST

https://{site}.chargebee.com/api/v2/time_machines/{time_machine_name}/travel_forward
destination_time
The time to travel to. Should be between the 'current' destination time of the timemachine and present time.
optional, timestamp(UTC) in seconds
Resource object representing time_machine.
always returned