# Interface: SyncFormulaDef\<K, L, ParamDefsT, SchemaT, ContextT, PermissionsContextT>

Defined in: [api.ts:1382](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1382)

Inputs for creating the formula that implements a sync table.

## Extends

- [`CommonPackFormulaDef`](../CommonPackFormulaDef/)\<`ParamDefsT`>.`OnErrorFormulaOptions`

## Type Parameters

| Type Parameter | | --- | | `K` *extends* `string` | | `L` *extends* `string` | | `ParamDefsT` *extends* [`ParamDefs`](../../type-aliases/ParamDefs/) | | `SchemaT` *extends* [`ObjectSchemaDefinition`](../ObjectSchemaDefinition/)\<`K`, `L`> | | `ContextT` *extends* [`SyncExecutionContext`](../SyncExecutionContext/)\<`any`, `any`> | | `PermissionsContextT` *extends* `SyncPassthroughData` |

## Properties

### cacheTtlSecs?

> `readonly` `optional` **cacheTtlSecs**: `number`

Defined in: [api_types.ts:593](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L593)

How long formulas running with the same values should cache their results for.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`cacheTtlSecs`](../CommonPackFormulaDef/#cachettlsecs)

______________________________________________________________________

### connectionRequirement?

> `readonly` `optional` **connectionRequirement**: [`ConnectionRequirement`](../../enumerations/ConnectionRequirement/)

Defined in: [api_types.ts:585](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L585)

Does this formula require a connection (aka an account)?

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`connectionRequirement`](../CommonPackFormulaDef/#connectionrequirement)

______________________________________________________________________

### description

> `readonly` **description**: `string`

Defined in: [api_types.ts:554](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L554)

A brief description of what the formula does.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`description`](../CommonPackFormulaDef/#description)

______________________________________________________________________

### examples?

> `readonly` `optional` **examples**: `object`[]

Defined in: [api_types.ts:574](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L574)

Sample inputs and outputs demonstrating usage of this formula.

#### params

> **params**: ([`PackFormulaValue`](../../type-aliases/PackFormulaValue/) | `undefined`)[]

#### result

> **result**: [`PackFormulaResult`](../../type-aliases/PackFormulaResult/)

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`examples`](../CommonPackFormulaDef/#examples)

______________________________________________________________________

### extraOAuthScopes?

> `readonly` `optional` **extraOAuthScopes**: `string`[]

Defined in: [api_types.ts:621](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L621)

OAuth scopes that the formula needs that weren't requested in the pack's overall authentication config. For example, a Slack pack can have one formula that needs admin privileges, but non-admins can use the bulk of the pack without those privileges. The platform will give users help in understanding that they need additional authentication to use a formula with extra OAuth scopes. Note that these scopes will always be requested in addition to the default scopes for the pack, so an end user must have both sets of permissions.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`extraOAuthScopes`](../CommonPackFormulaDef/#extraoauthscopes)

______________________________________________________________________

### instructions?

> `readonly` `optional` **instructions**: `string`

Defined in: [api_types.ts:559](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L559)

Instructions for LLMs to use the formula, overrides the description for LLMs if set.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`instructions`](../CommonPackFormulaDef/#instructions)

______________________________________________________________________

### isAction?

> `readonly` `optional` **isAction**: `boolean`

Defined in: [api_types.ts:580](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L580)

Does this formula take an action (vs retrieve data or make a calculation)? Actions are presented as buttons in the Coda UI.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`isAction`](../CommonPackFormulaDef/#isaction)

______________________________________________________________________

### isExperimental?

> `readonly` `optional` **isExperimental**: `boolean`

Defined in: [api_types.ts:599](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L599)

If specified, the formula will not be suggested to users in the formula autocomplete. The formula can still be invoked by manually typing its full name.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`isExperimental`](../CommonPackFormulaDef/#isexperimental)

______________________________________________________________________

### isSystem?

> `readonly` `optional` **isSystem**: `boolean`

Defined in: [api_types.ts:605](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L605)

Whether this is a formula that will be used internally and not exposed directly to users. Not for use by packs that are not Superhuman-authored.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`isSystem`](../CommonPackFormulaDef/#issystem)

______________________________________________________________________

### maxUpdateBatchSize?

> `optional` **maxUpdateBatchSize**: `number`

Defined in: [api.ts:1407](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1407)

If the table supports object updates, the maximum number of objects that will be sent to the pack in a single batch. Defaults to 1 if not specified.

______________________________________________________________________

### name

> `readonly` **name**: `string`

Defined in: [api_types.ts:549](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L549)

The name of the formula, used to invoke it.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`name`](../CommonPackFormulaDef/#name)

______________________________________________________________________

### ~~network?~~

> `readonly` `optional` **network**: [`Network`](../Network/)

Defined in: [api_types.ts:588](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L588)

#### Deprecated

use `isAction` and `connectionRequirement` instead

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`network`](../CommonPackFormulaDef/#network)

______________________________________________________________________

### parameters

> `readonly` **parameters**: `ParamDefsT`

Defined in: [api_types.ts:564](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L564)

The parameter inputs to the formula, if any.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`parameters`](../CommonPackFormulaDef/#parameters)

______________________________________________________________________

### validateParameters?

> `optional` **validateParameters**: [`MetadataFormula`](../../type-aliases/MetadataFormula/)\<[`SyncExecutionContext`](../SyncExecutionContext/)\<[`Continuation`](../Continuation/), [`Continuation`](../Continuation/), [`Continuation`](../Continuation/)>, [`ParameterValidationResult`](../../type-aliases/ParameterValidationResult/)>

Defined in: [api.ts:1456](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1456)

The JavaScript function that implements parameter validation. For sync tables, the execution context will include a `sync` field.

#### Overrides

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`validateParameters`](../CommonPackFormulaDef/#validateparameters)

______________________________________________________________________

### varargParameters?

> `readonly` `optional` **varargParameters**: [`ParamDefs`](../../type-aliases/ParamDefs/)

Defined in: [api_types.ts:569](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api_types.ts#L569)

Variable argument parameters, used if this formula should accept arbitrary numbers of inputs.

#### Inherited from

[`CommonPackFormulaDef`](../CommonPackFormulaDef/).[`varargParameters`](../CommonPackFormulaDef/#varargparameters)

## Methods

### execute()

> **execute**\<`ContextReturnT`>(`params`, `context`): `Promise`\<[`SyncFormulaResult`](../SyncFormulaResult/)\<`K`, `L`, `SchemaT`, `ContextReturnT`, `PermissionsContextT`>>

Defined in: [api.ts:1398](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1398)

The JavaScript function that implements this sync.

This function takes in parameters and a sync context which may have a continuation from a previous invocation, and fetches and returns one page of results, as well as another continuation if there are more result to fetch.

#### Type Parameters

| Type Parameter | | --- | | `ContextReturnT` *extends* [`SyncExecutionContext`](../SyncExecutionContext/)\<`any`, `any`, `any`> |

#### Parameters

| Parameter | Type | | --- | --- | | `params` | [`ParamValues`](../../type-aliases/ParamValues/)\<`ParamDefsT`> | | `context` | `ContextT` |

#### Returns

`Promise`\<[`SyncFormulaResult`](../SyncFormulaResult/)\<`K`, `L`, `SchemaT`, `ContextReturnT`, `PermissionsContextT`>>

______________________________________________________________________

### executeUpdate()?

> `optional` **executeUpdate**(`params`, `updates`, `context`): `Promise`\<[`SyncUpdateResult`](../SyncUpdateResult/)\<`K`, `L`, `SchemaT`>>

Defined in: [api.ts:1415](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1415)

The JavaScript function that implements this sync update if the table supports updates.

This function takes in parameters, updated sync table objects, and a sync context, and is responsible for pushing those updated objects to the external system then returning the new state of each object.

#### Parameters

| Parameter | Type | | --- | --- | | `params` | [`ParamValues`](../../type-aliases/ParamValues/)\<`ParamDefsT`> | | `updates` | [`SyncUpdate`](../SyncUpdate/)\<`K`, `L`, `SchemaT`>[] | | `context` | [`UpdateSyncExecutionContext`](../UpdateSyncExecutionContext/) |

#### Returns

`Promise`\<[`SyncUpdateResult`](../SyncUpdateResult/)\<`K`, `L`, `SchemaT`>>

______________________________________________________________________

### onError()?

> `optional` **onError**(`error`): `any`

Defined in: [api.ts:1703](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1703)

If specified, will catch errors in the [execute](#execute) function and call this function with the error, instead of letting them throw and the formula failing.

This is helpful for writing common error handling into a singular helper function that can then be applied to many different formulas in a pack.

#### Parameters

| Parameter | Type | | --- | --- | | `error` | `Error` |

#### Returns

`any`

#### Inherited from

`OnErrorFormulaOptions.onError`
