NetlifyExtensionClient
The NetlifyExtensionClient
provides different methods to interact with both the Netlify API and the Extension API.
Review TypeScript definitions in the SDK
When you install the Netlify SDK, you have access to the TypeScript definitions directly in the @netlify/sdk
package. You can browse through the definition files individually or review the type definition inline depending on your code editor.
Usage example
Methods
createConnectConfiguration
createConnectConfiguration({ teamId, dataLayerId, config, name, prefix? })
Creates a Connect configuration for an extension installation.
Parameters
Name | Type |
---|---|
teamId | string |
dataLayerId | string |
config | ConnectorConfiguration |
name | string |
prefix | string optional |
Returns
An empty Promise
.
createEnvironmentVariable
createEnvironmentVariable({ accountId, siteId, key, values })
Creates a new environment variable for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
isSecret | boolean optional Defaults to false. |
key | string |
scopes | EnvironmentVariableScopeType [] optional |
siteId | string optional |
values | EnvironmentVariableValue [] |
Returns
A Promise
with an EnvironmentVariableValue
object.
createOrUpdateVariable
createOrUpdateVariable({ accountId, siteId, key, value })
Creates or updates a single environment variable for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
isSecret | boolean optional. Defaults to false. |
key | string |
scopes | EnvironmentVariableScopeType [] optional |
siteId | string optional |
value | EnvVarRequest |
Returns
A Promise
with an EnvironmentVariable
object.
createOrUpdateVariables
createOrUpdateVariables({ accountId, siteId, variables })
Creates or updates all environment variables in the variables
object for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
isSecret | boolean optional. Defaults to false. |
scopes | EnvironmentVariableScopeType [] optional |
siteId | string optional |
variables | Record<string, EnvVarRequest> |
Returns
A Promise
with an array of EnvironmentVariable
.
createSiteConfiguration
createSiteConfiguration(teamId, siteId, config)
Creates a site configuration for an extension installation.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
config | SiteConfiguration |
Returns
An empty Promise
.
createTeamConfiguration
createTeamConfiguration(teamId, config)
Creates a team configuration for an extension installation.
Parameters
Name | Type |
---|---|
teamId | string |
config | TeamConfiguration |
Returns
An empty Promise
.
createVisualEditorConfiguration
createVisualEditorConfiguration({ teamId, siteId, config, name, projectId, prefix })
Creates a visual editor configuration for an extension installation.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
dataLayerId | string |
config | ConnectorConfiguration |
name | string |
projectId | string |
prefix | string |
Returns
An empty Promise
.
deleteConnectConfiguration
deleteConnectConfiguration({ teamId, dataLayerId, configurationId })
Deletes a Connect configuration for uninstalling the extension.
Parameters
Name | Type |
---|---|
teamId | string |
dataLayerId | string |
configurationId | string |
Returns
An empty Promise
.
deleteEnvironmentVariable
deleteEnvironmentVariable({ accountId, siteId, key })
Deletes an environment variable for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string optional |
key | string |
Returns
An empty Promise
.
deleteEnvironmentVariables
deleteEnvironmentVariables({ accountId, siteId, variables })
Deletes all environment variables specified in the variables
array for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string optional |
variables | string [] |
Returns
An empty Promise
.
deleteSiteConfiguration
deleteSiteConfiguration(teamId, siteId)
Deletes a site configuration for uninstalling the extension.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
Returns
An empty Promise
.
deleteTeamConfiguration
deleteTeamConfiguration(teamId)
Deletes a team configuration for uninstalling the extension.
Parameters
Name | Type |
---|---|
teamId | string |
Returns
An empty Promise
.
deleteVisualEditorConfiguration
deleteVisualEditorConfiguration({ teamId, siteId, configurationId, projectId })
Deletes a visual editor configuration for uninstalling the extension.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
configurationId | string |
projectId | string |
Returns
An empty Promise
.
getAccount
getAccount(accountId)
Gets an account by ID and returns account information.
Parameters
Name | Type |
---|---|
accountId | string |
Returns
A Promise
with an Account
object.
getConnectConfiguration
getConnectConfiguration(teamId, dataLayerId, configurationId)
Gets a Connect configuration by the specified team ID, data layer ID, and configuration ID.
Parameters
Name | Type |
---|---|
teamId | string |
dataLayerId | string |
configurationId | string |
Returns
A Promise
with an ConnectorConfiguration
object.
getEnvironmentVariables
getEnvironmentVariables({ accountId, siteId })
Gets all environment variables for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string optional |
Returns
A Promise
with an array of EnvironmentVariable
.
getSite
getSite(siteId)
Gets a site by ID and returns site information.
Parameters
Name | Type |
---|---|
siteId | string |
Returns
A Promise
with a Site
.
getSiteConfiguration
getSiteConfiguration(teamId, siteId)
Returns the extension configuration for a site for the current extension.
Parameters
Name | Type |
---|---|
siteId | string |
teamId | string |
Returns
A Promise
with an ExtensionResponse
) object.
getSites
getSites()
Gets all sites for an account.
Returns
A Promise
with an array of Site
.
getTeamConfiguration
getTeamConfiguration(teamId)
Returns the extension configuration for a team for the current extension.
Parameters
Name | Type |
---|---|
teamId | string |
Returns
Returns a Promise
with an ExtensionResponse
object.
getVisualEditorConfiguration
getVisualEditorConfiguration(teamId, siteId, configurationId)
Gets a visual editor configuration by the specified team ID, data layer ID, and configuration ID.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
configurationId | string |
Returns
A Promise
with an ConnectorConfiguration
object.
installExtensionOnTeam
installExtensionOnTeam(teamId, hasDataIntegration)
Installs this extension for a team.
Parameters
Name | Type |
---|---|
hasDataIntegration | boolean |
teamId | string |
Returns
An empty Promise
.
patchEnvironmentVariable
patchEnvironmentVariable({ accountId, siteId, key, context, value, contextParameter })
Creates or updates an environment variable for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string optional |
key | string |
context | string |
value | string |
contextParameter | string optional |
Returns
A Promise
with an EnvironmentVariable
object.
removeBuildToken
removeBuildToken(accountId, siteId)
Removes the build token for a site.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string |
Returns
An empty Promise
.
setBuildToken
setBuildToken(accountId, siteId, token)
Sets the build token for a site. Build tokens can be created using the generateBuildToken
method.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string |
token | string |
Returns
A Promise
with an EnvironmentVariable
object.
uninstallExtensionOnTeam
uninstallExtensionOnTeam(teamId)
Uninstalls this extension for a team, which also deletes the configuration.
Parameters
Name | Type |
---|---|
teamId | string |
Returns
An empty Promise
.
updateConnectConfiguration
updateConnectConfiguration({teamId, dataLayerId, configurationId, name, prefix?, config})
Updates a Connect configuration, based on the specified configuration ID.
Parameters
Name | Type |
---|---|
teamId | string |
dataLayerId | string |
configurationId | string |
name | string |
prefix | string optional |
config | ConnectorConfiguration |
Returns
An empty Promise
.
updateEnvironmentVariable
updateEnvironmentVariable({ accountId, siteId, key, values })
Updates an existing environment variable for a site when passed a siteId
. When not passed a siteId
, operates on the team level.
Parameters
Name | Type |
---|---|
accountId | string |
siteId | string optional |
key | string |
values | EnvironmentVariableValue [] |
Returns
A Promise
with an EnvironmentVariable
object.
updateSite
updateSite(siteId, changes?)
Updates a site with the given changes.
Parameters
Name | Type |
---|---|
siteId | string |
changes | Partial<Site> |
Returns
A Promise
with a Site
object.
updateSiteConfiguration
updateSiteConfiguration(teamId, siteId, config)
Updates the extension configuration for a site.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
config | SiteConfiguration |
Returns
An empty Promise
.
updateTeamConfiguration
updateTeamConfiguration(teamId, config)
Updates the extension configuration for a team.
Parameters
Name | Type |
---|---|
teamId | string |
config | TeamConfiguration |
Returns
An empty Promise
.
updateVisualEditorConfiguration
updateVisualEditorConfiguration({teamId, siteId, configurationId, config, name, projectId, prefix })
Updates a visual editor configuration, based on the specified configuration ID.
Parameters
Name | Type |
---|---|
teamId | string |
siteId | string |
configurationId | string |
config | ConnectorConfiguration |
name | string |
projectId | string |
prefix | string |
Returns
An empty Promise
.