--- id: create-a-rule title: "Create a Rule" description: "Creates a Rule" sidebar_label: "Create a Rule" hide_title: true hide_table_of_contents: true api: {"description":"Creates a Rule","tags":["Rules"],"security":[{"BearerAuth":[]},{"TokenAuth":[]}],"requestBody":{"description":"New 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"}}}}},"method":"post","path":"/api/rules","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":"Create a Rule","description":{"content":"Creates a Rule","type":"text/plain"},"url":{"path":["api","rules"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}},"auth":{"type":"bearer","bearer":[{"type":"any","value":"","key":"token"}]}}} sidebar_class_name: "post 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"; ## Create a Rule Creates a Rule
Request Body
New Rule request
A Rule Object
Schema
    sources object[] required
    Rule source groups
  • Array [
  • ]
  • destinations object[] required
    Rule destination groups
  • Array [
  • ]