---
title: "Set port mappings"
method: PUT
path: "/api/v1/cvms/{cvm_id}/ports"
tags: ["CVMs", "cvms-network-config"]
---

# Set port mappings

`PUT /api/v1/cvms/{cvm_id}/ports`

Bulk-replace all port mappings for this CVM. Writes to DB and applies to VMM.

## Path parameters

- `cvm_id` string, required

## Request body

- UpdatePortMappingsRequest — Bulk-replace all port mappings for a CVM.
  - `ports` PortMappingEntry[], required
    - `vm_port` integer, required
    - `protocol` string

## Response `200`

Updated port mappings

- PortMappingResponse[]
  - `id` string, hashid, required — A hashed identifier that maps to an internal database ID
  - `host_port` integer, required
  - `vm_port` integer, required
  - `protocol` string, required
  - `host_address` string, required

## Other responses

- `400` — Invalid request
- `403` — Feature not enabled for this workspace
- `404` — CVM not found
- `409` — Port conflict during concurrent updates
- `422` — Validation Error

---

[API](https://skmtc.net/phala/apis/phala-cloud-api.md) · [All operations](https://skmtc.net/phala/apis/phala-cloud-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/phala/phala-cloud-api/versions/83c6ae62e860/schema)
