Notifications

A Notification is our feature that sends E-Mails when specific actions occur in the folder.

Emails are sent in batches, with email frequency options of every 5 minutes, every 15 minutes, hourly, or daily. They will include a list of the matching actions within the configured notification period, limited to the first 100.

List Notifications

SDK Method

notification.List()

Return Values

Returns a *notification.Iter and an error. Range over All() to receive files_sdk.Notification values and errors. Check each loop error before using its resource. Next() and Err() remain supported.

Authorization Requirement

Available to all authenticated keys or sessions.

NotificationListParams Fields

FieldDescription
Path
string
Show notifications for this Path.
IncludeAncestors
boolean
If include_ancestors is true and path is specified, include notifications for any parent paths. Ignored if path is not specified.
GroupId
string

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/notification"
    "github.com/Files-com/files-sdk-go/v3/lib"
)

notificationIterator, err := notification.List(files_sdk.NotificationListParams{IncludeAncestors: lib.Bool(false)})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}

for notification, err := range notificationIterator.All() {
    if err != nil {
        var respErr files_sdk.ResponseError
        if errors.As(err, &respErr) {
            fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
        } else {
            fmt.Printf("Request failed: %v\n", err)
        }
        return
    }
    fmt.Println(notification)
}

Show Notification

SDK Method

notification.Find()

Return Values

Returns a files_sdk.Notification value and an error.

Authorization Requirement

Available to all authenticated keys or sessions.

NotificationFindParams Fields

FieldDescription
Id
int64
Required
Notification ID.

Example Request

