Test clocks
A test clock is a sandbox clock that you control. Customers created on a test clock, and their subscriptions, read the clock's frozen_at as the current time instead of real time. Use a test clock to check what your integration does when a trial ends, a renewal charges, or a payment retry runs, without waiting days or weeks for it to happen.
Test clocks exist only in sandboxes. Every test clock route needs a test-mode credential: a live credential gets 403 FORBIDDEN with details[0].reason test_mode_required, whatever scopes it holds. Listing and retrieving clocks requires developer.test_clocks.read or developer.test_clocks.write. Creating, advancing, and archiving them requires developer.test_clocks.write. Both scopes can be granted to live keys, so a live key can grant them to the sandbox keys it creates, but the routes themselves only accept test credentials.
Create a test clock#
POST /v1/test-clocks creates a clock with status ready, stopped at frozen_at. Both fields are optional.
curl -X POST https://api.withflintpay.com/v1/test-clocks \
-H "Authorization: Bearer flint_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"frozen_at": "2026-11-01T00:00:00Z",
"name": "Annual renewal test"
}'
frozen_at defaults to the time of the request. Fractional seconds are dropped. It can be up to 5 years after the request time, and no more than 1 hour before it, to allow for clock skew on your side. A value outside that range returns 400 INVALID_REQUEST with param: "frozen_at". name is your label, from 1 to 255 characters.
A new clock has version 1 and sends test_clock.created. There's no limit on the number of clocks in a sandbox.
List and retrieve test clocks#
curl "https://api.withflintpay.com/v1/test-clocks?status=ready&status=archived" \
-H "Authorization: Bearer flint_test_YOUR_KEY"
GET /v1/test-clocks returns the sandbox's clocks, newest first, then by test_clock_id descending. Set page_size from 1 to 100, with 20 by default, and pass next_page_token as the next request's page_token. Archived clocks are left out unless the status filter names archived. Repeat status, or send comma-separated values, to match several statuses.
curl https://api.withflintpay.com/v1/test-clocks/tclk_01K8ABCDEF0123456789ABCDEF \
-H "Authorization: Bearer flint_test_YOUR_KEY"
GET /v1/test-clocks/{test_clock_id} returns a clock in this sandbox, including an archived one. A clock in another sandbox returns 404 RESOURCE_NOT_FOUND with param: "test_clock_id", the same as an unknown ID.
Advance a test clock#
curl -X POST https://api.withflintpay.com/v1/test-clocks/tclk_01K8ABCDEF0123456789ABCDEF/advance \
-H "Authorization: Bearer flint_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: advance-renewal-test-1" \
-d '{
"frozen_at": "2026-12-01T00:00:00Z",
"expected_version": 1
}'
POST /v1/test-clocks/{test_clock_id}/advance moves a ready clock forward to frozen_at. Flint returns 202 with the clock in status advancing: frozen_at already shows the new time, and version has increased by 1. Flint then moves the clock's customers and their subscriptions to that time, running each trial end, renewal, notice, and payment retry that falls due along the way, in order, with the webhooks and emails they normally send. Fractional seconds in frozen_at are dropped. expected_version is optional, and an Idempotency-Key makes a retried request return the original response instead of starting another advance.
The advance is finished when the clock leaves advancing. To find out when:
- Listen for
test_clock.ready, ortest_clock.failedif Flint couldn't finish. - Or read
GET /v1/test-clocks/{test_clock_id}untilstatusisreadyorfailed.
Flint records test_clock.ready after every event the advance caused. Deliveries can still arrive in any order, but once the clock is ready, GET /v1/webhook-events lists every one of them.
How an advance runs#
Flint moves the clock in steps. Each step is the next time a subscription on the clock is due to do something, such as end a trial, renew, send a notice, or retry a payment. At each step, every subscription on the clock finishes what fell due, including any charge, before the clock moves to the next step. The last step is the new frozen_at.
A subscription canceled during the advance takes no further steps. If billing for a subscription on the clock has stopped running, Flint restarts it at the clock's time and runs the step again.
How far one advance can go#
One advance can reach the earliest of these times:
- 2 years after the clock's current
frozen_at. - 2 billing intervals after it, for each subscription on the clock that isn't canceled. A monthly subscription allows 2 months, and a subscription billed every 2 weeks allows 4 weeks.
Months and years are added in UTC. To move further, advance to the limit, wait for ready, then advance again. A request past the limit returns maximum_frozen_at, the latest time you can send.
Errors#
Flint checks an advance in this order and returns the first error that applies.
| Response | When |
|---|---|
400 INVALID_REQUEST | frozen_at is missing or isn't an RFC 3339 time, expected_version isn't a positive integer, or the body has a field the route doesn't accept. |
404 RESOURCE_NOT_FOUND | No clock with this ID exists in the sandbox. param is test_clock_id. |
409 VERSION_CONFLICT | expected_version doesn't match the clock's version. The error includes the current version. |
409 ACTION_NOT_ALLOWED with reason: "in_progress" | The clock is advancing. Wait until it's ready. |
409 ACTION_NOT_ALLOWED with reason: "terminal_status" | The clock is failed. Archive it and create a new one. |
409 ACTION_NOT_ALLOWED with reason: "archived" | The clock is archived and never advances. |
409 ACTION_NOT_ALLOWED with reason: "frozen_at_not_later" | frozen_at isn't later than the clock's current frozen_at. Test clocks only move forward. param is frozen_at. |
409 ACTION_NOT_ALLOWED with reason: "advance_limit_exceeded" | frozen_at is later than one advance can reach. param is frozen_at, and maximum_frozen_at is the latest time you can send. |
The status refusals carry current_status. The last two don't, because the request's frozen_at is the problem, not the clock's status.
When an advance fails#
The clock becomes failed and Flint sends test_clock.failed when an advance can't finish. Typical causes:
- A subscription on the clock doesn't finish a step after 10 attempts of up to 5 minutes each. This happens when it waits for something that runs in real time, such as a bank debit that is still processing, or a retry after a temporary error.
- Billing for a subscription on the clock stopped running, and Flint couldn't restart it.
- The advance needs more than 1,000 steps. Each distinct time a subscription on the clock wakes up to bill or send a notice is one step.
- The advance runs for more than 2 hours of real time.
Resources on a failed clock may have processed only part of the advance. A failed clock can't advance again: archive it and create a new one.
Archive a test clock#
curl -X DELETE "https://api.withflintpay.com/v1/test-clocks/tclk_01K8ABCDEF0123456789ABCDEF?expected_version=1" \
-H "Authorization: Bearer flint_test_YOUR_KEY"
DELETE /v1/test-clocks/{test_clock_id} archives the clock and returns it with status archived. The clock stays readable by ID, never advances again, and no new customer can be created on it. Customers and subscriptions already on it don't change: they keep the clock's frozen_at as their current time, so their subscriptions don't bill again. Cancel those subscriptions first if you want them canceled, or reset the sandbox to remove everything.
Status before DELETE | Result |
|---|---|
ready or failed | 200 with status archived. version increases by 1 and Flint sends test_clock.archived. |
archived | 200 with the clock unchanged. No event is sent. |
advancing | 409 ACTION_NOT_ALLOWED with current_status: "advancing" and reason: "in_progress". Wait until the clock is ready or failed. |
expected_version is optional. If it doesn't match the clock's version, the request returns 409 VERSION_CONFLICT with the current version and changes nothing.
The test clock resource#
| Field | Behavior |
|---|---|
test_clock_id | The clock's ID, beginning with tclk_. |
name | Your label. Omitted when you didn't set one. |
status | ready, advancing, failed, or archived. See statuses. |
frozen_at | The time the clock shows. Customers on the clock and their subscriptions treat it as the current time. During an advance it is already the time the clock is moving to. |
created_at, updated_at | When the clock was created and last changed, in real time. |
version | Increases when the clock is created, when an advance starts, when it finishes or fails, and when the clock is archived. Send it as expected_version to require the version you read. |
Statuses#
| Status | Meaning |
|---|---|
ready | Stopped at frozen_at. You can advance it and create customers on it. |
advancing | Flint is moving the clock's customers and their subscriptions to frozen_at, running the billing that falls due along the way, in order. Until the clock is ready, resources on it can show any time between the previous frozen_at and the new one. |
failed | Flint couldn't finish an advance, and resources on the clock may have processed only part of it. The clock can't advance again: archive it and create a new one. Final. |
archived | Archived with DELETE. Readable, but it never advances and takes no new customers. Final. |
status is a closed set. Branch on it to decide whether to wait, continue, or start over with a new clock.
Events#
| Event | When |
|---|---|
test_clock.created | A clock was created. |
test_clock.advancing | An advance started. |
test_clock.ready | An advance finished. Flint records it after every event the advance caused. |
test_clock.failed | An advance failed. |
test_clock.archived | A ready or failed clock was archived. |
Each event carries the clock as data.object. Events go to the sandbox's webhook endpoints, like any other sandbox event.
What follows the clock#
Customers created on a test clock, their subscriptions, and those subscriptions' payment retries use the clock's time wherever Flint decides or records a point in their billing lifecycle. Everything else uses real time.
| Behavior | Follows the clock |
|---|---|
| Trial end, then activation and the first charge | Yes |
subscription.trial_ending and subscription.renewal_upcoming notices | Yes |
Renewals at next_billing_at | Yes |
| Scheduled starts | Yes |
| Payment retries and the action when retries run out | Yes |
| Cancel at period end, and timed pauses that resume on their own | Yes |
Subscription _at fields other than created_at and updated_at | Yes |
created_at and updated_at on every resource | No |
| Webhook envelope times, request logs, and timelines | No |
| Orders, payment intents, invoices, refunds, disputes, and payouts | No |
| Card processing, 3D Secure, and bank debit settlement at Stripe | No |
The needs_attention subscription list filter | No |
Sandbox emails go to real addresses, and webhooks are real sandbox deliveries, so expect them when billing runs on a clock.
Resetting the sandbox removes its test clocks with the rest of its data.
The Test clock object#
A sandbox clock that customers created on it, and their subscriptions, read as the current time.
Returned by GET /v1/test-clocks/{test_clock_id} and carried by the endpoints below.
Attributes
created_atstringRequiredWhen the test clock was created, in real time.
frozen_atstringRequiredThe time the test clock shows. Customers created on the clock, and their subscriptions, treat it as the current time. After you advance the clock, `frozen_at` is the time you advanced it to, while `status` is `advancing` and after.
namestringYour label for the test clock. Omitted when you didn't set one.
statusenumRequiredWhere the test clock is in its lifecycle. Read it before advancing, and after an advance until it's `ready` or `failed`.
readyadvancingfailedarchived
test_clock_idstringRequiredUnique identifier for the test clock.
updated_atstringRequiredWhen the test clock last changed, in real time.
versionintegerRequiredPersisted version of this resource's owned state. Expanded resources and external observations can change independently.
{
"created_at": "2026-10-28T12:00:00Z",
"frozen_at": "2026-11-01T00:00:00Z",
"name": "Annual renewal test",
"status": "ready",
"test_clock_id": "tclk_01K8ABCDEF0123456789ABCDEF",
"updated_at": "2026-10-28T12:00:00Z",
"version": 1
}List test clocks#
/v1/test-clocksRequires scope developer.test_clocks.read or developer.test_clocks.write
Rate limit: read
Sandbox only. Lists the sandbox's test clocks, newest first, then by `test_clock_id`. Archived clocks are listed only when the `status` filter names `archived`. Default order: created_at descending, then test_clock_id descending.
Query parameters
statusarray of enumFilter by status. Omitted, the list leaves out archived rows; name archived to include them. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
readyadvancingfailedarchived
page_sizeintegerMaximum number of results to return, from 1 to 100. Defaults to 20.
page_tokenstringOpaque next_page_token from the previous response. Omit on the first request. You may change `page_size` between pages. Reuse it with the same endpoint, filters, sort, and request context. Do not parse or construct tokens. An invalid, expired, or mismatched token returns a validation error.
Response · 200
A page of test clocks.
dataarray of objectRequiredResource, collection, or operation result returned by this request.
created_atstringRequiredWhen the test clock was created, in real time.
frozen_atstringRequiredThe time the test clock shows. Customers created on the clock, and their subscriptions, treat it as the current time. After you advance the clock, `frozen_at` is the time you advanced it to, while `status` is `advancing` and after.
namestringYour label for the test clock. Omitted when you didn't set one.
statusenumRequiredWhere the test clock is in its lifecycle. Read it before advancing, and after an advance until it's `ready` or `failed`.
readyadvancingfailedarchived
test_clock_idstringRequiredUnique identifier for the test clock.
updated_atstringRequiredWhen the test clock last changed, in real time.
versionintegerRequiredPersisted version of this resource's owned state. Expanded resources and external observations can change independently.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
next_page_tokenstringOpaque token to send as `page_token` to retrieve the next page. Omitted when there is no next page.
request_idstringRequiredIdentifier of this API request, used to correlate logs and support requests.
curl https://api.withflintpay.com/v1/test-clocks \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"A page of test clocks.
{
"data": [
{
"created_at": "2026-10-28T12:00:00Z",
"frozen_at": "2026-11-01T00:00:00Z",
"name": "Annual renewal test",
"status": "ready",
"test_clock_id": "tclk_01K8ABCDEF0123456789ABCDEF",
"updated_at": "2026-10-28T12:00:00Z",
"version": 1
}
],
"meta": {
"api_version": "2026-09-07"
},
"next_page_token": "opaque-next-page-token",
"request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4D"
}Create a test clock#
/v1/test-clocksIdempotentRequires scope developer.test_clocks.write
Rate limit: write
Sandbox only. Creates a test clock stopped at `frozen_at`, with status `ready`. Customers created on it, and their subscriptions, read its time instead of real time.
Request body
frozen_atstringThe time the clock starts at. Defaults to now. It can be up to 5 years ahead, and no more than an hour behind now, to allow for clock skew on your side. Fractional seconds are truncated.
namestringYour label for the test clock.
Response · 201
The test clock.
dataobjectRequiredResource, collection, or operation result returned by this request.
created_atstringRequiredWhen the test clock was created, in real time.
frozen_atstringRequiredThe time the test clock shows. Customers created on the clock, and their subscriptions, treat it as the current time. After you advance the clock, `frozen_at` is the time you advanced it to, while `status` is `advancing` and after.
namestringYour label for the test clock. Omitted when you didn't set one.
statusenumRequiredWhere the test clock is in its lifecycle. Read it before advancing, and after an advance until it's `ready` or `failed`.
readyadvancingfailedarchived
test_clock_idstringRequiredUnique identifier for the test clock.
updated_atstringRequiredWhen the test clock last changed, in real time.
versionintegerRequiredPersisted version of this resource's owned state. Expanded resources and external observations can change independently.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
request_idstringRequiredIdentifier of this API request, used to correlate logs and support requests.
curl -X POST https://api.withflintpay.com/v1/test-clocks \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: a-unique-key" \
-d '{
"frozen_at": "2026-11-01T00:00:00Z",
"name": "Annual renewal test"
}'Get a test clock#
/v1/test-clocks/{test_clock_id}Requires scope developer.test_clocks.read or developer.test_clocks.write
Rate limit: read
Sandbox only. Returns a test clock in this sandbox, including an archived one.
Path parameters
test_clock_idstringRequiredID of the test clock.
curl https://api.withflintpay.com/v1/test-clocks/tclk_01KEZF7C00J8YBNPS7XJ5FG5ZZ \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"The test clock.
{
"data": {
"created_at": "2026-10-28T12:00:00Z",
"frozen_at": "2026-11-01T00:00:00Z",
"name": "Annual renewal test",
"status": "ready",
"test_clock_id": "tclk_01K8ABCDEF0123456789ABCDEF",
"updated_at": "2026-10-28T12:00:00Z",
"version": 1
},
"meta": {
"api_version": "2026-09-07"
},
"request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4D"
}Archive a test clock#
/v1/test-clocks/{test_clock_id}IdempotentRequires scope developer.test_clocks.write
Rate limit: write
Sandbox only. Archives the test clock. It stays readable by ID, never advances again, and no new customer can be created on it. Customers and subscriptions already on it are not changed: they keep the clock's `frozen_at` as their current time, so their subscriptions don't bill again. Cancel those subscriptions first if you want them canceled, or reset the sandbox to remove everything. Deleting an archived clock returns it unchanged.
Path parameters
test_clock_idstringRequiredID of the test clock.
Query parameters
expected_versionintegerOptional version most recently read. A stale value fails with `VERSION_CONFLICT` and the current version.
curl -X DELETE https://api.withflintpay.com/v1/test-clocks/tclk_01KEZF7C00J8YBNPS7XJ5FG5ZZ \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"Advance a test clock#
/v1/test-clocks/{test_clock_id}/advanceIdempotentRequires scope developer.test_clocks.write
Rate limit: write
Sandbox only. Moves the test clock forward to `frozen_at`. Flint accepts the request and returns the clock in status `advancing`, then moves the clock's customers and their subscriptions to `frozen_at`, running the billing that falls due along the way, in order. Flint sends `test_clock.ready` when the advance finishes, or `test_clock.failed` if it can't finish. You can also read the clock with `GET /v1/test-clocks/{test_clock_id}` until its status is `ready` or `failed`. One advance reaches at most two years, or two billing intervals of any subscription on the clock that isn't canceled, whichever is earlier.
Path parameters
test_clock_idstringRequiredID of the test clock.
Request body
expected_versionintegerOptional expected version of this resource. A stale value returns 409 VERSION_CONFLICT with the current version. Retrieve the resource and rebuild the request before retrying.
frozen_atstringRequiredThe time to move the clock to. It must be later than the clock's current `frozen_at`, and no later than two years after it or two billing intervals of any subscription on the clock that isn't canceled, whichever is earlier. Fractional seconds are truncated.
curl -X POST https://api.withflintpay.com/v1/test-clocks/tclk_01KEZF7C00J8YBNPS7XJ5FG5ZZ/advance \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: a-unique-key" \
-d '{
"expected_version": 1,
"frozen_at": "2026-12-01T00:00:00Z"
}'Was this helpful?
