Skip to content

NetlifyExtensionClient

The NetlifyExtensionClient provides different methods to interact with both the Netlify API and the Extension API.

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.

import { withNetlifySDKContext } from "@netlify/sdk/ui/functions";
export default withNetlifySDKContext((req, context) => {
const { accountId, auth, client } = context;
const accountInfo = await client.getAccount(accountId);
// Using the user’s OAuth connection to make a request to a third-party API
await fetch("https://api.example.com/project", {
headers: {
Authorization: `Bearer ${auth.providerToken}`,
},
method: "POST",
body: JSON.stringify({
name: `project_${accountInfo.name}`,
}),
});
return Response.json({});
});
  • NetlifyClient
Type Parameter
SiteConfiguration
TeamConfiguration

new NetlifyExtensionClient<SiteConfiguration, TeamConfiguration>(netlifyToken, extension, __namedParameters): NetlifyExtensionClient<SiteConfiguration, TeamConfiguration>

ParameterType
netlifyTokenstring
extensionstring
__namedParametersExtensionClientOptions

NetlifyExtensionClient<SiteConfiguration, TeamConfiguration>

NetlifyClient.constructor

PropertyTypeInherited from
apiKeystringNetlifyClient.apiKey
extensionstring-
extensionApiWretch<unknown, unknown, undefined>-
netlifyToken?string-
siteConfigId?string-
teamConfigId?string-
wretchWretch<unknown, unknown, undefined>NetlifyClient.wretch

cancelSiteDeploy(deployId): Promise<object>

Cancels an in-progress deployment.

ParameterType
deployIdstring

Promise<object>

NameType
adminUrlstring
availableFunctionsstring[]
branchstring
buildIdstring
commitMessagestring
commitRefstring
commitUrlstring
committerstring
context"production" | "branch-deploy" | "deploy-preview"
createdAtstring
deploySslUrlstring
deployTimenumber
deployUrlstring
edgeFunctionsPresentundefined | boolean
entryPathstring
errorMessagestring
expiresAtundefined | string
frameworkstring
functionSchedulesobject[]
idstring
lockedboolean
manualDeployboolean
namestring
pluginState"success" | "canceled_build" | "failed_plugin" | "failed_build" | "skipped" | "none"
publishedAtstring
requiredstring[]
requiredFunctionsstring[]
reviewIdnumber
reviewUrlstring
screenshotUrlstring
siteIdstring
skippedboolean
skippedLogboolean
sslUrlstring
state"new" | "pending_review" | "accepted" | "rejected" | "enqueued" | "building" | "uploading" | "uploaded" | "preparing" | "prepared" | "processing" | "ready" | "error" | "retrying"
summaryobject
summary.messagesundefined | object[]
summary.statusundefined | string
titlestring
updatedAtstring
urlstring
userIdstring
viewsCountnumber

NetlifyClient.cancelSiteDeploy


createBuildHook(siteId, buildHook): Promise<BuildHookResponse>

Creates a new build hook for a site.

ParameterType
siteIdstring
buildHookBuildHookInput

Promise<BuildHookResponse>

NetlifyClient.createBuildHook


createEnvironmentVariable(__namedParameters): Promise<EnvironmentVariable>

Creates a new environment variable for a site.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.isSecret?boolean
__namedParameters.keystring
__namedParameters.scopes?EnvironmentVariableScopeType[]
__namedParameters.siteIdstring
__namedParameters.valuesEnvironmentVariableValue[]

Promise<EnvironmentVariable>

NetlifyClient.createEnvironmentVariable


createHook(CreateHookRequest): Promise<CreateHookResponse>

ParameterType
CreateHookRequestCreateHookRequest

Promise<CreateHookResponse>

NetlifyClient.createHook


createHookBySiteId(siteId, input): Promise<object>

Creates a webhook for the given site.

ParameterType
siteIdstring
inputCreateHookBySiteIdInput

Promise<object>

NameType
actorstring
createdAtstring
dataobject
disabledboolean
eventstring
formIdstring
formNamestring
idstring
restrictedboolean
siteIdstring
successboolean
typestring
updatedAtstring
userIdstring

