API Version
Product Catalog
Library

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: In order to use Time Machine via API , you need to first "enable" the Time Travel option which is available under Settings > Configure Chargebee > Time Machine.

Sample time machine [ JSON ]

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

API Index URL GET

https://{site}.chargebee.com/api/v2/time_machines

Model Class

<cb_client>.TimeMachine
name
string, default=delorean, max chars=50
The name of the time machine. Currently only delorean is allowed
time_travel_status
enumerated string, default=not_enabled
The current status of time travel
Possible values are
not_enabledTime travel has not been enabled for the sitein_progressTime travel is in progresssucceededTime 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.
not_enabledTime travel has not been enabled for the sitein_progressTime travel is in progresssucceededTime 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.
Show all values[+]
genesis_time
timestamp(UTC) in seconds
The start time of the time machine. Specified when 'starting afresh'
destination_time
timestamp(UTC) in seconds
The destination time to which the time machine is travelling (or has traveled)
failure_code
optional, string, max chars=250
The failure code. This will follow the api error code convention
failure_reason
optional, string, max chars=250
The more descriptive failure reason.
error_json
optional, string, max chars=1000
The failure details as error json.
name name
string, default=delorean, max chars=50
The name of the time machine. Currently only delorean is allowed
time_travel_status time_travel_status
enumerated string, default=not_enabled
The current status of time travel
Possible values are
not_enabledTime travel has not been enabled for the sitein_progressTime travel is in progresssucceededTime 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.
not_enabledTime travel has not been enabled for the sitein_progressTime travel is in progresssucceededTime 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.
Show all values[+]
genesis_time genesis_time
timestamp(UTC) in seconds
The start time of the time machine. Specified when 'starting afresh'
destination_time destination_time
timestamp(UTC) in seconds
The destination time to which the time machine is travelling (or has traveled)
failure_code failure_code
optional, string, max chars=250
The failure code. This will follow the api error code convention
failure_reason failure_reason
optional, string, max chars=250
The more descriptive failure reason.
error_json error_json
optional, string, max chars=1000
The failure details as error json.
Retrieves the time machine. Currently only one time machine is available per site and is named 'delorean'.

Notes

Sample Codes
from chargebee import Chargebee

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

copy
Click to Copy
from chargebee import Chargebee

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

Sample Result [ JSON ]

Show more...
{
    "time_machine": {
        "destination_time": 1585065021,
        "genesis_time": 1585065021,
        "name": "delorean",
        "object": "time_machine",
        "time_travel_status": "succeeded"
    }
}

URL Format GET

https://{site}.chargebee.com/api/v2/time_machines/{time-machine-name}

Method

<cb_client>.TimeMachine.retrieve(<time_machine_name>,{<param name> : <value>,<param name> : <value> ...})
time_machine time_machine
always returned
Resource object representing time_machine

Sample admin console URL

https://{site}.chargebee.com/admin-console/time_machines/123x

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. Use method wait_for_time_travel_completion on the returned time_machine resource which will block until the time travel completes.

Notes

Sample Codes
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

copy
Click to Copy
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

Sample Result [ JSON ]

Show more...
{
    "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

Method

<cb_client>.TimeMachine.start_afresh(<time_machine_name>,{<param name> : <value>,<param name> : <value> ...})
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.
time_machine time_machine
always returned
Resource object representing time_machine

Sample admin console URL

https://{site}.chargebee.com/admin-console/time_machines/123x

Travel forward in time. This operation is asynchronous.

Notes

Sample Codes
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.TimeMachine.travel_forward("delorean",
    cb_client.TimeMachine.TravelForwardParams(
        destination_time=1586274640
    )
)
time_machine = response.time_machine

copy
Click to Copy
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.TimeMachine.travel_forward("delorean",
    cb_client.TimeMachine.TravelForwardParams(
        destination_time=1586274640
    )
)
time_machine = response.time_machine

Sample Result [ JSON ]

Show more...
{
    "time_machine": {
        "destination_time": 1586274640,
        "genesis_time": 1585066234,
        "name": "delorean",
        "object": "time_machine",
        "time_travel_status": "in_progress"
    }
}

URL Format POST

https://{site}.chargebee.com/api/v2/time_machines/{time-machine-name}/travel_forward

Method

<cb_client>.TimeMachine.travel_forward(<time_machine_name>,{<param name> : <value>,<param name> : <value> ...})
destination_time[]
optional, timestamp(UTC) in seconds
The time to travel to. Should be between the 'current' destination time of the time machine and present time.
time_machine time_machine
always returned
Resource object representing time_machine

Sample admin console URL

https://{site}.chargebee.com/admin-console/time_machines/123x