Skip to main content

Product Environments

Manage deployment environments for your products.

Overview​

Product environments allow you to maintain separate configurations for development, staging, and production. Each environment can have its own settings, credentials, and endpoints while sharing the same product structure.

Creating an Environment​

import Ductape from '@ductape/sdk';

const ductape = new Ductape({
accessKey: 'your-access-key',
});

await ductape.product.init('my-product');

await ductape.product.environment.create({
env_name: 'production',
slug: 'prd',
description: 'Production environment',
active: true,
});

Environment Fields​

FieldTypeDescription
env_namestringFull environment name
slugstringShort identifier (3 chars recommended)
descriptionstringEnvironment description
activebooleanWhether environment is active

Common Environments​

Development​

await ductape.product.environment.create({
env_name: 'development',
slug: 'dev',
description: 'Development environment for testing',
active: true,
});

Staging​

await ductape.product.environment.create({
env_name: 'staging',
slug: 'stg',
description: 'Staging environment for pre-production testing',
active: true,
});

Production​

await ductape.product.environment.create({
env_name: 'production',
slug: 'prd',
description: 'Production environment',
active: true,
});

Fetching Environments​

Get All Environments​

const environments = await ductape.product.environment.fetchAll();

environments.forEach(env => {
console.log(`${env.env_name} (${env.slug}): ${env.active ? 'active' : 'inactive'}`);
});

Get Specific Environment​

const production = await ductape.product.environment.fetch('prd');
console.log('Production environment:', production);

Updating Environments​

await ductape.product.environment.update('dev', {
description: 'Updated development environment',
active: false,
});

Using Environments​

Set product and env on the Ductape constructor. Runtime calls inherit them automatically:

const ductape = new Ductape({
accessKey: 'your-access-key',
product: 'my-product',
env: 'prd', // or 'dev', 'stg'
});

await ductape.api.run({
app: 'stripe',
action: 'create-charge',
input: { amount: 1000 },
});

await ductape.features.run({
feature_tag: 'process-payment',
input: { userId: '123' },
});

Best Practices​

  • Use standard slugs - dev, stg, prd are conventional
  • Keep active - Only deactivate environments temporarily
  • Document differences - Note what's different between environments
  • Test progression - Test in dev → staging → production
  • Separate credentials - Use different API keys per environment

See Also​