NetlifyClient.createHookBySiteId


createOrUpdateVariable(__namedParameters): Promise<void>

Creates or updates a single environment variable for a site when passed a siteId. When not passed a siteId, operates on the team level.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.isSecret?boolean
__namedParameters.keystring
__namedParameters.scopes?EnvironmentVariableScopeType[]
__namedParameters.siteId?string
__namedParameters.valueEnvVarRequest

Promise<void>

NetlifyClient.createOrUpdateVariable


createOrUpdateVariables(__namedParameters): Promise<void>

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.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.isSecret?boolean
__namedParameters.scopes?EnvironmentVariableScopeType[]
__namedParameters.siteId?string
__namedParameters.variablesRecord<string, EnvVarRequest>

Promise<void>

NetlifyClient.createOrUpdateVariables


createSiteBuildHook(siteId, input): Promise<object>

Creates a new build hook for a site.

ParameterType
siteIdstring
inputCreateSiteBuildHookInput

Promise<object>

NameType
branchstring
createdAtstring
draftboolean
idstring
msgstring
siteIdstring
titlestring
urlstring

NetlifyClient.createSiteBuildHook


createSiteConfiguration(teamId, siteId, config): Promise<WretchResponse>

Creates a site configuration for an extension installation.

ParameterType
teamIdstring
siteIdstring
configSiteConfiguration

Promise<WretchResponse>


createSiteDeploy(siteId, input): Promise<object>

Creates a new deployment for a site.

ParameterType
siteIdstring
inputCreateSiteDeployInput

Promise<object>

NameType
adminUrlstring
availableFunctionsstring[]
branchstring
buildIdstring
commitMessagestring
commitRefstring
commitUrlstring
committerstring
context"production" | "branch-deploy" | "deploy-preview"
createdAtstring
deploySslUrlstring
deployTimenumber
deployUrlstring
edgeFunctionsPresentundefined | boolean
entryPathstring
errorMessagestring
expiresAtundefined | string
frameworkstring
functionSchedulesobject[]
idstring
lockedboolean
manualDeployboolean
namestring
pluginState"success" | "canceled_build" | "failed_plugin" | "failed_build" | "skipped" | "none"
publishedAtstring
requiredstring[]
requiredFunctionsstring[]
reviewIdnumber
reviewUrlstring
screenshotUrlstring
siteIdstring
skippedboolean
skippedLogboolean
sslUrlstring
state"new" | "pending_review" | "accepted" | "rejected" | "enqueued" | "building" | "uploading" | "uploaded" | "preparing" | "prepared" | "processing" | "ready" | "error" | "retrying"
summaryobject
summary.messagesundefined | object[]
summary.statusundefined | string
titlestring
updatedAtstring
urlstring
userIdstring
viewsCountnumber

NetlifyClient.createSiteDeploy


createSiteLogDrain(siteId, input): Promise<object>

Creates a log drain for a site.

ParameterType
siteIdstring
inputCreateSiteLogDrainInput

Promise<object>

NameType
destinationstring
excludePiiundefined | boolean
format"json" | "ndjson"
idstring
logTypesstring
serviceConfigobject
serviceConfig.urlstring
siteIdstring

NetlifyClient.createSiteLogDrain


createTeamConfiguration(teamId, config): Promise<WretchResponse>

Creates a team configuration for an extension installation.

ParameterType
teamIdstring
configTeamConfiguration

Promise<WretchResponse>


deleteBuildHook(siteId, buildHookId): Promise<BuildHookResponse>

Deletes a build hook for a site.

ParameterType
siteIdstring
buildHookIdstring

Promise<BuildHookResponse>

NetlifyClient.deleteBuildHook


deleteDeploy(deployId): Promise<void>

Deletes a deployment.

ParameterType
deployIdstring

Promise<void>

NetlifyClient.deleteDeploy


deleteEnvironmentVariable(__namedParameters): Promise<WretchResponse>

Deletes an environment variable for a site when passed a siteId. When not passed a siteId, operates on the team level.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.keystring
__namedParameters.siteId?string

