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
- TypeScript
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
| Field | Type | Description |
|---|---|---|
env_name | string | Full environment name |
slug | string | Short identifier (3 chars recommended) |
description | string | Environment description |
active | boolean | Whether environment is active |
Common Environments
Development
- TypeScript
await ductape.product.environment.create({
env_name: 'development',
slug: 'dev',
description: 'Development environment for testing',
active: true,
});
Staging
- TypeScript
await ductape.product.environment.create({
env_name: 'staging',
slug: 'stg',
description: 'Staging environment for pre-production testing',
active: true,
});
Production
- TypeScript
await ductape.product.environment.create({
env_name: 'production',
slug: 'prd',
description: 'Production environment',
active: true,
});
Fetching Environments
Get All Environments
- TypeScript
const environments = await ductape.product.environment.fetchAll();
environments.forEach(env => {
console.log(`${env.env_name} (${env.slug}): ${env.active ? 'active' : 'inactive'}`);
});
Get Specific Environment
- TypeScript
const production = await ductape.product.environment.fetch('prd');
console.log('Production environment:', production);
Updating Environments
- TypeScript
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:
- TypeScript
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,prdare 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
- Products Overview - Product architecture
- Creating Products - Create new products
- Connecting Apps - Link apps to products