---
title: "Assign server to firewall"
method: POST
path: "/firewalls/{firewall_id}/assignments"
tags: ["Firewalls"]
---

# Assign server to firewall

`POST /firewalls/{firewall_id}/assignments`

## Request

- Base URL: `https://api.latitude.sh`
- URL: `https://api.latitude.sh/firewalls/{firewall_id}/assignments`
- Auth: API key in header `Authorization`

Assigns a server or a virtual machine to a firewall by its ID.

## Path parameters

- `firewall_id` string, required

## Request body

- object
  - `data` object, required
    - `type` 'firewall_assignments', required
    - `attributes` object
      - `server_id` string: The server ID to assign. Provide exactly one of server_id or virtual_machine_id. A server can be assigned to at most one firewall.
      - `virtual_machine_id` string: The virtual machine ID to assign. Provide exactly one of server_id or virtual_machine_id. A virtual machine can be assigned to at most one firewall.

## Response `201`

Created

## Changes

- **2026-08-26** `9a52f6ec0b3d`: 3 warning, 1 info
  - removed the optional property `attributes` from the response with the `201` status
  - removed the optional property `id` from the response with the `201` status
  - removed the optional property `type` from the response with the `201` status
  - added the optional property `data` to the response with the `201` status
- **2026-08-19** `9545f24e8507`: 4 info
  - added the new optional request property `data/attributes/virtual_machine_id` (media type: application/json)
  - added the new optional request property `data/attributes/virtual_machine_id` (media type: application/vnd.api+json)
  - the request property `data/attributes/server_id` became optional (media type: application/json)
  - the request property `data/attributes/server_id` became optional (media type: application/vnd.api+json)

[Operation history](https://skmtc.dev/latitude/apis/latitude-sh-api/changes/firewalls/:firewall_id/assignments/post.md)

---

[API](https://skmtc.dev/latitude/apis/latitude-sh-api.md) · [All operations](https://skmtc.dev/latitude/apis/latitude-sh-api/llms.txt) · [OpenAPI document](https://skmtc.dev/latitude/apis/latitude-sh-api/revisions/c45d92e99394?raw)