Promise<WretchResponse>

NetlifyClient.deleteEnvironmentVariable


deleteEnvironmentVariables(__namedParameters): Promise<void>

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.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.siteId?string
__namedParameters.variablesstring[]

Promise<void>

NetlifyClient.deleteEnvironmentVariables


deleteHook(hookId): Promise<void>

Deletes the given webhook.

ParameterType
hookIdstring

Promise<void>

NetlifyClient.deleteHook


deleteSiteBuildHook(siteId, buildHookId): Promise<void>

Deletes a build hook by site ID and build hook ID.

ParameterType
siteIdstring
buildHookIdstring

Promise<void>

NetlifyClient.deleteSiteBuildHook


deleteSiteConfiguration(teamId, siteId): Promise<WretchResponse>

Deletes a site configuration for uninstalling the extension.

ParameterType
teamIdstring
siteIdstring

Promise<WretchResponse>


deleteSiteForm(siteId, formId): Promise<void>

Deletes a form.

ParameterType
siteIdstring
formIdstring

Promise<void>

NetlifyClient.deleteSiteForm


deleteSiteLogDrain(siteId, logDrainId): Promise<void>

Deletes a log drain for a site.

ParameterType
siteIdstring
logDrainIdstring

Promise<void>

NetlifyClient.deleteSiteLogDrain


deleteTeamConfiguration(teamId): Promise<WretchResponse>

Deletes a team configuration for uninstalling the extension.

ParameterType
teamIdstring

Promise<WretchResponse>


getAccount(accountId): Promise<Account>

Gets an account by ID and returns account information.

ParameterType
accountIdstring

Promise<Account>

NetlifyClient.getAccount


getBlobStore(siteId, storeName): Store

Returns a configured @netlify/blobs#Blobs client for the given site and blob store name.

ParameterType
siteIdstring
storeNamestring

Store

The @netlify/blobs package

NetlifyClient.getBlobStore


getCurrentUser(): Promise<null | User>

getCurrentUser retrieves information about the current authenticated user. If the request is not authenticated, returns null.

Promise<null | User>

NetlifyClient.getCurrentUser


getDeploy(deployId): Promise<null | object>

Retrieves a deployment.

ParameterType
deployIdstring

Promise<null | object>

NetlifyClient.getDeploy


getDnsForSite(siteId): Promise<object[]>

Lists a site’s DNS records

ParameterType
siteIdstring

Promise<object[]>

NetlifyClient.getDnsForSite


getEnvironmentVariables(__namedParameters): Promise<EnvironmentVariable[]>

Gets all environment variables for a site when passed a siteId. When not passed a siteId, operates on the team level.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.siteId?string

Promise<EnvironmentVariable[]>

NetlifyClient.getEnvironmentVariables


getHook(hookId): Promise<null | object>

Retrieves a webhook by ID. Returns null if the webhook does not exist.

ParameterType
hookIdstring

Promise<null | object>

NetlifyClient.getHook


getSite(siteId): Promise<Site>

Gets a site by ID and returns site information.

ParameterType
siteIdstring

Promise<Site>

NetlifyClient.getSite


getSiteBuild(buildId): Promise<null | object>

getSiteBuild retrieves a site build by ID.

Returns null when no build is found for the given ID.

ParameterType
buildIdstring

Promise<null | object>

NetlifyClient.getSiteBuild


getSiteBuildHook(siteId, buildHookId): Promise<null | object>

Retrieves a build hook by site ID and build hook ID.

ParameterType
siteIdstring
buildHookIdstring

Promise<null | object>

NetlifyClient.getSiteBuildHook


getSiteConfiguration(teamId, siteId): Promise<null | ConfigurationResponse<SiteConfiguration>>

Returns the extension configuration for a site for the current extension.

ParameterType
teamIdstring
siteIdstring

Promise<null | ConfigurationResponse<SiteConfiguration>>


getSiteForm(siteId, formId): Promise<null | object>

Gets a form.

ParameterType
siteIdstring
formIdstring

Promise<null | object>

NetlifyClient.getSiteForm


