> 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/2.1/for-developers/rest-api/core/network/import-a-network-from-a-wireguard-configuration-file.md).

# Import a network from a WireGuard configuration file

Devices found in the configuration are returned unmapped; use `POST /api/v1/network/{network_id}/devices` to assign them to users.

```json
{"openapi":"3.1.0","info":{"title":"defguard Core API","version":"2.1.0"},"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":{"ImportNetworkData":{"type":"object","required":["name","endpoint","config","allow_all_groups","allowed_groups"],"properties":{"allow_all_groups":{"type":"boolean"},"allowed_groups":{"type":"array","items":{"type":"string"}},"config":{"type":"string"},"endpoint":{"type":"string"},"name":{"type":"string"}}},"ImportedNetworkData":{"type":"object","required":["network","devices"],"properties":{"devices":{"type":"array","items":{"$ref":"#/components/schemas/ImportedDevice"}},"network":{"$ref":"#/components/schemas/WireguardNetwork_i64"}}},"ImportedDevice":{"type":"object","required":["name","wireguard_pubkey","wireguard_ips"],"properties":{"name":{"type":"string"},"user_id":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/i64"}]},"wireguard_ips":{"type":"array","items":{"type":"string"}},"wireguard_pubkey":{"type":"string"}}},"i64":{"type":"integer","format":"int64"},"WireguardNetwork_i64":{"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","allowed_ips_from_acl","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"}},"allowed_ips_from_acl":{"type":"boolean"},"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"}}},"LocationMfaMode":{"type":"string","enum":["disabled","internal","external"]},"ServiceLocationMode":{"type":"string","enum":["disabled","prelogon","alwayson"]},"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/import":{"post":{"tags":["network"],"summary":"Import a network from a WireGuard configuration file","description":"Devices found in the configuration are returned unmapped; use\n`POST /api/v1/network/{network_id}/devices` to assign them to users.","operationId":"import_network","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportNetworkData"}}},"required":true},"responses":{"201":{"description":"Network imported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportedNetworkData"}}}},"400":{"description":"Invalid WireGuard configuration.","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"}}}},"413":{"description":"Configuration file too large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"500":{"description":"Unable to import network.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}}}}}}}
```
