ReferenceFlightcontrol APIEnvironment VariablesCreate Service Variables

Create Service Environment Variables API

Use this API to add environment variables to a specific service. This endpoint supports multiple variable types including plain text, AWS Parameter Store, AWS Secrets Manager, and values linked from other services.

API Description

MethodPath
POST/v1/services/{serviceId}/env-variables
Headers
AuthorizationBearer: [API key]
Content-Typeapplication/json

Full Endpoint URL https://api.flightcontrol.dev/v1/services/{serviceId}/env-variables

Path Parameters

ParameterTypeDescription
serviceIdstringThe unique ID of the service

Request Body

All fields are optional. You can send any combination of these groups:

ParameterTypeDescription
plainTextobjectPlain text environment variables stored in the database. Key-value pairs where both are strings.
parameterStoreobjectFC-managed secrets stored in AWS Parameter Store. Flightcontrol creates and manages the parameter. Key is the variable name, value is the secret value.
secretsManagerobjectFC-managed secrets stored in AWS Secrets Manager. Flightcontrol creates and manages the secret. Key is the variable name, value is the secret value.
fromParameterStoreobjectReference existing AWS Parameter Store parameters you manage. Key is the variable name, value is the parameter path. Saved immediately.
fromSecretsManagerobjectReference existing AWS Secrets Manager secrets you manage. Key is the variable name, value is the secret ARN. Saved immediately.
fromServiceobjectReference values from other services in your environment. Key is the variable name, value is an object with id (service ID) and value (property to reference).

Environment Variable Types

Plain Text

Simple string values stored in the database.

{
  "plainText": {
    "PORT": "3000",
    "LOG_LEVEL": "info"
  }
}

AWS Parameter Store (FC-Managed)

Store a secret value in AWS Systems Manager Parameter Store. Flightcontrol creates and manages the parameter.

{
  "parameterStore": {
    "DATABASE_PASSWORD": "my-secret-password"
  }
}

AWS Secrets Manager (FC-Managed)

Store a secret value in AWS Secrets Manager. Flightcontrol creates and manages the secret.

{
  "secretsManager": {
    "API_SECRET": "super-secret-api-key"
  }
}

Linked Service Value

Reference a value from another service in your environment (e.g., database connection string).

{
  "fromService": {
    "REDIS_URL": {
      "id": "redis-service-id",
      "value": "connectionString"
    }
  }
}

User-Managed AWS Parameter Store

Reference existing AWS Parameter Store parameters that you manage directly. These are saved immediately.

{
  "fromParameterStore": {
    "EXISTING_PARAM": "/my-org/existing-parameter"
  }
}

User-Managed AWS Secrets Manager

Reference existing AWS Secrets Manager secrets that you manage directly. These are saved immediately.

{
  "fromSecretsManager": {
    "EXISTING_SECRET": "arn:aws:secretsmanager:us-east-1:123456789:secret:my-secret"
  }
}

Request Example

curl -X POST "https://api.flightcontrol.dev/v1/services/svc-123/env-variables" \
  -H "Authorization: Bearer: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "plainText": {
      "PORT": "3000"
    },
    "parameterStore": {
      "DATABASE_PASSWORD": "db-password-123"
    },
    "fromService": {
      "REDIS_URL": {
        "id": "redis-service-id",
        "value": "connectionString"
      }
    }
  }'

Response

The response depends on the types of environment variables being saved.

Variables using plainText, fromService, fromParameterStore, and fromSecretsManager are saved immediately. Only FC-managed secrets (parameterStore and secretsManager) require async processing.

Synchronous Response (No FC-Managed Secrets)

When no parameterStore or secretsManager values are included:

HTTP/1.1 200 OK
{
  "status": "completed",
  "savedCount": 3
}
FieldTypeDescription
statusstring"completed" when all variables are saved
savedCountnumberCount of environment variables saved synchronously

Asynchronous Response (With FC-Managed Secrets)

When parameterStore or secretsManager values are included, a runId is returned to track the workflow:

HTTP/1.1 202 Accepted
{
  "status": "processing",
  "runId": "abc123-workflow-run-id",
  "savedCount": 2,
  "processingCount": 1
}
FieldTypeDescription
statusstring"processing" when FC-managed secrets are being stored
runIdstringWorkflow ID to check status
savedCountnumberCount of environment variables saved synchronously
processingCountnumberCount of FC-managed secrets being processed asynchronously

Checking Workflow Status

When you receive a runId, use the status endpoint to check progress:

MethodPath
GET/v1/services/{serviceId}/env-variables/status?runId={runId}

Status Request Example

curl "https://api.flightcontrol.dev/v1/services/svc-123/env-variables/status?runId=abc123" \
  -H "Authorization: Bearer: YOUR_API_KEY"

Status Response

{
  "isFinished": true,
  "processedEnvVariables": 1,
  "totalExpectedEnvVars": 1,
  "storedEnvVariables": {
    "DATABASE_PASSWORD": {"fromParameterStore": "/fc/..."}
  },
  "failedEnvVariables": {}
}
FieldTypeDescription
isFinishedbooleanWhether processing is complete
processedEnvVariablesnumberVariables processed so far
totalExpectedEnvVarsnumberTotal variables to process
storedEnvVariablesobjectSuccessfully stored variables with their AWS references
failedEnvVariablesobjectVariables that failed to store

Response Conditions

Errors

Service-level environment variables override environment-level variables with the same name during runtime.