# ServiceConfig

> Settings of a service.

Settings of a service. Every field is optional in updates; PATCH uses JSON Merge Patch semantics (null clears).

## Fields

| Field | Type | Description |
| --- | --- | --- |
| `source` | [ServiceSource](/docs/api/objects/service-source/) |  |
| `build` | [BuildSettings](/docs/api/objects/build-settings/) |  |
| `start` | string or null | Start command. Detected when empty. |
| `pre_deploy` | string or null | Runs once per deployment in a separate VM before traffic moves; failure stops the rollout. |
| `port` | integer or null |  |
| `healthcheck` | [Healthcheck](/docs/api/objects/healthcheck/) or any or null |  |
| `resources` | [ServiceResources](/docs/api/objects/service-resources/) |  |
| `replicas` | [Replicas](/docs/api/objects/replicas/) |  |
| `sleep_when_idle` | boolean | Scale to zero after 10 idle minutes; the first request wakes it in 1–3 s. |
| `private` | boolean | No public domain; reachable only on the environment's private network. |
| `cron` | [CronSettings](/docs/api/objects/cron-settings/) or any or null |  |
| `restart_policy` | object |  |
| `deploy` | object |  |
| `volumes` | array of [VolumeMount](/docs/api/objects/volume-mount/) |  |

\* always present

## Example

```json
{
  "source": {
    "kind": "git",
    "repo": "string",
    "root": "apps/web",
    "watch": [
      "apps/web/**",
      "packages/ui/**",
      "pnpm-lock.yaml"
    ],
    "image": "ghcr.io/acme/api:1.4.2",
    "registry_credentials_secret": "string"
  },
  "build": {
    "builder": "railpack",
    "dockerfile": "services/api/Dockerfile",
    "context": "string"
  },
  "start": "pnpm --filter web start",
  "pre_deploy": "pnpm --filter db migrate deploy",
  "port": 3000,
  "healthcheck": {
    "type": "http",
    "path": "/healthz",
    "port": 1,
    "timeout_seconds": 10,
    "interval_seconds": 10,
    "start_timeout_seconds": 300
  },
  "resources": {
    "cpu": 1,
    "memory_mb": 1024
  },
  "replicas": {
    "min": 1,
    "max": 1,
    "scale_on": {
      "cpu_percent": 10,
      "memory_percent": 10,
      "concurrency": 1
    }
  },
  "sleep_when_idle": false,
  "private": false,
  "cron": {
    "schedule": "0 2 * * *",
    "timezone": "Europe/London",
    "timeout_seconds": 1,
    "concurrency_policy": "forbid"
  },
  "restart_policy": {
    "mode": "on_failure",
    "max_retries": 10
  },
  "deploy": {
    "overlap_seconds": 20,
    "auto_rollback": false
  },
  "volumes": [
    {
      "volume": "string",
      "mount_path": "/data"
    }
  ]
}
```

## Used by

- [Update a service's base settings](/docs/api/services/#update-a-services-base-settings)
