Cloud › Services
Update service settings
PATCH https://devapi.dispralabs.com/v1/cloud/services/:svc/settings
Changes any of the service's settings in one step. Send base_generation (the generation you read) and only the fields you change.
The answer says how it applies: applied_now (health check, disk raised), or needs_redeploy (source, build, start, size, replicas). Send redeploy: 1 to deploy at once. If someone changed the settings since you read them, the update is refused with stale_generation.
Needs a key with full access.
- Authentication: Secret key (send it as
Authorization: Bearer <key>) - Idempotency: Safe to retry. Send an
Idempotency-Keyheader and repeated calls within 24 hours return the first result.
Parameters
svcstring, required: The service's id. Example:svc_01jdk3n2f4g6h8j0k2l4z6x8cabase_generationnumber, required: The generation you read. Example:7redeploynumber, optional: 1 deploys after saving. Example:1namestring, optional: A new name. Example:apisource_kindstring, optional: repo or image. Example:imageimage_refstring, optional: The image, for an image service. Example:ghcr.io/acme/api:1.4.2branchstring, optional: The branch to deploy from.root_dirstring, optional: The folder of the repository to build.build_cmdstring, optional: The build command.start_cmdstring, optional: The start command. Example:node dist/server.jsrestart_policystring, optional: always, on_failure or never.cpu_millisnumber, optional: CPU per replica in millicores.memory_mbnumber, optional: Memory per replica in MB.disk_mbnumber, optional: Temporary disk per replica, whole GB in MB.replicasnumber, optional: Replicas, 1 to 10. Example:2healthcheck_pathstring, optional: The health check path, or null to clear it. Example:/healthzhealthcheck_timeout_snumber, optional: Seconds before one check fails, or null for the default.
Returns
- 200: generation, apply (applied_now or needs_redeploy) and dep when a deployment started.
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | A field is missing or not valid. The message names it. |
| 404 | not_found | No such object in the key's project (or environment). |
| 409 | stale_generation | Someone changed it since you read it: read it again and retry. |
| 409 | service_replicas_volume | A service with a volume runs one replica. |
| 409 | account_frozen | The workspace is out of credits: add credits on the dashboard to create, change or deploy. |
Request samples
Dispra Cloud CLI
dcloud api PATCH /v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/settings --data '{"base_generation":7,"redeploy":1,"name":"api","source_kind":"image","image_ref":"ghcr.io/acme/api:1.4.2","start_cmd":"node dist/server.js","replicas":2,"healthcheck_path":"/healthz"}'
cURL
curl -X PATCH "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/settings" \
-H "Authorization: Bearer dsp_live_YOUR_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"base_generation":7,"redeploy":1,"name":"api","source_kind":"image","image_ref":"ghcr.io/acme/api:1.4.2","start_cmd":"node dist/server.js","replicas":2,"healthcheck_path":"/healthz"}'
Node
const res = await fetch("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/settings", {
method: "PATCH",
headers: { Authorization: "Bearer dsp_live_YOUR_KEY", "Idempotency-Key": crypto.randomUUID(), "Content-Type": "application/json" },
body: JSON.stringify({
"base_generation": 7,
"redeploy": 1,
"name": "api",
"source_kind": "image",
"image_ref": "ghcr.io/acme/api:1.4.2",
"start_cmd": "node dist/server.js",
"replicas": 2,
"healthcheck_path": "/healthz"
}),
});
console.log(await res.json());
Python
import uuid, requests
res = requests.request("PATCH", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/settings", headers={"Authorization": "Bearer dsp_live_YOUR_KEY", "Idempotency-Key": str(uuid.uuid4())}, json={
"base_generation": 7,
"redeploy": 1,
"name": "api",
"source_kind": "image",
"image_ref": "ghcr.io/acme/api:1.4.2",
"start_cmd": "node dist/server.js",
"replicas": 2,
"healthcheck_path": "/healthz"
})
print(res.json())
Go
body := strings.NewReader(`{"base_generation":7,"redeploy":1,"name":"api","source_kind":"image","image_ref":"ghcr.io/acme/api:1.4.2","start_cmd":"node dist/server.js","replicas":2,"healthcheck_path":"/healthz"}`)
req, _ := http.NewRequest("PATCH", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/settings", body)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
req.Header.Set("Idempotency-Key", uuid.NewString())
res, _ := http.DefaultClient.Do(req)
Responses
200
{}
400 invalid_request
{
"error": {
"code": "invalid_request",
"message": "A field is missing or not valid. The message names it.",
"request_id": "req_7f3a9c21d84be056"
}
}
404 not_found
{
"error": {
"code": "not_found",
"message": "No such object in the key's project (or environment).",
"request_id": "req_7f3a9c21d84be056"
}
}
409 stale_generation
{
"error": {
"code": "stale_generation",
"message": "Someone changed it since you read it: read it again and retry.",
"request_id": "req_7f3a9c21d84be056"
}
}
409 service_replicas_volume
{
"error": {
"code": "service_replicas_volume",
"message": "A service with a volume runs one replica.",
"request_id": "req_7f3a9c21d84be056"
}
}
409 account_frozen
{
"error": {
"code": "account_frozen",
"message": "The workspace is out of credits: add credits on the dashboard to create, change or deploy.",
"request_id": "req_7f3a9c21d84be056"
}
}