> ## Documentation Index
> Fetch the complete documentation index at: https://www.latitude.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Assign server to firewall

> Assigns a server to a firewall by its ID.



## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples post /firewalls/{firewall_id}/assignments
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: IP Addresses
  - name: Kubernetes Clusters
  - name: Operating Systems
  - name: Plans
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
paths:
  /firewalls/{firewall_id}/assignments:
    post:
      tags:
        - Firewalls
      summary: Assign server to firewall
      description: Assigns a server to a firewall by its ID.
      operationId: create-firewall-assignment
      parameters:
        - name: firewall_id
          in: path
          description: The Firewall ID
          required: true
          examples:
            Created:
              value: fw_Ee8pKq05DWAob
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - firewall_assignments
                    attributes:
                      type: object
                      properties:
                        server_id:
                          type: string
                      required:
                        - server_id
                  required:
                    - type
              required:
                - data
            examples:
              Created:
                summary: Created
                value:
                  data:
                    type: firewall_assignments
                    attributes:
                      server_id: sv_aKXgRdR3qv9k5
          application/vnd.api+json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - firewall_assignments
                    attributes:
                      type: object
                      properties:
                        server_id:
                          type: string
                      required:
                        - server_id
                  required:
                    - type
              required:
                - data
            examples:
              Created:
                summary: Created
                value:
                  data:
                    type: firewall_assignments
                    attributes:
                      server_id: sv_aKXgRdR3qv9k5
        required: true
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              examples:
                Created:
                  value:
                    data:
                      id: fwasg_6VE1Wd37dXnZJ
                      type: firewall_assignments
                      attributes:
                        server:
                          id: sv_aKXgRdR3qv9k5
                          hostname: Ergonomic Wooden Keyboard
                          primary_ipv4: 132.192.74.198
                        firewall_id: fw_Ee8pKq05DWAob
              schema:
                $ref: '#/components/schemas/firewall_server'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.firewalls.assign(firewall_id="fw_Ee8pKq05DWAob", data={
                    "type": latitudesh_python_sdk.CreateFirewallAssignmentFirewallsType.FIREWALL_ASSIGNMENTS,
                    "attributes": {
                        "server_id": "sv_aKXgRdR3qv9k5",
                    },
                })

                # Handle response
                print(res)
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tlatitudeshgosdk \"github.com/latitudesh/latitudesh-go-sdk\"\n\t\"github.com/latitudesh/latitudesh-go-sdk/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := latitudeshgosdk.New(\n        latitudeshgosdk.WithSecurity(os.Getenv(\"LATITUDESH_BEARER\")),\n    )\n\n    res, err := s.Firewalls.Assignments.Create(ctx, \"fw_Ee8pKq05DWAob\", operations.CreateFirewallAssignmentFirewallsAssignmentsRequestBody{\n        Data: operations.CreateFirewallAssignmentFirewallsAssignmentsData{\n            Type: operations.CreateFirewallAssignmentFirewallsAssignmentsTypeFirewallAssignments,\n            Attributes: &operations.CreateFirewallAssignmentFirewallsAssignmentsAttributes{\n                ServerID: \"sv_aKXgRdR3qv9k5\",\n            },\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.FirewallServer != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Latitudesh } from "latitudesh-typescript-sdk";

            const latitudesh = new Latitudesh({
              bearer: process.env["LATITUDESH_BEARER"] ?? "",
            });

            async function run() {
              const result = await latitudesh.firewalls.assignments.create({
                firewallId: "fw_Ee8pKq05DWAob",
                requestBody: {
                  data: {
                    type: "firewall_assignments",
                    attributes: {
                      serverId: "sv_aKXgRdR3qv9k5",
                    },
                  },
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    firewall_server:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - firewall_servers
        attributes:
          type: object
          properties:
            server_id:
              type: string
            firewall_id:
              type: string
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````