Skip to main content

Invoke Async Reactors

Invoke Asynchronously
Enterprise

Invoke a Reactor by ID without waiting for its execution to finish. The response contains a request ID that you can use to poll for the result.

For configuration and runtime-specific behavior, see Asynchronous Reactors using Node.js runtime images or the legacy Asynchronous node-bt Reactors.

POST
https://api.basistheory.com/reactors/{id}/react-async
Copy

Permissions

reactor:invoke
For container-scoped detokenization, use token:use in an Access Rule.
Use reactor:invoke as a direct Application permission. Direct token:use permissions are supported only for backward compatibility and will be deprecated.

Request

The request body depends on the Reactor runtime:

curl 'https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13/react-async' \
-H 'BT-API-KEY: <PRIVATE_API_KEY>' \
-H 'Content-Type: application/json' \
-X 'POST' \
--data '{
"args": {
"card": "{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
"customer_id": "myCustomerId1234"
}
}'

URI Parameters

ParameterRequiredTypeDefaultDescription
idtrueuuidnullThe ID of the Reactor

Request Parameters

The request parameters depend on the Reactor runtime:

node-bt

ParameterRequiredTypeDefaultDescription
argsfalseobjectnullArguments sent to the Reactor as req.args.

The callback_url parameter is not supported by /react-async. Legacy node-bt Reactors can use it only through the synchronous /react endpoint, and it is deprecated.

DEPRECATED

Node.js Runtime Images

ParameterRequiredTypeDefaultDescription
Request bodyfalseobjectnullArguments sent directly to the Reactor as event.req.

Response

The endpoint returns 202 Accepted after the request is accepted for asynchronous execution:

{
"asyncReactorRequestId": "3254626a-e1cf-4616-968f-e08a7ade4fce"
}

Save asyncReactorRequestId with the Reactor ID. Both values are required to retrieve the result.

Retrieve Async Result
Enterprise

Poll the result endpoint using the Reactor ID and asyncReactorRequestId.

GET
https://api.basistheory.com/reactors/{id}/results/{request_id}
Copy

Permissions

reactor:invoke
For container-scoped detokenization, use token:use in an Access Rule.
Use reactor:invoke as a direct Application permission. Direct token:use permissions are supported only for backward compatibility and will be deprecated.

Request

Retrieve an Async Reactor Result
curl 'https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13/results/3254626a-e1cf-4616-968f-e08a7ade4fce' \
-H 'BT-API-KEY: <PRIVATE_API_KEY>'

URI Parameters

ParameterRequiredTypeDefaultDescription
idtrueuuidnullThe ID of the Reactor.
request_idtrueuuidnullThe asyncReactorRequestId returned when the invocation was accepted. It is also available from the reactor.invoked, reactor.completed, and reactor.failed webhook events.

Node.js Runtime Results

The following result contract applies to asynchronous Reactors using a Node.js runtime image. The records property contains successfully written partial results, including records written before the Reactor later fails or times out.

Pending Response

While an asynchronous invocation using a Node.js runtime image is running, the endpoint returns 202 Accepted:

{
"status": "pending"
}

Continue polling until the endpoint returns 200 OK.

Completed Success Response

When an asynchronous invocation using a Node.js runtime image completes, the endpoint returns 200 OK. result contains the validated Reactor response, and records is always present.

See Partial Results for how to write records during an asynchronous invocation.

If the Reactor did not write any partial results, records is an empty array:

{
"result": {
"res": {
"body": {
"processed": true
},
"statusCode": 200
}
},
"records": []
}

Completed Failure Response

If the async runtime fails or times out before producing a final Reactor response, the completed body contains error instead of result. The records property contains any partial results that were written successfully:

See Partial Results for how to preserve records before an invocation fails or times out.

If the Reactor did not write any partial results, partial_records is false and records is an empty array:

{
"error": {
"title": "Async Reactor timed out",
"status": 504,
"detail": "The async Reactor timed out before it completed.",
"partial_records": false
},
"records": []
}

The result endpoint still returns 200 OK. The embedded error.status identifies why the invocation failed.

Errors returned by customer code remain inside the validated result.req or result.res object. The top-level error property is reserved for a failure or timeout that prevented the async runtime from producing a final Reactor response.

node-bt Results

When a node-bt invocation succeeds, the endpoint returns the Reactor's raw output and any tokens created from its tokenize output. If the invocation fails, the endpoint returns the Reactor error.

See the Reactor Response Object for response fields and Reactor Error Handling for failure details. See Asynchronous node-bt Reactors for the webhook and result-retrieval workflow.

Result Status Codes

StatusRuntimeMeaning
200AllThe invocation completed.
202Node.js runtime imagesThe invocation is still running. See Pending Response.
401AllThe credentials are missing or invalid.
403AllThe Application lacks permission to retrieve the result.
404AllThe Reactor or request ID was not found, or the request does not belong to the Reactor. For node-bt, this can also mean the invocation is still running.

Reactor Errors

See Reactor Error Codes for possible errors and common scenarios. See Reactor Error Handling for runtime-specific guidance.

Detokenization

Asynchronous invocations use the same Reactor detokenization behavior and limits as synchronous invocations. Use the request shape for the selected runtime.

Limitations

See Rate Limits for Reactor payload, timeout, and concurrency limits.