---
id: update-a-rule
title: "Update a Rule"
description: "Update/Replace a Rule"
sidebar_label: "Update a Rule"
hide_title: true
hide_table_of_contents: true
api: {"description":"Update/Replace a Rule","tags":["Rules"],"security":[{"BearerAuth":[]},{"TokenAuth":[]}],"parameters":[{"in":"path","name":"ruleId","required":true,"schema":{"type":"string"},"description":"The unique identifier of a rule"}],"requestBody":{"description":"Update Rule request","content":{"application/json":{"schema":{"allOf":[{"type":"object","properties":{"name":{"description":"Rule name identifier","type":"string"},"description":{"description":"Rule friendly description","type":"string"},"disabled":{"description":"Rules status","type":"boolean"},"flow":{"description":"Rule flow, currently, only \"bidirect\" for bi-directional traffic is accepted","type":"string"}},"required":["name","description","disabled","flow"],"title":"RuleMinimum"},{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string"}},"destinations":{"type":"array","items":{"type":"string"}}}}]}}}},"responses":{"200":{"description":"A Rule object","content":{"application/json":{"schema":{"allOf":[{"type":"object","properties":{"id":{"description":"Rule ID","type":"string"}},"required":["id"]},{"type":"object","properties":{"name":{"description":"Rule name identifier","type":"string"},"description":{"description":"Rule friendly description","type":"string"},"disabled":{"description":"Rules status","type":"boolean"},"flow":{"description":"Rule flow, currently, only \"bidirect\" for bi-directional traffic is accepted","type":"string"}},"required":["name","description","disabled","flow"],"title":"RuleMinimum"},{"type":"object","properties":{"sources":{"description":"Rule source groups","type":"array","items":{"type":"object","properties":{"id":{"description":"Group ID","type":"string"},"name":{"description":"Group Name identifier","type":"string"},"peers_count":{"description":"Count of peers associated to the group","type":"integer"}},"required":["id","name","peers_count"],"title":"GroupMinimum"}},"destinations":{"description":"Rule destination groups","type":"array","items":{"type":"object","properties":{"id":{"description":"Group ID","type":"string"},"name":{"description":"Group Name identifier","type":"string"},"peers_count":{"description":"Count of peers associated to the group","type":"integer"}},"required":["id","name","peers_count"],"title":"GroupMinimum"}}},"required":["sources","destinations"]}],"title":"Rule"}}}},"400":{"description":"Bad Request","content":{}},"401":{"description":"Requires authentication","content":{}},"403":{"description":"Forbidden","content":{}},"500":{"description":"Internal Server Error","content":{}}},"method":"put","path":"/api/rules/{ruleId}","servers":[{"url":"https://netbird.io","description":"Default server"}],"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"TokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Prefix the value with \\\"Token\\\" to indicate the custom authorization type"}},"jsonRequestBodyExample":{"name":"string","description":"string","disabled":true,"flow":"string","sources":["string"],"destinations":["string"]},"info":{"title":"NetBird REST API","description":"API to manipulate groups, rules, policies and retrieve information about peers and users","version":"0.0.1"},"postman":{"name":"Update a Rule","description":{"content":"Update/Replace a Rule","type":"text/plain"},"url":{"path":["api","rules",":ruleId"],"host":["{{baseUrl}}"],"query":[],"variable":[{"disabled":false,"description":{"content":"(Required) The unique identifier of a rule","type":"text/plain"},"type":"any","value":"","key":"ruleId"}]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"method":"PUT","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}},"auth":{"type":"bearer","bearer":[{"type":"any","value":"<Bearer Token>","key":"token"}]}}}
sidebar_class_name: "put api-method"
info_path: api/netbird-rest-api
custom_edit_url: null
---

import ApiTabs from "@theme/ApiTabs";
import MimeTabs from "@theme/MimeTabs";
import ParamsItem from "@theme/ParamsItem";
import ResponseSamples from "@theme/ResponseSamples";
import SchemaItem from "@theme/SchemaItem";
import SchemaTabs from "@theme/SchemaTabs";
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
import TabItem from "@theme/TabItem";

## Update a Rule



Update/Replace a Rule

<details style={{"marginBottom":"1rem"}} data-collapsed={false} open={true}><summary style={{}}><strong>Path Parameters</strong></summary><div><ul><ParamsItem className={"paramsItem"} param={{"in":"path","name":"ruleId","required":true,"schema":{"type":"string"},"description":"The unique identifier of a rule"}}></ParamsItem></ul></div></details><MimeTabs><TabItem label={"application/json"} value={"application/json-schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Request Body</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}><div style={{"marginTop":"1rem","marginBottom":"1rem"}}>

Update Rule request

</div></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"name"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule name identifier","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"description"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule friendly description","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"disabled"} required={true} schemaName={"boolean"} qualifierMessage={undefined} schema={{"description":"Rules status","type":"boolean"}}></SchemaItem><SchemaItem collapsible={false} name={"flow"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule flow, currently, only \"bidirect\" for bi-directional traffic is accepted","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"sources"} required={false} schemaName={"string[]"} qualifierMessage={undefined} schema={{"type":"array","items":{"type":"string"}}}></SchemaItem><SchemaItem collapsible={false} name={"destinations"} required={false} schemaName={"string[]"} qualifierMessage={undefined} schema={{"type":"array","items":{"type":"string"}}}></SchemaItem></ul></details></TabItem></MimeTabs><div><ApiTabs><TabItem label={"200"} value={"200"}><div>

A Rule object

</div><div><MimeTabs schemaType={"response"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs><TabItem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule ID","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule name identifier","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"description"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule friendly description","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"disabled"} required={true} schemaName={"boolean"} qualifierMessage={undefined} schema={{"description":"Rules status","type":"boolean"}}></SchemaItem><SchemaItem collapsible={false} name={"flow"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Rule flow, currently, only \"bidirect\" for bi-directional traffic is accepted","type":"string"}}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>sources</strong><span style={{"opacity":"0.6"}}> object[]</span><strong style={{"fontSize":"var(--ifm-code-font-size)","color":"var(--openapi-required)"}}> required</strong></summary><div style={{"marginLeft":"1rem"}}><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>

Rule source groups

</div><li><div style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem","paddingBottom":".5rem"}}>Array [</div></li><SchemaItem collapsible={false} name={"id"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Group ID","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Group Name identifier","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"peers_count"} required={true} schemaName={"integer"} qualifierMessage={undefined} schema={{"description":"Count of peers associated to the group","type":"integer"}}></SchemaItem><li><div style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem"}}>]</div></li></div></details></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>destinations</strong><span style={{"opacity":"0.6"}}> object[]</span><strong style={{"fontSize":"var(--ifm-code-font-size)","color":"var(--openapi-required)"}}> required</strong></summary><div style={{"marginLeft":"1rem"}}><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>

