Create Environment Variables

Creates new environment variables for a given project. This endpoint will fail if any of the specified environment variable keys already exist, unless upsert is set to true.

POST /projects/{projectId}/env-vars
import { v0 } from 'v0-sdk'

// Create new environment variables (will fail if keys already exist)
const result = await v0.projects.createEnvVars({
  projectId: 'project_abc123',
  environmentVariables: [
    {
      key: 'DATABASE_URL',
      value: 'postgresql://user:pass@host:5432/db'
    },
    {
      key: 'API_SECRET_KEY',
      value: 'sk_1234567890abcdef'
    }
  ]
})

console.log(result)

// Upsert environment variables (will overwrite existing values)
const upsertResult = await v0.projects.createEnvVars({
  projectId: 'project_abc123',
  upsert: true,
  environmentVariables: [
    {
      key: 'DATABASE_URL',
      value: 'postgresql://newuser:newpass@newhost:5432/newdb'
    }
  ]
})

console.log(upsertResult)

Parameters

Path Parameters

projectId string Required

The unique identifier of the project where environment variables should be created.


Query Parameters

decrypted enum

Whether to return decrypted values. Defaults to false (encrypted).

Possible values:

  • true
  • false

Request Body

environmentVariables object[] Required

An array of environment variables to create with key and value fields.

Array items:

key string Required

The name of the environment variable.


value string Required

The value of the environment variable.


upsert boolean

Whether to overwrite existing environment variables with the same keys. Defaults to false.


Response

Response Body

object string Required


data any[] Required

Array items: string