Create reaction definition

post
Create reaction definition

https://api.serialized.io/reactions/definitions
Create a new reaction definition
Request
Response
Request
Headers
Serialized-Access-Key
required
string
Serialized access key
Serialized-Secret-Access-Key
required
string
Serialized secret key
Body Parameters
reactionName
required
string
Unique name of the reaction
feedName
required
string
Name of the feed
reactOnEventType
required
string
Event type to react on
cancelOnEventTypes
optional
array
Event types to cancel reaction scheduled in the future
triggerTimeField
optional
string
Path to event data field containing trigger time. If not specified, trigger time will be ASAP. Dot notation supported.
offset
optional
string
Trigger time offset. Defined in the ISO-8601 duration format (PnDTnHnMn.nS). May be negative.
action
required
object
Action to invoke. See examples below.
Response
200: OK
Reaction definition successfully created.
409: Conflict
If reaction definition name is not unique
422: Unprocessable Entity
Invalid request body

Example

cURL
Java
C#
Node
cURL
curl -i https://api.serialized.io/reactions/definitions \
--header "Content-Type: application/json" \
--header "Serialized-Access-Key: <YOUR_ACCESS_KEY>" \
--header "Serialized-Secret-Access-Key: <YOUR_SECRET_ACCESS_KEY>" \
--data '
{
"reactionName": "payment-processed-email-reaction",
"feedName": "payment",
"reactOnEventType": "PaymentProcessed",
"action": {
"actionType": "HTTP_POST",
"targetUri": "https://your-email-service"
}
}
'
Java
import com.google.common.collect.ImmutableMap;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
Client client = ClientBuilder.newClient();
URI apiRoot = URI.create("https://api.serialized.io");
Map<String, Object> reactionDefinition = ImmutableMap.of(
"reactionName", "payment-processed-email-reaction",
"feedName", "payment",
"reactOnEventType", "PaymentProcessed",
"action", ImmutableMap.of(
"actionType", "HTTP_POST",
"targetUri", "https://your-email-service"
)
);
Response response = client.target(apiRoot)
.path("reactions")
.path("definitions")
.request()
.header("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
.header("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
.post(Entity.json(reactionDefinition));
C#
using System;
using System.Collections.Generic;
using RestSharp;
var definition = new Dictionary<string, object>
{
{ "reactionName", "payment-processed-email-reaction" },
{ "feedName", "payment" },
{ "reactOnEventType", "PaymentProcessed" },
{ "action", new Dictionary<string, Object>
{
{"actionType", "HTTP_POST"},
{"targetUri", "https://your-email-service"}
}
},
};
var postRequest = new RestRequest("reactions/definitions", Method.POST)
.AddHeader("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
.AddHeader("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>");
.AddJsonBody(definition);
var response = client.Execute(postRequest);
Node
const axios = require("axios");
const client = axios.create({
baseURL: "https://api.serialized.io",
headers: {"Serialized-Access-Key": "<YOUR_ACCESS_KEY>"},
headers: {"Serialized-Secret-Access-Key": "<YOUR_SECRET_ACCESS_KEY>"}
});
const definition = {
reactionName: "payment-processed-email-reaction",
feedName: "payment",
reactOnEventType: "PaymentProcessed",
action: {
actionType: "HTTP_POST",
targetUri: "https://your-email-service"
}
};
client.post("reactions/definitions", definition)
.then(function (response) {
// Handle response
})
.catch(function (error) {
// Handle error
});