Skip to content
← Public packages

@cameronpak/box

Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.

src/create-environment.ts

23 lines · 696 B · TypeScript
import { boxRequest, type Result } from './client.ts'
import type { BoxEnvironment } from './types.ts'

export type CreateEnvironmentInput = {
	/** Unique name. Letters, numbers, dot, dash, underscore; max 64 chars. */
	name: string
}

export type CreateEnvironmentOutput = { environments: Array<BoxEnvironment> }

/**
 * Create a new named environment. It starts on version 1 with all fine-grained
 * flags on and safeForThirdParties off.
 */
export default async function createEnvironment(
	input: CreateEnvironmentInput,
): Promise<Result<CreateEnvironmentOutput>> {
	return boxRequest<CreateEnvironmentOutput>({
		path: '/environments',
		method: 'POST',
		body: { name: input.name },
	})
}