Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/netlify

src/create-env-var.js

22 lines · 1.0 KB · JavaScript
import { createEnvVar } from './netlify.js'

/**
 * Create a site environment variable.
 * Requires `dryRun: true` to preview or `confirm: true` to write.
 * Dry-run previews redact `value`.
 * @param {Object} input
 * @param {string} input.accountId Team id or slug.
 * @param {string} input.site Site id, name, or domain.
 * @param {string} input.key Variable name.
 * @param {string} input.value Variable value.
 * @param {string} [input.context] Deploy context (`all`, `production`, `deploy-preview`, …).
 * @param {boolean} [input.dryRun] Return the request preview without creating the variable.
 * @param {boolean} [input.confirm] Required for the live write.
 * @returns {Promise<Record<string, unknown>>} Created env metadata or dry-run preview.
 * @example
 * import createEnvVar from 'kody:@kody/netlify/create-env-var'
 * const preview = await createEnvVar({ accountId: 'acme', site: 'example-site', key: 'EXAMPLE_FLAG', value: '1', dryRun: true })
 */
export default async function createEnvVarEntrypoint(input = {}) {
	return await createEnvVar(input)
}