> For the complete documentation index, see [llms.txt](https://docs.defguard.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.defguard.net/for-developers/rest-api/core/network/create-a-network.md).

# Create a network

```json
{"openapi":"3.1.0","info":{"title":"defguard Core API","version":"2.0.3"},"tags":[{"name":"network","description":"WireGuard networks, including import from a WireGuard configuration file."}],"security":[{"cookie":[]},{"api_token":[]}],"components":{"securitySchemes":{"cookie":{"type":"apiKey","in":"cookie","name":"defguard_session"},"api_token":{"type":"http","scheme":"bearer"}},"schemas":{"WireguardNetworkData":{"type":"object","required":["name","address","endpoint","port","mtu","fwmark","allow_all_groups","allowed_groups","keepalive_interval","peer_disconnect_threshold","acl_enabled","acl_default_allow","location_mfa_mode","service_location_mode"],"properties":{"acl_default_allow":{"type":"boolean"},"acl_enabled":{"type":"boolean"},"address":{"type":"string"},"allow_all_groups":{"type":"boolean"},"allowed_groups":{"type":"array","items":{"type":"string"}},"allowed_ips":{"type":["string","null"]},"dns":{"type":["string","null"]},"endpoint":{"type":"string"},"fwmark":{"type":"integer","format":"int64"},"keepalive_interval":{"type":"integer","format":"int32"},"location_mfa_mode":{"$ref":"#/components/schemas/LocationMfaMode"},"mtu":{"type":"integer","format":"int32"},"name":{"type":"string"},"peer_disconnect_threshold":{"type":"integer","format":"int32"},"port":{"type":"integer","format":"int32"},"service_location_mode":{"$ref":"#/components/schemas/ServiceLocationMode"}}},"LocationMfaMode":{"type":"string","enum":["disabled","internal","external"]},"ServiceLocationMode":{"type":"string","enum":["disabled","prelogon","alwayson"]},"WireguardNetwork":{"type":"object","description":"Stores the configuration required to set up a WireGuard network.","required":["id","name","address","port","pubkey","endpoint","mtu","fwmark","allowed_ips","allow_all_groups","acl_enabled","acl_default_allow","keepalive_interval","peer_disconnect_threshold","location_mfa_mode","service_location_mode"],"properties":{"acl_default_allow":{"type":"boolean"},"acl_enabled":{"type":"boolean"},"address":{"type":"array","items":{"type":"string"}},"allow_all_groups":{"type":"boolean"},"allowed_ips":{"type":"array","items":{"type":"string"}},"connected_at":{"type":["string","null"],"format":"date-time"},"dns":{"type":["string","null"]},"endpoint":{"type":"string"},"fwmark":{"type":"integer","format":"int64"},"id":{"type":"integer","format":"int64"},"keepalive_interval":{"type":"integer","format":"int32"},"location_mfa_mode":{"$ref":"#/components/schemas/LocationMfaMode"},"mtu":{"type":"integer","format":"int32"},"name":{"type":"string"},"peer_disconnect_threshold":{"type":"integer","format":"int32"},"port":{"type":"integer","format":"int32"},"pubkey":{"type":"string"},"service_location_mode":{"$ref":"#/components/schemas/ServiceLocationMode"}}},"ApiErrorResponse":{"type":"object","description":"Body returned with error responses.","required":["msg"],"properties":{"code":{"type":["string","null"],"description":"Machine-readable error code, returned for selected errors."},"msg":{"type":"string","description":"Human-readable error message."}}}}},"paths":{"/api/v1/network":{"post":{"tags":["network"],"summary":"Create a network","operationId":"create_network","requestBody":{"description":"`address` is a comma-separated list of network addresses.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WireguardNetworkData"}}},"required":true},"responses":{"201":{"description":"Network created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WireguardNetwork"}}}},"400":{"description":"Invalid location settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"401":{"description":"Session is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"403":{"description":"Requires admin privileges.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"500":{"description":"Unable to create network.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}}}}}}}
```
