Reactors
Create Reactor
Create a new Reactor for the Tenant.
Permissions
reactor:create
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
javascript='module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: "bar"
}
};
};'
curl "https://api.basistheory.com/reactors" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>" \
-H "Content-Type: application/json" \
-X "POST" \
-d '{
"name": "My Reactor",
"code": '"$(echo $javascript | jq -Rsa .)"',
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
},
"application": {
"id": "45c124e7-6ab2-4899-b4d9-1388b0ba9d04"
}
}'
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<MANAGEMENT_API_KEY>");
const reactor = await bt.reactors.create({
name: "My Reactor",
code: `
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: "bar"
}
};
};
`,
configuration: {
SERVICE_API_KEY: "key_abcd1234",
},
application: {
id: "45c124e7-6ab2-4899-b4d9-1388b0ba9d04",
},
});
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var code = @"
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar'
}
};
};
";
var createReactorRequest = new CreateReactorRequest("My Reactor", code)
{
_Configuration = new Dictionary<string, string> {
{ "SERVICE_API_KEY", "key_abcd1234" }
},
Application = new Application {
Id = new Guid("45c124e7-6ab2-4899-b4d9-1388b0ba9d04")
}
};
Reactor result = apiInstance.Create(createReactorRequest);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Map;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<MANAGEMENT_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
CreateReactorRequest createReactorRequest = new CreateReactorRequest(); // CreateReactorRequest |
Reactor reactor = apiInstance.create(createReactorRequest
.name("My Reactor")
.code("""
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
raw: {
foo: 'bar'
}
};
};
""")
._configuration(Map.of("SERVICE_API_KEY", "key_abcd134"))
.application(Application.fromJson("45c124e7-6ab2-4899-b4d9-1388b0ba9d04")));
}
}
import basistheory
from basistheory.api import reactors_api
from basistheory.model.create_reactor_request import CreateReactorRequest
from basistheory.model.application import Application
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<MANAGEMENT_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
reactor = reactors_client.create(create_reactor_request=CreateReactorRequest(
name="My Reactor",
code=" \
module.exports = async function (req) { \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
raw: { \
foo: 'bar' \
} \
}; \
};",
configuration={
"SERVICE_API_KEY": "key_abcd134"
},
application=Application(
id="45c124e7-6ab2-4899-b4d9-1388b0ba9d04"
)
))
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<MANAGEMENT_API_KEY>"},
})
createReactorRequest := *basistheory.NewCreateReactorRequest("My Reactor")
createReactorRequest.SetCode(`
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar'
}
};
};
`)
createReactorRequest.SetConfiguration(map[string]string{
"SERVICE_API_KEY": "key_abcd134",
})
application := *basistheory.NewApplication()
application.SetId("45c124e7-6ab2-4899-b4d9-1388b0ba9d04")
createReactorRequest.SetApplication(application)
reactor, httpResponse, error := apiClient.ReactorsApi.Create(contextWithAPIKey).CreateReactorRequest(createReactorRequest).Execute()
}
Request Parameters
Attribute | Required | Type | Default | Description |
---|---|---|---|---|
name | true | string | null | The name of the reactor. Has a maximum length of 200 |
code | true | string | null | Reactor code which will be executed when the Reactor is processed |
configuration | true | map<string, string> | null | A string key and string value map of predefined configuration names and values accessible from the Reactor code |
application.id | false | uuid | null | This Application's API key is injected into a pre-configured BasisTheory JS SDK instance passed into the Reactor's runtime. Must be a public or private Application Type. |
Response
Returns a Reactor if the Reactor was created. Returns an error if there were validation errors, or the Reactor failed to create.
{
"id": "5b493235-6917-4307-906a-2cd6f1a90b13",
"tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
"name": "My Reactor",
"code": "
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar',
}
};
};
",
"application": {...},
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
},
"created_by": "3ce0dceb-fd0b-4471-8006-c51243c9ef7a",
"created_at": "2020-09-15T15:53:00+00:00"
}
List Reactors
Get a list of reactors for the Tenant.
Permissions
reactor:read
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/reactors" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>"
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<MANAGEMENT_API_KEY>");
const reactors = await bt.reactors.list();
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var id = new List<Guid>();
var name = "";
var page = 1;
var start = "";
var size = 1;
ReactorPaginatedList result = apiInstance.Get(id, name, page, start, size);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<MANAGEMENT_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
List<UUID> id = Arrays.asList();
String name = "";
Integer page = 1;
Integer size = 56;
ReactorPaginatedList result = apiInstance.get(id, name, page, size);
}
}
import basistheory
from basistheory.api import reactors_api
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<MANAGEMENT_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
reactors = reactors_client.get()
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<MANAGEMENT_API_KEY>"},
})
reactors, httpResponse, err := apiClient.ReactorsApi.Get(contextWithAPIKey).Execute()
}
Query Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | false | array | [] | An optional list of Reactor ID's to filter the list of reactors by |
name | false | string | null | Wildcard search of reactors by name |
Response
Returns a paginated object with the data
property containing an array of reactors. Providing any query parameters will filter the results. Returns an error if reactors could not be retrieved.
{
"pagination": {...}
"data": [
{
"id": "5b493235-6917-4307-906a-2cd6f1a90b13",
"tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
"name": "My Reactor",
"code": "
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar',
}
};
};
",
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
},
"created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"created_at": "2020-09-15T15:53:00+00:00",
"modified_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"modified_at": "2021-03-01T08:23:14+00:00"
},
{...},
{...}
]
}
Get a Reactor
Get a Reactor by ID in the Tenant.
Permissions
reactor:read
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>"
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<MANAGEMENT_API_KEY>");
const reactor = await bt.reactors.retrieve(
"5b493235-6917-4307-906a-2cd6f1a90b13"
);
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var id = Guid.Parse("");
Reactor result = apiInstance.GetById(id);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<MANAGEMENT_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
Reactor result = apiInstance.getById(UUID.fromString("5b493235-6917-4307-906a-2cd6f1a90b13"));
}
}
import basistheory
from basistheory.api import reactors_api
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<MANAGEMENT_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
reactor = reactors_client.get_by_id("5b493235-6917-4307-906a-2cd6f1a90b13")
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<MANAGEMENT_API_KEY>"},
})
reactor, httpResponse, err := apiClient.ReactorsApi.GetById(contextWithAPIKey, "5b493235-6917-4307-906a-2cd6f1a90b13").Execute()
}
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the reactor |
Response
Returns a Reactor with the id
provided. Returns an error if the Reactor could not be retrieved.
{
"id": "5b493235-6917-4307-906a-2cd6f1a90b13",
"tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
"name": "My Reactor",
"code": "
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar',
}
};
};
",
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
},
"created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"created_at": "2020-09-15T15:53:00+00:00",
"modified_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"modified_at": "2021-03-01T08:23:14+00:00"
}
Update Reactor
Update a Reactor by ID in the Tenant.
Permissions
reactor:update
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
javascript='module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: "bar"
}
};
};'
curl "https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>" \
-H "Content-Type: application/json" \
-X "PUT" \
-d '{
"name": "My Reactor",
"code": '"$(echo $javascript | jq -Rsa .)"',
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
},
"application": {
"id": "45c124e7-6ab2-4899-b4d9-1388b0ba9d04"
}
}'
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<MANAGEMENT_API_KEY>");
const reactor = await bt.reactors.update(
"5b493235-6917-4307-906a-2cd6f1a90b13",
{
name: "My Reactor",
code: '
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: "bar"
}
};
};
',
configuration: {
SERVICE_API_KEY: "key_abcd1234",
},
application: {
id: "45c124e7-6ab2-4899-b4d9-1388b0ba9d04",
},
}
);
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var id = new Guid("9fd32800-f0a6-4bc2-8335-4390faa61476");
var code = @"
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar'
}
};
};
";
var updateReactorRequest = new UpdateReactorRequest("My Reactor", code: code)
{
_Configuration = new Dictionary<string, string> {
{ "SERVICE_API_KEY", "key_abcd1234" }
},
Application = new Application {
Id = new Guid("45c124e7-6ab2-4899-b4d9-1388b0ba9d04")
}
};
Reactor result = apiInstance.Update(id, updateReactorRequest);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Map;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<MANAGEMENT_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
UpdateReactorRequest updateReactorRequest = new UpdateReactorRequest(); // CreateReactorRequest |
Reactor reactor = apiInstance.update(UUID.fromString("5b493235-6917-4307-906a-2cd6f1a90b13"),updateReactorRequest
.name("My Reactor")
.code("""
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
raw: {
foo: 'bar'
}
};
};
""")
._configuration(Map.of("SERVICE_API_KEY", "key_abcd134"))
.application(Application.fromJson("45c124e7-6ab2-4899-b4d9-1388b0ba9d04")));
}
}
import basistheory
from basistheory.api import reactors_api
from basistheory.model.update_reactor_request import UpdateReactorRequest
from basistheory.model.application import Application
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<MANAGEMENT_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
reactor = reactors_client.update("5b493235-6917-4307-906a-2cd6f1a90b13", update_reactor_request=UpdateReactorRequest(
name="My Reactor",
code=" \
module.exports = async function (req) { \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
raw: { \
foo: 'bar' \
} \
}; \
};",
configuration={
"SERVICE_API_KEY": "key_abcd134"
},
application=Application(
id="45c124e7-6ab2-4899-b4d9-1388b0ba9d04"
)
))
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<MANAGEMENT_API_KEY>"},
})
updateReactorRequest := *basistheory.NewUpdateReactorRequest("My Reactor")
updateReactorRequest.SetCode(`
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar'
}
};
};
`)
updateReactorRequest.SetConfiguration(map[string]string{
"SERVICE_API_KEY": "key_abcd134",
})
application := *basistheory.NewApplication()
application.SetId("45c124e7-6ab2-4899-b4d9-1388b0ba9d04")
updateReactorRequest.SetApplication(application)
reactor, httpResponse, err := apiClient.ReactorsApi.Update(contextWithAPIKey, "5b493235-6917-4307-906a-2cd6f1a90b13").UpdateReactorRequest(updateReactorRequest).Execute()
}
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the reactor |
Request Parameters
Attribute | Required | Type | Default | Description |
---|---|---|---|---|
name | true | string | null | The name of the reactor. Has a maximum length of 200 |
code | true | string | null | Reactor code which will be executed when the Reactor is processed |
configuration | true | map<string, string> | null | A string key and string value map of predefined configuration names and values accessible from the Reactor code |
application.id | false | uuid | null | This Application's API key is injected into a pre-configured BasisTheory JS SDK instance passed into the Reactor's runtime. Must be a public or private Application Type. |
Response
Returns a Reactor if the Reactor was updated. Returns an error if there were validation errors, or the Reactor failed to update.
{
"id": "5b493235-6917-4307-906a-2cd6f1a90b13",
"tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
"name": "My Reactor",
"code": "
module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar'
}
};
};
",
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
},
"created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"created_at": "2020-09-15T15:53:00+00:00",
"modified_by": "34053374-d721-43d8-921c-5ee1d337ef21",
"modified_at": "2021-03-01T08:23:14+00:00"
}
Patch Reactor
Patch a Reactor by ID in the Tenant.
Permissions
reactor:update
Content-Type
header to be set to application/merge-patch+json
. Requests made with a different Content-Type
header value will receive a 415 Unsupported Media Type
response code. For more information on merge-patch, see RFC 7386.Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>" \
-H "Content-Type: application/merge-patch+json" \
-X "PATCH" \
-d '{
"name": "My Reactor",
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
}
}'
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<MANAGEMENT_API_KEY>");
const reactor = await bt.reactors.patch(
"5b493235-6917-4307-906a-2cd6f1a90b13",
{
name: "My Reactor",
configuration: {
SERVICE_API_KEY: "key_abcd1234",
}
}
);
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var id = Guid.Parse("");
var patchReactorRequest = new PatchReactorRequest()
{
// Additional parameters
};
apiInstance.Patch(id, patchReactorRequest);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Map;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<MANAGEMENT_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
PatchReactorRequest patchReactorRequest = new PatchReactorRequest();
Reactor reactor = apiInstance.patch(UUID.fromString("5b493235-6917-4307-906a-2cd6f1a90b13"), patchReactorRequest
.name("My Reactor")
._configuration(Map.of("SERVICE_API_KEY", "key_abcd134")));
}
}
import basistheory
from basistheory.api import reactors_api
from basistheory.model.patch_reactor_request import PatchReactorRequest
from basistheory.model.application import Application
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<MANAGEMENT_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
reactor = reactors_client.patch("5b493235-6917-4307-906a-2cd6f1a90b13", patch_reactor_request=PatchReactorRequest(
name="My Reactor",
configuration={
"SERVICE_API_KEY": "key_abcd134"
}
))
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<MANAGEMENT_API_KEY>"},
})
patchReactorRequest := *basistheory.NewPatchReactorRequest("My Reactor")
patchReactorRequest.SetConfiguration(map[string]string{
"SERVICE_API_KEY": "key_abcd134",
})
reactor, httpResponse, err := apiClient.ReactorsApi.Patch(contextWithAPIKey, "5b493235-6917-4307-906a-2cd6f1a90b13").PatchReactorRequest(patchReactorRequest).Execute()
}
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the reactor |
Request Parameters
Attribute | Required | Type | Default | Description |
---|---|---|---|---|
name | false | string | null | The name of the reactor. Has a maximum length of 200 |
code | false | string | null | Reactor code which will be executed when the Reactor is processed |
configuration | false | map<string, string> | null | A string key and string value map of predefined configuration names and values accessible from the Reactor code |
application.id | false | uuid | null | This Application's API key is injected into a pre-configured BasisTheory JS SDK instance passed into the Reactor's runtime. Must be a public or private Application Type. |
Response
Returns 204
if successful. Returns an error if there were validation errors, or the operation failed.
Delete Reactor
Delete a Reactor by ID in the Tenant.
Permissions
reactor:delete
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/reactors/fb124bba-f90d-45f0-9a59-5edca27b3b4a" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>" \
-X "DELETE"
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<MANAGEMENT_API_KEY>");
await bt.reactors.delete("fb124bba-f90d-45f0-9a59-5edca27b3b4a");
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var id = Guid.Parse("");
apiInstance.Delete(id);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<MANAGEMENT_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
apiInstance.delete(UUID.fromString("45c124e7-6ab2-4899-b4d9-1388b0ba9d04"));
}
}
import basistheory
from basistheory.api import reactors_api
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<MANAGEMENT_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
reactors_client.delete("fb124bba-f90d-45f0-9a59-5edca27b3b4a")
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<MANAGEMENT_API_KEY>"},
})
httpResponse, err := apiClient.ReactorsApi.Delete(contextWithAPIKey, "fb124bba-f90d-45f0-9a59-5edca27b3b4a").Execute()
}
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the reactor |
Response
Returns an error if the Reactor failed to delete.
Invoke a Reactor
Invoke a reactor by ID.
Permissions
token:use
The token:use
permission is required to use a Reactor, and it is required for each
Container of Tokens you wish to detokenize in a Reactor.
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13/react" \
-H "BT-API-KEY: <PRIVATE_API_KEY>" \
-H "Content-Type: application/json" \
-X "POST" \
-d '{
"args": {
"card": "{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
"customer_id": "myCustomerId1234"
}
}'
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<PRIVATE_API_KEY>");
const reactResponse = await bt.reactors.react(
"5b493235-6917-4307-906a-2cd6f1a90b13",
{
args: {
card: "{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
customer_id: "myCustomerId1234",
},
}
);
using BasisTheory.net.Api;
using BasisTheory.net.Client;
using BasisTheory.net.Model;
Configuration config = new Configuration();
config.BasePath = "https://api.basistheory.com";
config.AddApiKey("BT-API-KEY", "YOUR_API_KEY");
var apiInstance = new ReactorsApi(config);
var id = new Guid("9fd32800-f0a6-4bc2-8335-4390faa61476");
var reactRequest = new ReactRequest
{
Args = new
{
card = "{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
customer_id = "myCustomerId1234"
}
};
ReactResponse result = apiInstance.React(id, reactRequest);
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Map;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<PRIVATE_API_KEY>");
ReactorsApi apiInstance = new ReactorsApi(defaultClient);
ReactRequest reactRequest = new ReactRequest();
ReactResponse result = apiInstance.react(UUID.fromString("5b493235-6917-4307-906a-2cd6f1a90b13"),
reactRequest.args(
Map.of("card","{{fe7c0a36-eb45-4f68-b0a0-791de}}",
"customer_id", "myCustomerId1234")));
System.out.println(result);
}
}
import basistheory
from basistheory.api import reactors_api
from basistheory.model.react_request import ReactRequest
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<PRIVATE_API_KEY>")) as api_client:
reactors_client = reactors_api.ReactorsApi(api_client)
react_response = reactors_client.react("5b493235-6917-4307-906a-2cd6f1a90b13", react_request=ReactRequest(
args={
"card":"{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
"customer_id": "myCustomerId1234"
}
))
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<PRIVATE_API_KEY>"},
})
reactRequest := *basistheory.NewReactRequest()
reactRequest.SetArgs(map[string]interface{}{
"card": "{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
"customer_id": "myCustomerId1234",
})
reacthttpResponse, httpResponse, err := apiClient.ReactorsApi.React(contextWithAPIKey, "5b493235-6917-4307-906a-2cd6f1a90b13").ReactRequest(reactRequest).Execute()
}
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the Reactor |
Request Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
args | false | object | null | Arguments to provide to the reactor. |
callback_url | false | string | null | Indicates that the reactor should be invoked asynchronously and the result delivered as a webhook to this URL. See Asynchronous Reactors for more info. Enterprise DEPRECATED |
Reactor Request Parameters
The reactor will be executed with a req
object that contains the following properties
Parameter | Description |
---|---|
args | Detokenized arguments to provided to the reactor. |
configuration | A string key and string value map of all configuration name and values defined when creating the Reactor |
bt | A pre-configured Basis Theory JS instance for the application defined with the Reactor. This will be null if no application was defined. |
Response
Returns a Reactor Response if the Reactor completed successfully. Returns an error if the Reactor failed. Errors generated from Reactors will be translated to the common Basis Theory Error format. See Reactor Errors for more details.
Reactor Response Object
Attribute | Type | Description |
---|---|---|
tokens | object | (Optional) Token(s) created from the tokenize block of the Reactor code response |
raw | object | (Optional) Raw output returned from the Reactor |
Limitations
Head over to Rate Limits to learn more about Reactors limitations.
Detokenization
In order to use tokenized data within a reactor, the args
parameter may contain one or more detokenization expressions.
When any detokenization expressions are detected, Basis Theory will attempt to detokenize and inject the raw token data into the args
forwarded to the Reactor function.
Reactor request args
may contain a mixture of detokenization expressions and raw plaintext data.
Tokens containing complex data may be detokenized into a Reactor request, including Bank and Card token types.
When tokens with complex data are detokenized, the entire JSON data payload will be included within the args
.
For an example, see Use Complex Tokens.
Validation is performed on the resulting request after detokenization, so several required request parameters may be supplied by detokenizing a single complex token that contains several of the request parameters.
At most, 100 tokens may be detokenized within a single Reactor request.
Invoke a Reactor Asynchronously Enterprise
Invoke a reactor by ID asynchronously. See Asynchronous Reactors for more info.
Permissions
token:use
The token:use
permission is required to use a Reactor, and it is required for each
Container of Tokens you wish to detokenize in a Reactor.
Request
- cURL
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" \
-d '{
"args": {
"card": "{{fe7c0a36-eb45-4f68-b0a0-791de28b29e4}}",
"customer_id": "myCustomerId1234"
}
}'
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the Reactor |
Request Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
args | false | object | null | Arguments to provide to the reactor. |
Response
{
"asyncReactorRequestId": "3254626a-e1cf-4616-968f-e08a7ade4fce"
}
Returns a request ID that can be used later to retrieve the results of the asynchronous invocation.
Retrieve Result Enterprise
Will retrieve the results of an asynchronous invocation.
Permissions
token:use
The token:use
permission is required to read the result of reactors.
Request
- cURL
curl --location 'https://api.basistheory.com/reactors/7001A144-96D0-4401-9D96-13557824A9E0/results/369a879e-338d-4f52-83cf-53a6af3f3f18' \
--header 'BT-API-KEY: <PRIVATE_API_KEY>'
URI Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
id | true | uuid | null | The ID of the Reactor |
request_id | true | uuid | null | The ID of the Reactor request id. Retrieved from either the response of react-async or from the webhook events (reactor.invoked , reactor.completed , reactor.failed ). |
Request Parameters
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
args | false | object | null | Arguments to provide to the reactor. |
Response
Returns a response object the same as the synchronous response.
Reactor Response Object
Attribute | Type | Description |
---|---|---|
tokens | object | (Optional) Token(s) created from the tokenize block of the Reactor code response |
raw | object | (Optional) Raw output returned from the Reactor |
Reactor Object
Attribute | Type | Description |
---|---|---|
id | uuid | Unique identifier of the Reactor which can be used to get a Reactor |
tenant_id | uuid | The Tenant ID which owns the reactor |
name | string | The name of the reactor |
code | string | Reactor code which will be executed when the Reactor is processed |
configuration | map<string, string> | A string key and string value map of predefined configuration names and values accessible from the Reactor code |
application | Application | (Optional) This Application's API key is injected into a pre-configured BasisTheory JS SDK instance passed into the Reactor's runtime. Must be a public or private Application Type. |
created_by | uuid | (Optional) The ID of the user or Application that created the Reactor |
created_at | string | (Optional) Created date of the Reactor in ISO 8601 format |
modified_by | uuid | (Optional) The ID of the user or Application that last modified the Reactor |
modified_at | date | (Optional) Last modified date of the Reactor in ISO 8601 format |
Reactor Code
All Reactor code
snippets must export a function which takes in a request object and returns a response object.
The snippet should be written in Javascript (targeting Node.js v16) and generally follows the following structure:
module.exports = async function (req) {
const { my_arg } = req.args; // access any args provided with the request
const { MY_CONFIG } = req.configuration; // access any static config defined on the Reactor
// do anything here!
return {
raw: {}, // non-sensitive data that should be returned in plaintext
tokenize: {}, // sensitive data that should be tokenized
};
};
Reactor Code Request Object
Attribute | Type | Description |
---|---|---|
args | object | The arguments that were provided when the reactor was invoked |
configuration | map<string, string> | A string key and string value map of all configuration name and values defined when creating the Reactor |
Reactor Code Response Object
Attribute | Type | Description |
---|---|---|
raw | object | (Optional) Raw output returned from the Reactor |
tokenize | object | (Optional) A payload that will be tokenized to produce one or more tokens |
The payload returned in the tokenize
property will be tokenized in the same way that requests are tokenized via the Tokenize endpoint.
For more information, see Tokenize.