Skip to main content
Get, set, update, and delete environment variables in a running sandbox.

Endpoints

Get All Environment Variables

GET {sandbox_public_host}/env
Response:
{
  "env_vars": {
    "PATH": "/usr/local/bin:/usr/bin:/bin",
    "HOME": "/root",
    "API_KEY": "sk-test-123"
  }
}

Set All Environment Variables

PUT {sandbox_public_host}/env
Request Body:
{
  "env_vars": {
    "API_KEY": "sk-prod-xyz",
    "NODE_ENV": "production"
  }
}

Update Environment Variables

PATCH {sandbox_public_host}/env
Request Body:
{
  "env_vars": {
    "DEBUG": "true"
  }
}

Delete Environment Variable

DELETE {sandbox_public_host}/env/{key}

Examples

cURL

# Get all
curl -H "Authorization: Bearer {auth_token}" \
     https://1761048129dsaqav4n.hopx.dev/env

# Set all
curl -X PUT https://1761048129dsaqav4n.hopx.dev/env \
  -H "Authorization: Bearer {auth_token}" \
  -H "Content-Type: application/json" \
  -d '{"env_vars": {"API_KEY": "sk-prod-xyz"}}'

# Update
curl -X PATCH https://1761048129dsaqav4n.hopx.dev/env \
  -H "Authorization: Bearer {auth_token}" \
  -H "Content-Type: application/json" \
  -d '{"env_vars": {"DEBUG": "true"}}'

# Delete
curl -X DELETE \
     -H "Authorization: Bearer {auth_token}" \
     https://1761048129dsaqav4n.hopx.dev/env/DEBUG

Python

# Get all
response = requests.get(
    f"{sandbox_public_host}/env",
    headers={"Authorization": f"Bearer {auth_token}"}
)
env_vars = response.json()["env_vars"]

# Set all
requests.put(
    f"{sandbox_public_host}/env",
    headers={"Authorization": f"Bearer {auth_token}"},
    json={"env_vars": {"API_KEY": "sk-prod-xyz"}}
)

# Update
requests.patch(
    f"{sandbox_public_host}/env",
    headers={"Authorization": f"Bearer {auth_token}"},
    json={"env_vars": {"DEBUG": "true"}}
)

# Delete
requests.delete(
    f"{sandbox_public_host}/env/DEBUG",
    headers={"Authorization": f"Bearer {auth_token}"}
)

JavaScript

// Get all
const response = await fetch(`${sandboxPublicHost}/env`, {
  headers: {
    'Authorization': `Bearer ${authToken}`
  }
});
const data = await response.json();
const envVars = data.env_vars;

// Set all
await fetch(`${sandboxPublicHost}/env`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${authToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    env_vars: { API_KEY: 'sk-prod-xyz' }
  })
});

// Update
await fetch(`${sandboxPublicHost}/env`, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${authToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    env_vars: { DEBUG: 'true' }
  })
});

// Delete
await fetch(`${sandboxPublicHost}/env/DEBUG`, {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${authToken}`
  }
});