getSiteLogDrain(siteId, logDrainId): Promise<null | object>

Gets a log drain for a site.

ParameterType
siteIdstring
logDrainIdstring

Promise<null | object>

NetlifyClient.getSiteLogDrain


getSites(): Promise<Site[]>

Gets all sites for an account.

Promise<Site[]>

NetlifyClient.getSites


getTeamConfiguration(teamId): Promise<null | ConfigurationResponse<TeamConfiguration>>

Returns the extension configuration for a team for the current extension.

ParameterType
teamIdstring

Promise<null | ConfigurationResponse<TeamConfiguration>>


installExtensionOnTeam(teamId): Promise<object>

Installs this extension for a team.

ParameterType
teamIdstring

Promise<object>

NameType
tokenstring

listHooksBySiteId(siteId): Promise<object[]>

Retrieves a list of webhooks for the given site.

ParameterType
siteIdstring

Promise<object[]>

NetlifyClient.listHooksBySiteId


listSiteBuildHooks(siteId): Promise<object[]>

Lists all build hooks for a site.

ParameterType
siteIdstring

Promise<object[]>

NetlifyClient.listSiteBuildHooks


listSiteConfigurations(teamId): Promise<ConfigurationResponse<SiteConfiguration>[]>

List all site configurations for the specified team.

ParameterType
teamIdstring

Promise<ConfigurationResponse<SiteConfiguration>[]>


listSiteDeploys(siteId): Promise<object[]>

Lists deployments for a site.

ParameterType
siteIdstring

Promise<object[]>

NetlifyClient.listSiteDeploys


listSiteForms(siteId): Promise<object[]>

Lists forms for a site.

ParameterType
siteIdstring

Promise<object[]>

NetlifyClient.listSiteForms


listSiteLogDrains(siteId): Promise<object[]>

Lists a site’s log drains.

ParameterType
siteIdstring

Promise<object[]>

NetlifyClient.listSiteLogDrains


lockDeploy(deployId): Promise<void>

Locks an existing deployment.

ParameterType
deployIdstring

Promise<void>

NetlifyClient.lockDeploy


patchEnvironmentVariable(__namedParameters): Promise<EnvironmentVariable>

Creates or updates an environment variable for a site when passed a siteId. When not passed a siteId, operates on the team level.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.contextstring
__namedParameters.contextParameter?string
__namedParameters.keystring
__namedParameters.siteId?string
__namedParameters.valuestring

Promise<EnvironmentVariable>

NetlifyClient.patchEnvironmentVariable


purgeCache(siteId, cacheTags): Promise<void>

purgeCache purges cached content from Netlify’s CDN. Supports purging by Cache-Tag.

ParameterType
siteIdstring
cacheTagsstring[]

Promise<void>

NetlifyClient.purgeCache


redeploySite(__namedParameters): Promise<RedeploySiteResponse>

Redeploys a site by triggering a new build. A ‘branch’ can be specified to build a specific branch. If none are specified, the default branch will be built.

ParameterType
__namedParametersobject
__namedParameters.branch?string
__namedParameters.siteIdstring

Promise<RedeploySiteResponse>

NetlifyClient.redeploySite


restoreSiteDeploy(siteId, deployId): Promise<object>

Restores a site to the specified deployment.

ParameterType
siteIdstring
deployIdstring

Promise<object>

NameType
adminUrlstring
availableFunctionsstring[]
branchstring
buildIdstring
commitMessagestring
commitRefstring
commitUrlstring
committerstring
context"production" | "branch-deploy" | "deploy-preview"
createdAtstring
deploySslUrlstring
deployTimenumber
deployUrlstring
edgeFunctionsPresentundefined | boolean
entryPathstring
errorMessagestring
expiresAtundefined | string
frameworkstring
functionSchedulesobject[]
idstring
lockedboolean
manualDeployboolean
namestring
pluginState"success" | "canceled_build" | "failed_plugin" | "failed_build" | "skipped" | "none"
publishedAtstring
requiredstring[]
requiredFunctionsstring[]
reviewIdnumber
reviewUrlstring
screenshotUrlstring
siteIdstring
skippedboolean
skippedLogboolean
sslUrlstring
state"new" | "pending_review" | "accepted" | "rejected" | "enqueued" | "building" | "uploading" | "uploaded" | "preparing" | "prepared" | "processing" | "ready" | "error" | "retrying"
summaryobject
summary.messagesundefined | object[]
summary.statusundefined | string
titlestring
updatedAtstring
urlstring
userIdstring
viewsCountnumber

