Syncs

A Sync represents a file synchronization job between two locations (local-remote, remote-remote, local-child_site, etc). It can be scheduled, run manually, or triggered by custom logic. Syncs track their runs, status, and configuration.

List Syncs

SDK Method

sync.List()

Return Object

[]*Sync

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"
    "github.com/Files-com/files-sdk-go/v3/sync"
)

syncIterator, err := sync.List(files_sdk.SyncListParams{})
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 syncIterator.Next() {
    sync := syncIterator.sync()
}
err = syncIterator.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 Sync

SDK Method

sync.Find()

Return Object

Sync

Authorization Requirement

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

SyncFindParams Fields

FieldDescription
Id
int64
Required
Sync ID.

Example Request

import (
    "fmt"
    "errors"

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

sync, err := sync.Find(files_sdk.SyncFindParams{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 Sync

SDK Method

sync.Create()

Return Object

Sync

Authorization Requirement

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

SyncCreateParams Fields

FieldDefaultDescription
DeleteEmptyFolders
boolean
falseDelete empty folders after sync?
Description
string
Description for this sync job
DestPath
string
""Absolute destination path for the sync
DestRemoteServerId
int64
Remote server ID for the destination (if remote)
Disabled
boolean
falseIs this sync disabled?
ExcludePatterns
array(string)
Array of glob patterns to exclude
HolidayRegion
string
Skip the sync if there is a formal, observed holiday for this region.
IncludePatterns
array(string)
Array of glob patterns to include
Interval
string
If trigger is daily, this specifies how often to run this sync. One of: day, week, week_end, month, month_end, quarter, quarter_end, year, year_end
KeepAfterCopy
boolean
trueKeep files after copying?
Name
string
Name for this sync job
RecurringDay
int64
If trigger type is daily, this specifies a day number to run in one of the supported intervals: week, month, quarter, year.
RecurringDays
array(int64)
If trigger type is daily, this specifies one or more day numbers to run in one of the supported intervals: week, month, quarter, year.
ScheduleId
int64
If trigger is custom_schedule, the reusable Schedule used instead of the sync's schedule fields.
ScheduleDaysOfWeek
array(int64)
If trigger is custom_schedule, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
ScheduleTimeZone
string
Time zone for the schedule. If not set, times are interpreted as UTC.
ScheduleTimesOfDay
array(string)
Times of day to run in HH:MM format. For custom_schedule, run at these times on specified days of week. For daily, run at these times on the scheduled interval date.
SrcPath
string
""Absolute source path for the sync
SrcRemoteServerId
int64
Remote server ID for the source (if remote)
SyncIntervalMinutes
int64
Frequency in minutes between syncs. If set, this value must be greater than or equal to the remote_sync_interval value for the site's plan. If left blank, the plan's remote_sync_interval will be used. This setting is only used if trigger is empty.
Trigger
string
Trigger type: daily, custom_schedule, or manual
Possible values: daily, custom_schedule, manual
TriggerFile
string
Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
AlwaysWriteTriggerFile
boolean
falseIf true, the trigger file will be sent at the end of a successful sync even when no files were transferred.
WorkspaceId
int64
0Workspace ID this sync belongs to

Example Request

import (
    "fmt"
    "errors"

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

sync, err := sync.Create(files_sdk.SyncCreateParams{DeleteEmptyFolders: lib.Bool(true)})
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())
    }
}

Dry Run Sync

SDK Method

sync.DryRun()

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.

SyncDryRunParams Fields

FieldDescription
Id
int64
Required
Sync ID.

Example Request

import (
    "fmt"
    "errors"

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

err := sync.DryRun(files_sdk.SyncDryRunParams{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())
    }
}

Manually Run Sync

SDK Method

sync.ManualRun()

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.

SyncManualRunParams Fields

FieldDescription
Id
int64
Required
Sync ID.

Example Request

import (
    "fmt"
    "errors"

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

err := sync.ManualRun(files_sdk.SyncManualRunParams{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())
    }
}

Update Sync

SDK Method

sync.Update()

Return Object

Sync

Authorization Requirement

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

SyncUpdateParams Fields

FieldDescription
Id
int64
Required
Sync ID.
DeleteEmptyFolders
boolean
Delete empty folders after sync?
Description
string
Description for this sync job
DestPath
string
Absolute destination path for the sync
DestRemoteServerId
int64
Remote server ID for the destination (if remote)
Disabled
boolean
Is this sync disabled?
ExcludePatterns
array(string)
Array of glob patterns to exclude
HolidayRegion
string
Skip the sync if there is a formal, observed holiday for this region.
IncludePatterns
array(string)
Array of glob patterns to include
Interval
string
If trigger is daily, this specifies how often to run this sync. One of: day, week, week_end, month, month_end, quarter, quarter_end, year, year_end
KeepAfterCopy
boolean
Keep files after copying?
Name
string
Name for this sync job
RecurringDay
int64
If trigger type is daily, this specifies a day number to run in one of the supported intervals: week, month, quarter, year.
RecurringDays
array(int64)
If trigger type is daily, this specifies one or more day numbers to run in one of the supported intervals: week, month, quarter, year.
ScheduleId
int64
If trigger is custom_schedule, the reusable Schedule used instead of the sync's schedule fields.
ScheduleDaysOfWeek
array(int64)
If trigger is custom_schedule, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
ScheduleTimeZone
string
Time zone for the schedule. If not set, times are interpreted as UTC.
ScheduleTimesOfDay
array(string)
Times of day to run in HH:MM format. For custom_schedule, run at these times on specified days of week. For daily, run at these times on the scheduled interval date.
SrcPath
string
Absolute source path for the sync
SrcRemoteServerId
int64
Remote server ID for the source (if remote)
SyncIntervalMinutes
int64
Frequency in minutes between syncs. If set, this value must be greater than or equal to the remote_sync_interval value for the site's plan. If left blank, the plan's remote_sync_interval will be used. This setting is only used if trigger is empty.
Trigger
string
Trigger type: daily, custom_schedule, or manual
Possible values: daily, custom_schedule, manual
TriggerFile
string
Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
AlwaysWriteTriggerFile
boolean
If true, the trigger file will be sent at the end of a successful sync even when no files were transferred.

Example Request

import (
    "fmt"
    "errors"

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

sync, err := sync.Update(files_sdk.SyncUpdateParams{
  Id: 1,
  DeleteEmptyFolders: lib.Bool(true)
})
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 Sync

SDK Method

sync.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.

SyncDeleteParams Fields

FieldDescription
Id
int64
Required
Sync ID.

Example Request

import (
    "fmt"
    "errors"

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

err := sync.Delete(files_sdk.SyncDeleteParams{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 Sync Object

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

AttributeDescription
Id
int64
Sync ID
Name
string
Name for this sync job
Description
string
Description for this sync job
SiteId
int64
Site ID this sync belongs to
WorkspaceId
int64
Workspace ID this sync belongs to
UserId
int64
User who created or owns this sync
SrcPath
string
Absolute source path for the sync
DestPath
string
Absolute destination path for the sync
SrcRemoteServerId
int64
Remote server ID for the source (if remote)
DestRemoteServerId
int64
Remote server ID for the destination (if remote)
SrcSiteId
int64
Source site ID if syncing from a child or partner site
DestSiteId
int64
Destination site ID if syncing to a child or partner site
TwoWay
boolean
Is this a two-way sync?
KeepAfterCopy
boolean
Keep files after copying?
DeleteEmptyFolders
boolean
Delete empty folders after sync?
Disabled
boolean
Is this sync disabled?
Trigger
string
Trigger type: daily, custom_schedule, or manual
Possible values: daily, custom_schedule, manual
TriggerFile
string
Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
AlwaysWriteTriggerFile
boolean
If true, the trigger file will be sent at the end of a successful sync even when no files were transferred.
IncludePatterns
array(string)
Array of glob patterns to include
ExcludePatterns
array(string)
Array of glob patterns to exclude
CreatedAt
date-time
When this sync was created
UpdatedAt
date-time
When this sync was last updated
SyncIntervalMinutes
int64
Frequency in minutes between syncs. If set, this value must be greater than or equal to the remote_sync_interval value for the site's plan. If left blank, the plan's remote_sync_interval will be used. This setting is only used if trigger is empty.
Interval
string
If trigger is daily, this specifies how often to run this sync. One of: day, week, week_end, month, month_end, quarter, quarter_end, year, year_end
RecurringDay
int64
If trigger type is daily, this specifies a day number to run in one of the supported intervals: week, month, quarter, year.
RecurringDays
array(int64)
If trigger type is daily, this specifies one or more day numbers to run in one of the supported intervals: week, month, quarter, year.
ScheduleId
int64
If trigger is custom_schedule, the reusable Schedule used instead of the sync's schedule fields.
ScheduleDaysOfWeek
array(int64)
If trigger is custom_schedule, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
ScheduleTimesOfDay
array(string)
Times of day to run in HH:MM format. For custom_schedule, run at these times on specified days of week. For daily, run at these times on the scheduled interval date.
ScheduleTimeZone
string
Time zone for the schedule. If not set, times are interpreted as UTC.
HolidayRegion
string
Skip the sync if there is a formal, observed holiday for this region.
LatestSyncRun
SyncRun
The latest run of this sync