Skip to main content
POST
Test a Cloud Function
Run the draft of a Cloud Function on a test copy that cannot change anything. Without a draft, the test runs the published code.

What happens during a test

Send an event-shaped ctx to test with. Without it, the function receives {}. A test has the same time and request limits as a real execution. It appears in run history with sample_label test_run, but it does not change run_count, last_run_at, or last_run_status.
Accepted risks of a test
  • A GET that changes something in the other system, such as an unsubscribe link or a webhook triggered by a GET, runs for real.
  • Writes get a synthetic {} answer. Code that reads fields from that answer, such as an ID it expects back, can take a different branch than in production.
  • A write sent through globalThis.fetch instead of the provided fetch or axios is also held back, but it is not listed in run.requests.
  • A raw TCP connection opened with a socket API is not held back.

Read the result

  • run.status is success, error, or timeout. An error in your code is a successful call with run.status error.
  • run.effects lists the previewed lead changes.
  • run.requests lists every request made through fetch or axios. The ones with blocked: true were not sent.
  • run.mode is test.
A 503 DEPLOYMENT_NOT_CURRENT means the test copy could not be prepared. Nothing ran and nothing was recorded. Retry in a moment. To verify a real write, publish the code while the function is paused, then turn it on and watch its next runs.

Authorizations

X-API-Key
string
header
required

API key for authentication. Keys are prefixed with nxr_live_.

Path Parameters

id
string<uuid>
required

Cloud Function id.

Body

application/json
ctx
object

Optional event-shaped ctx to test with. Defaults to {}.

Response

The test ran. A function error or timeout is reported in run.status and run.error, not as an HTTP error.

success
enum<boolean>
required
Available options:
true
run
object
required
test
enum<boolean>
required
Available options:
true
Last modified on October 6, 2026