Events are functions that have an order of execution within Cyclr. You can use these functions to react to events that happen in Cyclr with your own script.

before_webhook

You can call before_webhook when a request is received and before you do anything else. You can use the method to decide if a request should continue or return a custom message to the caller instead.

Global object Description
method_endpoint The webhook request URL.
method_request_headers The webhook request headers.
method_request The webhook request body.
method_request parameters The webhook request parameters.
method_response_headers The response headers for the request.
method_response The response body for the request.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return The return object set to true continues with the request to the third party API. The return object set to false aborts the request.
Note: You can use throw for a more useful step error message.

after_webhook

You can call after_webhook immediately after a request to a webhook is received, regardless of the status of the cycle.

Global object Description
method_response The POST object received by the Cyclr webhook.
cycle_variables This object allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
cycle_step_id The ID of the step that executes the script.
cycle_id The ID of the cycle the script runs in.
cyclr_account_id The internal ID of the account the script runs in.
external_account_id The external ID of the account the script runs in.
return The return object set to true continues with the request to the third party API. The return object set to false aborts the request. Note: You can use throw for a more useful step error message.

before_action

You can call before_action before you make a request to an external API. Methods that use paging call this function before you retrieve each page.

Global object Description
method_request_headers The HTTP headers for the request.
method_request_parameters The querystring parameters for the request.
method_request The object that’s posted to the third party API.
method_request_mergefields The mergefields for the request.
cycle_variables Allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
cycle_step_id The ID of the step that executes the script.
cycle_id The ID of the cycle the script runs in.
cyclr_account_id The internal ID of the account the script runs in.
external_account_id The external ID of the account the script runs in.
last_successful_run_date The time value that indicates when a step last ran without error.
action_data An object that persists data between some event handler functions, and allows you to pass data between them. You can access this object in before_action, after_action, after_action_paging, action_condition and after_error.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return The return object set to true continues with the request to the third party API. The return object set to false aborts the request.
Note: You can use throw for a more useful step error message.

after_action

You can call the after_action function when Cyclr receives a response from the external API. Methods that use paging call this function after Cyclr retrieves each page.

Global object Description
method_endpoint The URL of the original request.
method_request The POSt object that the third party API recieves.
method_request_mergefields The mergefields for the request.
method_response_headers The response headers for the request.
method_response The object that contains the response data from the third party API.
Note: If the method uses paging, this contains only the current page’s response.
cycle_variables This object allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
cycle_step_id The ID of the step that executes the script.
cycle_id The ID of the cycle the script runs in.
cyclr_account_id The internal ID of the account the script runs in.
external_account_id The external ID of the account the script runs in.
action_data An object that persists data between some event handler functions, and allows you to pass data between them. You can access this object in before_action, after_action, after_action_paging, action_condition and after_error.
statusCode The response status code.
reasonPhrase The response reason phrase.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.

after_action_paging

You can call the after_action_paging function after Cyclr retrieves all pages of data, regardless of whether you use paging.

Note: This function waits for inbound paging, and doesn’t wait for outbound paging to complete.

Global object Description
method_request_headers The response headers for the request.
method_request_parameters The parameters for the request.
method_request_mergefields The mergefields for the request.
method_response The object that contains the response data from the third party API.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
cycle_step_id The ID of the step that executes the script.
cycle_id The ID of the cycle the script runs in.
cyclr_account_id The internal ID of the account the script runs in.
external_account_id The external ID of the account the script runs in.
next_last_successful_run_date The object that allows you to set the last_successful_run_date value that a step uses on its next run.
action_data An object that persists data between some event handler functions, and allows you to pass data between them. You can access this object in before_action, after_action, after_action_paging, action_condition and after_error.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must returntrue.

after_error

You can call the after_error function when Cyclr receives an error from an external API.

Global object Description
method_error The details of the error. For more information on handling errors, see the [Handle Errors from Third Party APIs](#handle-errors-from-third-party-apis) section.
cycle_variables This object allows you to access Cycle variables.
Note: Changes aren't persisted across cycles.
cycle_step_id The ID of the step that executes the script.
cycle_id The ID of the cycle the script runs in.
cyclr_account_id The internal ID of the account the script runs in.
external_account_id The external ID of the account the script runs in.
action_data An object that persists data between some event handler functions, and allows you to pass data between them. You can access this object in before_action, after_action, after_action_paging, action_condition and after_error.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.

action_condition

Connector builder only.

You can use the action_condition function to combine a method with a decision step, which means you can perform a test that directs a transaction through either the true or false exit point. Cyclr adds the true and false exit points if you include this function in a method. For more information, see the example script.

Global objects Description
method_response The object that contains the response data from the third party API.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
cycle_step_id The ID of the step that executes the script.
cycle_id The ID of the cycle the script runs in.
cyclr_account_id The internal ID of the account the script runs in.
external_account_id The external ID of the account the script runs in.
action_data An object that persists data between some event handler functions, and allows you to pass data between them. You can access this object in before_action, after_action, after_action_paging, action_condition and after_error.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Set the return object to true for the transaction to exit on the true route, and false to exit on the false route.

Example script

// Any records that pass the condition will continue down the green "True" path.
// Those that do not will take the red "False" path.

function action_condition() {
	if ([some test])
		return true;

	return false;
}

// If you want to send errored transactions (as opposed to successful calls that 
// fail the condition) down the false path, you will need to add after_error script.

before_oauth2_authorise

Connector builder only.

You can call the before_oauth2_authorise event before Cyclr makes an OAuth 2 authorize request.

Global object Description
method_endpoint The URL for the OAuth authorisation endpoint.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.

before_oauth2_token

Connector builder only.

You can call the before_oauth2_token event before Cyclr makes an OAuth 2 access token request.

Global object Description
method_request_headers The HTTP headers for the request.
method_request The object that’s posted to the OAuth 2 access token endpoint.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.

after_oauth2_token

Connector builder only.

You can call the after_oauth2_token function after Cyclr makes an OAuth 2 access token request.

Global object Description
method_response The object received from the OAuth 2 access token request.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.

before_oauth2_refresh

Connector builder only.

You can call the before_oauth2refresh function before Cyclr makes an OAuth 2 refresh token request.

Global object Description
method_request_headers The HTTP headers for the request.
method_request The object that’s sent to the OAuth 2 refresh token request.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.

after_oauth2_refresh

Connector builder only.

You can call the after_oauth2_refresh function after Cyclr makes an OAuth 2 refresh token request.

Global object Description
method_response The object received from the OAuth 2 refresh token request.
cycle_variables The object that allows access to Cycle variables.
Note: Changes aren't persisted across cycles.
script_parameters An object that contains any available script parameters from the connector and method.
Note: Changes aren't persisted across cycles.
return Inbuilt Cyclr functions must return true.