Skip to main content
POST
/
api
/
platform
/
initEnv
Initialize Environment
curl --request POST \
  --url https://api.example.com/api/platform/initEnv \
  --header 'Content-Type: application/json' \
  --data '
{
  "templateService": "<string>",
  "templateName": "<string>",
  "testId": "<string>",
  "impersonateUserId": "<string>",
  "impersonateEmail": "<string>",
  "ttlSeconds": 123
}
'
{
  "environmentId": "<string>",
  "environmentUrl": "<string>",
  "schemaName": "<string>",
  "expiresAt": "<string>",
  "templateSchema": "<string>",
  "service": "<string>"
}

Request

POST /api/platform/initEnv

Body Parameters

templateService
string
required
Service type: "slack" or "linear"
templateName
string
Template to clone from (e.g., "slack_default", "linear_expanded"). Required if testId is not provided.
testId
string
Test ID to get template configuration from. If provided, templateService and templateName are inferred.
impersonateUserId
string
User ID the agent will act as. Required if testId is not provided.
impersonateEmail
string
Email of the user to impersonate. Alternative to impersonateUserId.
ttlSeconds
number
default:"1800"
Time-to-live in seconds. Environment auto-deletes after this time.

Example Request

curl -X POST https://api.agentdiff.dev/api/platform/initEnv \
  -H "X-API-Key: ad_live_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "templateService": "slack",
    "templateName": "slack_default",
    "impersonateUserId": "U01AGENBOT9",
    "ttlSeconds": 3600
  }'

Response

environmentId
string
Unique environment identifier
environmentUrl
string
Base URL for service API calls
schemaName
string
PostgreSQL schema name for this environment
expiresAt
string
ISO 8601 timestamp when environment will auto-delete
templateSchema
string
Template that was cloned
service
string
Service type (slack or linear)

Example Response

{
  "environmentId": "abc123def456",
  "environmentUrl": "/api/env/abc123def456/services/slack",
  "schemaName": "state_pool_abc123",
  "expiresAt": "2025-11-26T16:00:00Z",
  "templateSchema": "slack_default",
  "service": "slack"
}

Errors

ErrorStatusDescription
template_not_found404Template doesn’t exist
missing_impersonate400impersonateUserId or impersonateEmail required
invalid_service400Unknown service type

SDK Usage

env = client.init_env(
    templateService="slack",
    templateName="slack_default",
    impersonateUserId="U01AGENBOT9",
    ttlSeconds=3600
)