import (
    "fmt"
    "errors"

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

notification, err := notification.Find(files_sdk.NotificationFindParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(notification)

Create Notification

SDK Method

notification.Create()

Return Values

Returns a files_sdk.Notification value and an error.

Authorization Requirement

Available to all authenticated keys or sessions.

NotificationCreateParams Fields

FieldDefaultDescription
UserId
int64
The id of the user to notify. Provide user_id, username or group_id.
NotifyOnCopy
boolean
If true, copying or moving resources into this path will trigger a notification, in addition to just uploads.
NotifyOnDelete
boolean
falseTrigger on files deleted in this path?
NotifyOnDownload
boolean
falseTrigger on files downloaded in this path?
NotifyOnMove
boolean
falseTrigger on files moved to this path?
NotifyOnUpload
boolean
trueTrigger on files created/uploaded/updated/changed in this path?
NotifyUserActions
boolean
If true actions initiated by the user will still result in a notification
Recursive
boolean
If true, enable notifications for each subfolder in this path
SendInterval
string
The time interval that notifications are aggregated by. Can be five_minutes, fifteen_minutes, hourly, or daily.
Subject
string
Custom subject line to use for notification emails
Message
string
Custom message to include in notification emails
TriggeringFilenames
array(string)
Array of filenames (possibly with wildcards) to scope trigger
TriggeringGroupIds
array(int64)
If set, will only notify on actions made by a member of one of the specified groups
TriggeringUserIds
array(int64)
If set, will only notify on actions made one of the specified users
TriggerByShareRecipients
boolean
falseNotify when actions are performed by a share recipient?
WorkspaceId
int64
0Workspace ID. 0 means the default workspace.
GroupId
int64
The ID of the group to notify. Provide user_id, username or group_id.
GroupIds
string
Group IDs when the notification requires multiple groups. If sent as a string, it should be comma-delimited.
Path
string
Path
Username
string
The username of the user to notify. Provide user_id, username or group_id.

Example Request

import (
    "fmt"
    "errors"

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

notification, err := notification.Create(files_sdk.NotificationCreateParams{UserId: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(notification)

Update Notification

SDK Method

notification.Update()

Return Values

Returns a files_sdk.Notification value and an error.

Authorization Requirement

Available to all authenticated keys or sessions.

NotificationUpdateParams Fields

FieldDescription
Id
int64
Required
Notification ID.
NotifyOnCopy
boolean
If true, copying or moving resources into this path will trigger a notification, in addition to just uploads.
NotifyOnDelete
boolean
Trigger on files deleted in this path?
NotifyOnDownload
boolean
Trigger on files downloaded in this path?
NotifyOnMove
boolean
Trigger on files moved to this path?
NotifyOnUpload
boolean
Trigger on files created/uploaded/updated/changed in this path?
NotifyUserActions
boolean
If true actions initiated by the user will still result in a notification
Recursive
boolean
If true, enable notifications for each subfolder in this path
SendInterval
string
The time interval that notifications are aggregated by. Can be five_minutes, fifteen_minutes, hourly, or daily.
Subject
string
Custom subject line to use for notification emails
Message
string
Custom message to include in notification emails
TriggeringFilenames
array(string)
Array of filenames (possibly with wildcards) to scope trigger
TriggeringGroupIds
array(int64)
If set, will only notify on actions made by a member of one of the specified groups
TriggeringUserIds
array(int64)
If set, will only notify on actions made one of the specified users
TriggerByShareRecipients
boolean
Notify when actions are performed by a share recipient?
WorkspaceId
int64
Workspace ID. 0 means the default workspace.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/notification"
    "github.com/Files-com/files-sdk-go/v3/lib"
)

notification, err := notification.Update(files_sdk.NotificationUpdateParams{
  Id: 1,
  NotifyOnCopy: lib.Bool(false),
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(notification)

Delete Notification

SDK Method

notification.Delete()

Return Values

Returns an error, or nil on success.

Authorization Requirement

Available to all authenticated keys or sessions.

NotificationDeleteParams Fields

FieldDescription
Id
int64
Required
Notification ID.

Example Request

import (
    "fmt"
    "errors"

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

err := notification.Delete(files_sdk.NotificationDeleteParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}

The Notification Object

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

AttributeDescription
Id
int64
Notification ID
Path
string
Folder path to notify on. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
GroupId
int64
ID of Group to receive notifications
GroupName
string
Group name, if a Group ID is set
GroupIds
array(int64)
Group IDs when the notification requires multiple groups
GroupNames
array(string)
Group names when the notification requires multiple groups
TriggeringGroupIds
array(int64)
If set, will only notify on actions made by a member of one of the specified groups
TriggeringUserIds
array(int64)
If set, will only notify on actions made one of the specified users
TriggerByShareRecipients
boolean
Notify when actions are performed by a share recipient?
NotifyUserActions
boolean
If true, will send notifications about a user's own activity to that user. If false, only activity performed by other users (or anonymous users) will be sent in notifications.
NotifyOnCopy
boolean
Trigger on files copied to this path?
NotifyOnDelete
boolean
Trigger on files deleted in this path?
NotifyOnDownload
boolean
Trigger on files downloaded in this path?
NotifyOnMove
boolean
Trigger on files moved to this path?
NotifyOnUpload
boolean
Trigger on files created/uploaded/updated/changed in this path?
Recursive
boolean
Apply notification recursively? This will enable notifications for each subfolder.
SendInterval
string
The time interval that notifications are aggregated to
Possible values: five_minutes, fifteen_minutes, hourly, daily
Subject
string
Custom subject line to use for notification emails
Message
string
Custom message to include in notification emails
TriggeringFilenames
array(string)
Array of filenames (possibly with wildcards) to scope trigger
WorkspaceId
int64
Workspace ID. 0 means the default workspace.
Unsubscribed
boolean
Is the user unsubscribed from this notification?
UnsubscribedReason
string
The reason that the user unsubscribed
Possible values: none, unsubscribe_link_clicked, mail_bounced, mail_marked_as_spam
UserId
int64
Notification user ID
Username
string
Notification username
SuppressedEmail
boolean
If true, it means that the recipient at this user's email address has manually unsubscribed from all emails, or had their email "hard bounce", which means that we are unable to send mail to this user's current email address. Notifications will resume if the user changes their email address.