# Custom Events

Source: https://dev.arcxp.com/integrations/events/ifx-custom-events/

This document explains what IFX events are, how to receive them in your integration, where to find events, how to subscribe to events and how to create custom events which can be used for Inbound Webhooks or for scheduled events.

You can create your own **custom events**, private to your organization. Custom events can be used in two ways:

1. Create an [Inbound Webhook](https://dev.arcxp.com/integrations/webhooks/ifx-inbound-webhooks/) that will invoke an integration
2. Create an event that will run on a scheduled basis

> **Tip:**
> 
> A custom event is used for _either_ an Inbound Webhook or is scheduled — it cannot be used for both.

## Creating a Custom Event

Create a custom event by sending a `POST` request to the [/admin/events/custom](https://dev.arcxp.com/api/integrations/integrations-production/) endpoint.

```json
{
  "eventName": "custom:descriptive_name",
  "description": "This event receives notifications from ABC service."
}
```

## Creating Scheduled Events

**Scheduled events** are triggered based on time, running without user action on a defined interval such as once a week. Scheduled integrations can be used for automatically triggering an integration to perform tasks such as generating reports, or reaching out to any API (Arc or external) to gather the necessary data to perform such tasks.

IFX scheduled events use the **six-field** [AWS Cron Expression](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html) format (no seconds value). You can use a generator such as [Crontab Generator](https://www.freetool.dev/crontab-generator/).

Create a scheduled, custom event by sending a `POST` request to the [/admin/events/custom](https://dev.arcxp.com/api/integrations/integrations-production/) endpoint. In this case you will provide the `schedule` parameter:

```json
{
  "eventName": "custom:descriptive_name",
  "description": "This is a scheduled event that will run at 12:00:00pm, on Wednesdays.",
  "schedule": {
    "cron": "0 12 ? * WED *"
  }
}
```

## Modifying an Event’s Schedule

Modify an event’s schedule by sending a `PUT` request to the [/admin/events/custom/:eventName](https://dev.arcxp.com/api/integrations/integrations-production/) endpoint.

```json
{
  "description": "This is my event that will run every 7 days at noon.",
  "schedule": {
    "cron": "0 0 12 */7 * ? "
  }
}
```

## Deleting a Schedule

You can delete an event’s schedule without deleting the event itself (this action cannot be undone). Send a `DELETE` request to the [/admin/events/custom/:eventName/schedule](https://dev.arcxp.com/api/integrations/integrations-production/) endpoint.

## What type of schedules can be set up?

You can set up any schedule that is **greater than five minutes**. You can specify frequencies such as:

- Minutes
- Hours
- Day of the month
- Month
- Day of the week
- Year

For example, the **six-field** cron expression `0 0 ? * SUN *` is described as `At 00:00:00, on every Sunday, every month`. You can learn more about cron schedules here: [Crontab Generator](https://www.freetool.dev/crontab-generator/).

## What about failures or guaranteed delivery of messages to IFX?

Your integration should handle errors. Using the Node.js language, you should use a [try/catch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) statement, where on catch (error) you would need to decide what action you would like to take.

---
  
Have a feature request or suggestion? Let us know on [Our Ideas Portal](https://ideas.arcxp.com/?project=IFX).
