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
- Java
- Go
- .NET
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,
});
import app.ductape.sdk.Ductape;
import app.ductape.sdk.core.EnvType;
import app.ductape.sdk.core.RequestContext;
RequestContext auth = new RequestContext(null, null, null, null, 'your-access-key');
Ductape ductape = new Ductape(EnvType.PRODUCTION, auth);
ductape.product.init('my-product');
ductape.product.environment.create(Map.of(
"env_name", "production",
"slug", "prd",
"description", "Production environment",
"active", true
));
import (
"context"
"github.com/ductape/ductape/sdk/go/core"
ductapesdk "github.com/ductape/ductape/sdk/go/ductape"
)
auth := core.NewRequestContext("", "", "", "", 'your-access-key')
client, err := ductapesdk.New(core.EnvProduction, auth)
if err != nil {
return err
}
client.product.init('my-product');
client.product.environment.create({
"env_name": "production",
"slug": "prd",
"description": "Production environment",
"active": true,
});
using Ductape.Sdk;
using Ductape.Sdk.Core;
var auth = new RequestContext(null, null, null, null, 'your-access-key', null);
var ductape = new Ductape(EnvType.Production, auth);
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
- Java
- Go
- .NET
await ductape.product.environment.create({
env_name: 'development',
slug: 'dev',
description: 'Development environment for testing',
active: true,
});
ductape.product.environment.create(Map.of(
"env_name", "development",
"slug", "dev",
"description", "Development environment for testing",
"active", true
));
client.product.environment.create({
"env_name": "development",
"slug": "dev",
"description": "Development environment for testing",
"active": true,
});
await ductape.product.environment.create({
["env_name"] = "development",
["slug"] = "dev",
["description"] = "Development environment for testing",
["active"] = true,
});
Staging
- TypeScript
- Java
- Go
- .NET
await ductape.product.environment.create({
env_name: 'staging',
slug: 'stg',
description: 'Staging environment for pre-production testing',
active: true,
});
ductape.product.environment.create(Map.of(
"env_name", "staging",
"slug", "stg",
"description", "Staging environment for pre-production testing",
"active", true
));
client.product.environment.create({
"env_name": "staging",
"slug": "stg",
"description": "Staging environment for pre-production testing",
"active": true,
});
await ductape.product.environment.create({
["env_name"] = "staging",
["slug"] = "stg",
["description"] = "Staging environment for pre-production testing",
["active"] = true,
});
Production
- TypeScript
- Java
- Go
- .NET
await ductape.product.environment.create({
env_name: 'production',
slug: 'prd',
description: 'Production environment',
active: true,
});
ductape.product.environment.create(Map.of(
"env_name", "production",
"slug", "prd",
"description", "Production environment",
"active", true
));
client.product.environment.create({
"env_name": "production",
"slug": "prd",
"description": "Production environment",
"active": true,
});
await ductape.product.environment.create({
["env_name"] = "production",
["slug"] = "prd",
["description"] = "Production environment",
["active"] = true,
});
Fetching Environments
Get All Environments
- TypeScript
- Java
- Go
- .NET
const environments = await ductape.product.environment.fetchAll();
environments.forEach(env => {
console.log(`${env.env_name} (${env.slug}): ${env.active ? 'active' : 'inactive'}`);
});
Map<String, Object> environments = ductape.product.environment.fetchAll();
environments.forEach(env => Map.of(
System.out.println(`$Map.of(env.env_name) ($Map.of(env.slug)): $Map.of(env.active ? 'active' : 'inactive')`);
));
environments := client.product.environment.fetchAll();
environments.forEach(env => {
fmt.Println(`${env.env_name} (${env.slug}): ${env.active ? 'active' : 'inactive'}`);
});
var environments = await ductape.product.environment.fetchAll();
environments.forEach(env => {
Console.WriteLine(`${env.env_name} (${env.slug}): ${env.active ? 'active' : 'inactive'}`);
});
Get Specific Environment
- TypeScript
- Java
- Go
- .NET
const production = await ductape.product.environment.fetch('prd');
console.log('Production environment:', production);
Map<String, Object> production = ductape.product.environment.fetch('prd');
System.out.println('Production environment:', production);
production := client.product.environment.fetch('prd');
fmt.Println('Production environment:', production);
var production = await ductape.product.environment.fetch('prd');
Console.WriteLine('Production environment:', production);
Updating Environments
- TypeScript
- Java
- Go
- .NET
await ductape.product.environment.update('dev', {
description: 'Updated development environment',
active: false,
});
ductape.product.environment.update('dev', Map.of(
"description", "Updated development environment",
"active", false
));
client.product.environment.update('dev', {
"description": "Updated development environment",
"active": false,
});
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
- Java
- Go
- .NET
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' },
});
Map<String, Object> ductape = new Ductape(Map.of(
"accessKey", "your-access-key",
"product", "my-product",
"env", "prd", // or 'dev', 'stg'
));
ductape.api().run(Map<String, Object>.of(
"app", "stripe",
"action", "create-charge",
input: Map.of( "amount", 1000 )
));
ductape.features.run(Map.of(
"feature_tag", "process-payment",
input: Map.of( "userId", "123" )
));
import "context"
auth := core.NewRequestContext("", "", "", "", 'your-access-key')
client, err := ductapesdk.New(core.EnvProduction, auth)
if err != nil {
return err
}
client.Api.Run(ctx, map[string]any{
"app": "stripe",
"action": "create-charge",
input: { "amount": 1000 },
});
client.features.run({
"feature_tag": "process-payment",
input: { "userId": "123" },
});
var ductape = new Ductape({
["accessKey"] = "your-access-key",
["product"] = "my-product",
["env"] = "prd", // or 'dev', 'stg'
});
await await ductape.Api.RunAsync(new Dictionary<string, object?>
{
["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