Skip to main content

Create Event

POST https://app.jiter.dev/api/events

Request Body Parameters

ParameterDescriptionExample
payloadYour stringified payload'{"action":"buyGroceries","values":["eggs","bacon","pasta","bread"]}'
destinationThe endpoint we should send your event tohttps://your-app.com/webhooks/jiter
scheduledTimeAn ISO timestamp in the future when you would like to receive your event'2022-10-05T19:10:58.322Z'

Response

CodeDescription
200Creates a scheduled event
400Please make sure your scheduled time is in the future
500Unable to create the event

Example Usage

index.ts
import axios from "axios";

const apiBaseUrl = "https://app.jiter.dev/api";
const twentyFourHours = 24 * 60 * 60 * 1000;

const createEvent = async () => {
const tomorrow = new Date(Date.now() + twentyFourHours);

try {
const { data } = await axios.post(
`${apiBaseUrl}/events`,
{
destination: "https://your-app.com/webhooks/jiter",
scheduledTime: tomorrow,
payload: JSON.stringify({
action: "buyGroceries",
values: ["eggs", "bacon", "pasta", "bread"],
}),
},
{ headers: { "x-api-key": "YOUR_API_KEY" } }
);

console.log("Event created 🎉", data);
} catch (error) {
console.log("Unable to create event", error);
}
};

createEvent();

Example Success Response

{
"id": "9",
"scheduledTime": "2022-10-27T04:50:26.573Z",
"destination": "https://your-app.com/webhooks/jiter",
"org": "5",
"status": "Pending",
"payload": "{'action':'buyGroceries','values':['eggs','bacon','pasta','bread']}",
"createdAt": "2022-10-05T19:51:27.000Z",
"updatedAt": "2022-10-05T19:51:27.000Z"
}

Example Error Response

{
"message": "Please enter a valid time"
}