NetlifyClient.restoreSiteDeploy


rollbackSiteDeploy(siteId): Promise<void>

Initiates a deployment rollback for the site, restoring the site to its previous deployment.

ParameterType
siteIdstring

Promise<void>

NetlifyClient.rollbackSiteDeploy


uninstallExtensionOnTeam(teamId): Promise<WretchResponse>

Uninstalls this extension for a team, which also deletes the configuration.

ParameterType
teamIdstring

Promise<WretchResponse>


unlockDeploy(deployId): Promise<void>

Unlocks a locked deployment.

ParameterType
deployIdstring

Promise<void>

NetlifyClient.unlockDeploy


updateEnvironmentVariable(__namedParameters): Promise<EnvironmentVariable>

Updates an existing environment variable for a site when passed a siteId. When not passed a siteId, operates on the team level.

ParameterType
__namedParametersobject
__namedParameters.accountIdstring
__namedParameters.isSecret?boolean
__namedParameters.keystring
__namedParameters.scopes?EnvironmentVariableScopeType[]
__namedParameters.siteId?string
__namedParameters.valuesEnvironmentVariableValue[]

Promise<EnvironmentVariable>

NetlifyClient.updateEnvironmentVariable


updateHook(hookId, input): Promise<object>

Updates a webhook by ID. Returns the updated webhook.

ParameterType
hookIdstring
inputUpdateHookInput

Promise<object>

NameType
actorstring
createdAtstring
dataobject
disabledboolean
eventstring
formIdstring
formNamestring
idstring
restrictedboolean
siteIdstring
successboolean
typestring
updatedAtstring
userIdstring

NetlifyClient.updateHook


updateSite(siteId, changes): Promise<Site>

Updates a site with the given changes.

ParameterType
siteIdstring
changesPartial<Site>

Promise<Site>

NetlifyClient.updateSite


updateSiteBuildHook(siteId, buildHookId, input): Promise<object>

Updates a build hook by site ID and build hook ID.

ParameterType
siteIdstring
buildHookIdstring
inputUpdateSiteBuildHookInput

Promise<object>

NameType
branchstring
createdAtstring
draftboolean
idstring
msgstring
siteIdstring
titlestring
urlstring

NetlifyClient.updateSiteBuildHook


updateSiteConfiguration(teamId, siteId, config): Promise<WretchResponse>

Updates the extension configuration for a site.

ParameterType
teamIdstring
siteIdstring
configSiteConfiguration

Promise<WretchResponse>


updateSiteLogDrain(siteId, logDrainId, input): Promise<object>

Updates a log drain for a site.

ParameterType
siteIdstring
logDrainIdstring
inputCreateSiteLogDrainInput

Promise<object>

NameType
destinationstring
excludePiiundefined | boolean
format"json" | "ndjson"
idstring
logTypesstring
serviceConfigobject
serviceConfig.urlstring
siteIdstring

NetlifyClient.updateSiteLogDrain


updateTeamConfiguration(teamId, config): Promise<WretchResponse>

Updates the extension configuration for a team.

ParameterType
teamIdstring
configTeamConfiguration

Promise<WretchResponse>


upsertSiteConfiguration(teamId, siteId, config): Promise<WretchResponse>

Upserts a configuration object of type ‘site’ for the extension installation

ParameterType
teamIdstring
siteIdstring
configSiteConfiguration

Promise<WretchResponse>


upsertTeamConfiguration(teamId, config): Promise<WretchResponse>

Upserts a configuration object of type ‘team’ for the extension installation

ParameterType
teamIdstring
configTeamConfiguration

Promise<WretchResponse>