Event Subscriptions

An EventSubscription selects EventRecords for an EventChannel and sends them to one or more EventTargets.

List Event Subscriptions

SDK Method

EventSubscription.list()

Return Object

EventSubscription[]

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

import EventSubscription from 'files.com/lib/models/EventSubscription';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const eventSubscriptions = await EventSubscription.list();
  for (const eventSubscription of eventSubscriptions) {
    // Operate on eventSubscription
  }
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Show Event Subscription

SDK Method

EventSubscription.find()

Return Object

EventSubscription

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
id
int64
Required
Event Subscription ID.

Example Request

import EventSubscription from 'files.com/lib/models/EventSubscription';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const eventSubscription = await EventSubscription.find(id);
  // Operate on eventSubscription
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Create Event Subscription

SDK Method

EventSubscription.create()

Return Object

EventSubscription

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDefaultDescription
event_channel_id
int64
Event Channel ID
workspace_id
int64
0Workspace ID. 0 means the default workspace or site-wide.
apply_to_all_workspaces
boolean
falseIf true, this default-workspace subscription applies to events from all workspaces.
name
string
Required
Event Subscription name.
subject
string
Custom subject line to use for notification emails.
message
string
Custom message to include in notification emails.
message_only
boolean
falseIf true, notification email bodies contain only the custom message, omitting event details and the review button. Requires a custom message, defaults to false, and does not affect non-email targets.
enabled
boolean
trueWhether this Event Subscription can dispatch events.
event_types
array(string)
Event type strings matched by this subscription. Blank means all event types.
delivery_policy
object
Event Subscription delivery policy.
event_target_ids
array(int64)
Event Target IDs this subscription sends to.

Additional Arguments

Example Request

import EventSubscription from 'files.com/lib/models/EventSubscription';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const eventSubscription = await EventSubscription.create({
    name: "example",
  });
  // Operate on eventSubscription
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Update Event Subscription

SDK Method

eventSubscription.update()

Return Object

EventSubscription

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
event_channel_id
int64
Event Channel ID
workspace_id
int64
Workspace ID. 0 means the default workspace or site-wide.
apply_to_all_workspaces
boolean
If true, this default-workspace subscription applies to events from all workspaces.
name
string
Event Subscription name.
subject
string
Custom subject line to use for notification emails.
message
string
Custom message to include in notification emails.
message_only
boolean
If true, notification email bodies contain only the custom message, omitting event details and the review button. Requires a custom message, defaults to false, and does not affect non-email targets.
enabled
boolean
Whether this Event Subscription can dispatch events.
event_types
array(string)
Event type strings matched by this subscription. Blank means all event types.
delivery_policy
object
Event Subscription delivery policy.
event_target_ids
array(int64)
Event Target IDs this subscription sends to.

Additional Arguments

Example Request

import EventSubscription from 'files.com/lib/models/EventSubscription';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the eventSubscription object by its id.
  const eventSubscription = await EventSubscription.find(id);
  await eventSubscription.update({
    event_channel_id: 1,
  });
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Delete Event Subscription

SDK Method

eventSubscription.delete()

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Example Request

import EventSubscription from 'files.com/lib/models/EventSubscription';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the eventSubscription object by its id.
  const eventSubscription = await EventSubscription.find(id);
  await eventSubscription.delete();
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The EventSubscription Object

Some of the methods above return a EventSubscription object. The attributes of this object are listed below.

AttributeDescription
id
int64
Event Subscription ID
event_channel_id
int64
Event Channel ID
workspace_id
int64
Workspace ID. 0 means the default workspace or site-wide.
apply_to_all_workspaces
boolean
If true, this default-workspace subscription applies to events from all workspaces.
name
string
Event Subscription name.
subject
string
Custom subject line to use for notification emails.
message
string
Custom message to include in notification emails.
message_only
boolean
If true, notification email bodies contain only the custom message, omitting event details and the review button. Requires a custom message, defaults to false, and does not affect non-email targets.
enabled
boolean
Whether this Event Subscription can dispatch events.
event_types
array(string)
Event type strings matched by this subscription. Blank means all event types.
filter
object
Structured event payload filter.
delivery_policy
object
Event Subscription delivery policy.
event_target_ids
array(int64)
Event Target IDs this subscription sends to.
created_at
date-time
Event Subscription create date/time.
updated_at
date-time
Event Subscription update date/time.