ReferenceFlightcontrol APIServicesUpdate Scaling

Update Service Scaling

API Description

  • Method: POST
  • Path: /v1/services/:serviceId/scaling
  • Full Endpoint: https://api.flightcontrol.com/v1/services/:serviceId/scaling

Headers

  • Authorization: Bearer token (required)
  • Content-Type: application/json

Parameters

Path Parameters

  • serviceId (string, required) - The unique identifier of the service

Body Parameters

  • operation (string, required) - The scaling operation to perform. One of: "set", "add", "remove"
  • count (number, required) - The number of instances to set/add/remove

Request Examples

Set Exact Instance Count

curl -X POST https://api.flightcontrol.com/v1/services/cmds18v130000485zbcat00xy/scaling \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "set",
    "count": 5
  }'

Add Instances

curl -X POST https://api.flightcontrol.com/v1/services/cmds18v130000485zbcat00xy/scaling \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "add",
    "count": 2
  }'

Remove Instances

curl -X POST https://api.flightcontrol.com/v1/services/cmds18v130000485zbcat00xy/scaling \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "remove",
    "count": 1
  }'

Response Example

Success Response (200 OK)

{
  "serviceId": "srv_1234567890",
  "previousDesiredCount": 3,
  "newDesiredCount": 5,
  "autoscalingEnabled": true
}

Error Response (400 Bad Request)

{
  "message": "Invalid count: must be between 0 and 100",
  "errorCode": "FC:Request:Error:VALIDATION_ERROR"
}

Error Response (404 Not Found)

{
  "message": "Service not found",
  "errorCode": "FC:Request:Error:NOT_FOUND"
}

Error Response (401 Unauthorized)

{
  "error": "Please use an API key for this request"
}

Response Fields

  • serviceId - The unique identifier of the service
  • previousDesiredCount - The desired instance count before the update
  • newDesiredCount - The new desired instance count after the update
  • autoscalingEnabled - Whether autoscaling is enabled for this service

Response Conditions

  • 200 OK - Service scaling updated successfully
  • 400 Bad Request - Invalid operation or count parameter
  • 401 Unauthorized - Invalid or missing API key
  • 403 Forbidden - User doesn’t have permission to scale this service
  • 404 Not Found - Service not found or not a scalable service type

Important Notes

  • Manual scaling works regardless of whether autoscaling is enabled
  • When autoscaling is enabled, manual scaling provides temporary capacity adjustments
  • The service must be in a scalable state (not scheduler services)
  • Instance count must be within valid bounds (0-100)
  • Scaling operations may take time to complete as ECS provisions/terminates instances

Supported Service Types

This endpoint is available for the following service types:

  • Web services (web)
  • Private web services (web-private)
  • Worker services (worker)
  • Network servers (network-server)
  • Private network servers (private-network-server)

Note: Scheduler services do not support this endpoint as they have different scaling characteristics.

Operation Details

Set Operation

  • Sets the exact number of instances
  • The count must be between 0 and 100
  • Will scale up or down to reach the target count

Add Operation

  • Increases the current instance count by the specified amount
  • The resulting count must not exceed 100
  • Useful for gradual scale-up scenarios

Remove Operation

  • Decreases the current instance count by the specified amount
  • The resulting count cannot go below 0
  • Useful for gradual scale-down scenarios