Skip to main content

states

Creates, updates, deletes, gets or lists a states resource.

Overview​

Namestates
TypeResource
Idfivetran.connections.states

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
statestringA freeform JSON object representing the connector's cursor or internal state. The structure is defined by the connector implementation and varies by connector type. Returns 400 if no state has been written yet. (opaque JSON object)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectconnection_idThis endpoint returns the connection state for [Function](https:​//fivetran.com/docs/connectors/functions) and [Connector SDK](https:​//fivetran.com/docs/connector-sdk) connections. Sending a request for any other connection type returns 400 Bad Request. To update the connection state, use [Update Connection State](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection-state).<br /><br />To read the sync status for any connection type, use [Retrieve connection details](https:​//fivetran.com/docs/rest-api/api-reference/connections/connection-details) and inspect the status object in the response.<br />
updateupdateconnection_idUpdates the connection state. This endpoint is only supported for [Function](https:​//fivetran.com/docs/connectors/functions) and [Connection SDK](https:​//fivetran.com/docs/connectors/connector-sdk) connectors. To update the state, you should pause your connection first.<br /><br />To update the connection state, do the following:<br /><br /> 1. Pause connection using [Update a Connection](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection) endpoint (set 'paused' to 'true').<br /> 2. Update the state by using the [Update Connection State](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection-state) endpoint.<br /> 3. Unpause the connection by setting the 'paused' parameter to 'false' in the [Update a Connection](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection) endpoint request.<br />

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
connection_idstringThe unique identifier of the connection. Retrieve it from the id field in the [List All Connections](https:​//fivetran.com/docs/rest-api/api-reference/connections/list-connections) response, or from the id field returned when you [Create a Connection](https:​//fivetran.com/docs/rest-api/api-reference/connections/create-connection).

SELECT examples​

This endpoint returns the connection state for [Function](https:​//fivetran.com/docs/connectors/functions) and [Connector SDK](https:​//fivetran.com/docs/connector-sdk) connections. Sending a request for any other connection type returns 400 Bad Request. To update the connection state, use [Update Connection State](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection-state).<br /><br />To read the sync status for any connection type, use [Retrieve connection details](https:​//fivetran.com/docs/rest-api/api-reference/connections/connection-details) and inspect the status object in the response.<br />

SELECT
state
FROM fivetran.connections.states
WHERE connection_id = '{{ connection_id }}' -- required
;

UPDATE examples​

Updates the connection state. This endpoint is only supported for [Function](https:​//fivetran.com/docs/connectors/functions) and [Connection SDK](https:​//fivetran.com/docs/connectors/connector-sdk) connectors. To update the state, you should pause your connection first.<br /><br />To update the connection state, do the following:<br /><br /> 1. Pause connection using [Update a Connection](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection) endpoint (set 'paused' to 'true').<br /> 2. Update the state by using the [Update Connection State](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection-state) endpoint.<br /> 3. Unpause the connection by setting the 'paused' parameter to 'false' in the [Update a Connection](https:​//fivetran.com/docs/rest-api/api-reference/connections/modify-connection) endpoint request.<br />

UPDATE fivetran.connections.states
SET
state = '{{ state }}'
WHERE
connection_id = '{{ connection_id }}' --required
RETURNING
state;