---
title: "Create or update service"
method: PUT
path: "/service/{id}"
tags: ["service"]
---

# Create or update service

`PUT /service/{id}`

## Path parameters

- `id` integer, required

## Request body

- ServiceSpec — Configuration of a service
  - `id` integer — Unique identification
  - `frontend-address` FrontendAddress, required — Layer 4 address. The protocol is currently ignored, all services will behave as if protocol any is specified. To restrict to a particular protocol, use policy.
    - `ip` string — Layer 3 address
    - `protocol` 'tcp' | 'udp' | 'any' — Layer 4 protocol
    - `scope` 'external' | 'internal' — Load balancing scope for frontend address
    - `port` integer — Layer 4 port number
  - `backend-addresses` BackendAddress[] — List of backend addresses
    - `ip` string, required — Layer 3 address
    - `protocol` string — Layer 4 protocol (TCP, UDP, etc)
    - `port` integer — Layer 4 port number
    - `nodeName` string — Optional name of the node on which this backend runs
    - `state` 'active' | 'terminating' | 'quarantined' | 'maintenance' — State of the backend for load-balancing service traffic
    - `preferred` boolean — Indicator if this backend is preferred in the context of clustermesh service affinity. The value is set based on related annotation of global service. Applicable for active state only.
    - `weight` integer, nullable — Backend weight
    - `zone` string — Optional name of the zone in which this backend runs
  - `flags` object — Optional service configuration flags
    - `type` 'ClusterIP' | 'NodePort' | 'ExternalIPs' | 'HostPort' | 'LoadBalancer' | 'LocalRedirect' — Service type
    - `trafficPolicy` 'Cluster' | 'Local' — Service external traffic policy (deprecated in favor of extTrafficPolicy)
    - `extTrafficPolicy` 'Cluster' | 'Local' — Service external traffic policy
    - `intTrafficPolicy` 'Cluster' | 'Local' — Service internal traffic policy
    - `natPolicy` 'None' | 'Nat46' | 'Nat64' — Service protocol NAT policy
    - `healthCheckNodePort` integer — Service health check node port
    - `name` string — Service name (e.g. Kubernetes service name)
    - `namespace` string — Service namespace (e.g. Kubernetes namespace)
    - `cluster` string — Service cluster
  - `updateServices` boolean — Update all services selecting the backends with their given states (id and frontend are ignored)

## Response `200`

Updated

## Other responses

- `201` — Created
- `403` — Forbidden
- `460` — Invalid frontend in service configuration
- `461` — Invalid backend in service configuration
- `500` — Error while creating service
- `501` — Error while updating backend states

## Changes

- **2024-09-03** (v1) `5b32623f4b87` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/cilium/apis/cilium-api/changes/service/:id/put.md)

---

[API](https://skmtc.dev/cilium/apis/cilium-api.md) · [All operations](https://skmtc.dev/cilium/apis/cilium-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/cilium/cilium-api/revisions/5b32623f4b87/schema)
