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 (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    event_subscription "github.com/Files-com/files-sdk-go/v3/eventsubscription"
)

eventSubscriptionIterator, err := event_subscription.List(files_sdk.EventSubscriptionListParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for eventSubscriptionIterator.Next() {
    eventSubscription := eventSubscriptionIterator.eventSubscription()
}
err = eventSubscriptionIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.

EventSubscriptionFindParams Fields

FieldDescription
Id
int64
Required
Event Subscription ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    event_subscription "github.com/Files-com/files-sdk-go/v3/eventsubscription"
)

eventSubscription, err := event_subscription.Find(files_sdk.EventSubscriptionFindParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.

EventSubscriptionCreateParams Fields

FieldDefaultDescription
EventChannelId
int64
Event Channel ID
WorkspaceId
int64
0Workspace ID. 0 means the default workspace or site-wide.
ApplyToAllWorkspaces
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.
MessageOnly
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.
EventTypes
array(string)
Event type strings matched by this subscription. Blank means all event types.
DeliveryPolicy
object
Event Subscription delivery policy.
EventTargetIds
array(int64)
Event Target IDs this subscription sends to.

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    event_subscription "github.com/Files-com/files-sdk-go/v3/eventsubscription"
)

eventSubscription, err := event_subscription.Create(files_sdk.EventSubscriptionCreateParams{Name: "example"})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.

EventSubscriptionUpdateParams Fields

FieldDescription
Id
int64
Required
Event Subscription ID.
EventChannelId
int64
Event Channel ID
WorkspaceId
int64
Workspace ID. 0 means the default workspace or site-wide.
ApplyToAllWorkspaces
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.
MessageOnly
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.
EventTypes
array(string)
Event type strings matched by this subscription. Blank means all event types.
DeliveryPolicy
object
Event Subscription delivery policy.
EventTargetIds
array(int64)
Event Target IDs this subscription sends to.

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    event_subscription "github.com/Files-com/files-sdk-go/v3/eventsubscription"
)

eventSubscription, err := event_subscription.Update(files_sdk.EventSubscriptionUpdateParams{
  Id: 1,
  EventChannelId: 1
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.

EventSubscriptionDeleteParams Fields

FieldDescription
Id
int64
Required
Event Subscription ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    event_subscription "github.com/Files-com/files-sdk-go/v3/eventsubscription"
)

err := event_subscription.Delete(files_sdk.EventSubscriptionDeleteParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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
EventChannelId
int64
Event Channel ID
WorkspaceId
int64
Workspace ID. 0 means the default workspace or site-wide.
ApplyToAllWorkspaces
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.
MessageOnly
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.
EventTypes
array(string)
Event type strings matched by this subscription. Blank means all event types.
Filter
object
Structured event payload filter.
DeliveryPolicy
object
Event Subscription delivery policy.
EventTargetIds
array(int64)
Event Target IDs this subscription sends to.
CreatedAt
date-time
Event Subscription create date/time.
UpdatedAt
date-time
Event Subscription update date/time.