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
| Method | Path |
|---|---|
| POST | /v1/services/{serviceId}/env-variables |
| Headers | |
|---|---|
| Authorization | Bearer: [API key] |
| Content-Type | application/json |
Full Endpoint URL https://api.flightcontrol.dev/v1/services/{serviceId}/env-variables
Path Parameters
| Parameter | Type | Description |
|---|---|---|
serviceId | string | The unique ID of the service |
Request Body
All fields are optional. You can send any combination of these groups:
| Parameter | Type | Description |
|---|---|---|
plainText | object | Plain text environment variables stored in the database. Key-value pairs where both are strings. |
parameterStore | object | FC-managed secrets stored in AWS Parameter Store. Flightcontrol creates and manages the parameter. Key is the variable name, value is the secret value. |
secretsManager | object | FC-managed secrets stored in AWS Secrets Manager. Flightcontrol creates and manages the secret. Key is the variable name, value is the secret value. |
fromParameterStore | object | Reference existing AWS Parameter Store parameters you manage. Key is the variable name, value is the parameter path. Saved immediately. |
fromSecretsManager | object | Reference existing AWS Secrets Manager secrets you manage. Key is the variable name, value is the secret ARN. Saved immediately. |
fromService | object | Reference 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
}| Field | Type | Description |
|---|---|---|
status | string | "completed" when all variables are saved |
savedCount | number | Count 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
}| Field | Type | Description |
|---|---|---|
status | string | "processing" when FC-managed secrets are being stored |
runId | string | Workflow ID to check status |
savedCount | number | Count of environment variables saved synchronously |
processingCount | number | Count of FC-managed secrets being processed asynchronously |
Checking Workflow Status
When you receive a runId, use the status endpoint to check progress:
| Method | Path |
|---|---|
| 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": {}
}| Field | Type | Description |
|---|---|---|
isFinished | boolean | Whether processing is complete |
processedEnvVariables | number | Variables processed so far |
totalExpectedEnvVars | number | Total variables to process |
storedEnvVariables | object | Successfully stored variables with their AWS references |
failedEnvVariables | object | Variables that failed to store |
Response Conditions
Errors
Service-level environment variables override environment-level variables with the same name during runtime.