Rule destination groups

</div><li><div style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem","paddingBottom":".5rem"}}>Array [</div></li><SchemaItem collapsible={false} name={"id"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Group ID","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Group Name identifier","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"peers_count"} required={true} schemaName={"integer"} qualifierMessage={undefined} schema={{"description":"Count of peers associated to the group","type":"integer"}}></SchemaItem><li><div style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem"}}>]</div></li></div></details></SchemaItem></ul></details></TabItem><TabItem label={"Example (from schema)"} value={"Example (from schema)"}><ResponseSamples responseExample={"{\n  \"id\": \"string\",\n  \"name\": \"string\",\n  \"description\": \"string\",\n  \"disabled\": true,\n  \"flow\": \"string\",\n  \"sources\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"peers_count\": 0\n    }\n  ],\n  \"destinations\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"peers_count\": 0\n    }\n  ]\n}"} language={"json"}></ResponseSamples></TabItem></SchemaTabs></TabItem></MimeTabs></div></TabItem><TabItem label={"400"} value={"400"}><div>

Bad Request

</div><div></div></TabItem><TabItem label={"401"} value={"401"}><div>

Requires authentication

</div><div></div></TabItem><TabItem label={"403"} value={"403"}><div>

Forbidden

</div><div></div></TabItem><TabItem label={"500"} value={"500"}><div>

Internal Server Error

</div><div></div></TabItem></ApiTabs></div>
      