About the Subnets API

API Version: 1.9

The Subnets API allows you to save subnets and manage your saved subnets.

This is the API for Subnets.

See also: Subnet Calculator API

Endpoints

https://networkcalc.com/api/account/subnets/{subnet_id}

List one or more of the subnets saved to your account.

Example request and response
curl https://networkcalc.com/api/account/subnets/12345 \
  --header "Authorization: Bearer 2jdS83kfDdDfllHk"

{
  "status": "OK",
  "subnets": [
    {
      "octet_1": 10,
      "octet_2": 0,
      "octet_3": 1,
      "octet_4": 0,
      "subnet_bits": 24,
      "cidr_notation": "10.0.1.0/24",
      "subnet_mask": {
        "octet_1": "255",
        "octet_2": "255",
        "octet_3": "255",
        "octet_4": "0"
      },
      "assignable_hosts": 254,
      "id": 12345,
      "is_active": 1,
      "network_address": "10.0.1.0",
      "name": "Example Subnet"
    }
  ]
}
This endpoint requires authorization. Read about API authorization or see NetworkCalc Pro pricing.

Parameters

{subnet_id}

(Optional) The unique ID of the subnet.

Example: https://networkcalc.com/api/account/subnets/12345

Response Codes

200
OK - Success.
401
INVALID_REQUEST - The authorization header is missing.
401
INVALID_GRANT - The given access token is expired or invalid.
400
MISSING_HEADER - A required header is missing.
400
MISSING_VALUES - One of the required parameters is missing from the body.
400
NOT_UPDATED - The subnet could not be saved. Verify the request and try again.
400
NOT_DELETED - The subnet could not be deleted. Verify the request and try again.
400
NOT_FOUND - A subnet with the given ID could not be found.
400
NETWORK_ADDRESS_INVALID - The supplied network address is incorrectly formatted or otherwise invalid.
400
SYSTEM_ERROR - A system error occurred. Try the request again.
https://networkcalc.com/api/account/subnets/

Save a subnet to your account.

Example request and response
curl -X POST https://networkcalc.com/api/account/subnets \
  --header "Authorization: Bearer 2jdS83kfDdDfllHk" \
  --header "Content-Type: application/json" \
  --data '{
  "network_address": "10.0.5.0",
  "subnet_bits": 27,
  "name": "My Favorite Subnet"
}'

{
  "status": "OK",
  "subnet": {
    "octet_1": 10,
    "octet_2": 0,
    "octet_3": 5,
    "octet_4": 0,
    "subnet_bits": 27,
    "cidr_notation": "10.0.5.0/27",
    "subnet_mask": {
      "octet_1": "255",
      "octet_2": "255",
      "octet_3": "255",
      "octet_4": "224"
    },
    "assignable_hosts": 30,
    "name": "My Favorite Subnet",
    "id": 235
  }
}
This endpoint requires authorization. Read about API authorization or see NetworkCalc Pro pricing.

Request Headers

Content-Type
(Required) application/json

Request Body

{
  "network_address": "[string] The network address in dotted decimal notation. Also accepts any IP address in the subnet.",
  "subnet_bits": "[number] The number of bits representing the subnet mask.",
  "name": "[string] A display name for the subnet."
}

Response Codes

200
OK - Success.
401
INVALID_REQUEST - The authorization header is missing.
401
INVALID_GRANT - The given access token is expired or invalid.
400
MISSING_HEADER - A required header is missing.
400
MISSING_VALUES - One of the required parameters is missing from the body.
400
NOT_UPDATED - The subnet could not be saved. Verify the request and try again.
400
NOT_DELETED - The subnet could not be deleted. Verify the request and try again.
400
NOT_FOUND - A subnet with the given ID could not be found.
400
NETWORK_ADDRESS_INVALID - The supplied network address is incorrectly formatted or otherwise invalid.
400
SYSTEM_ERROR - A system error occurred. Try the request again.
https://networkcalc.com/api/account/subnets/

Edit a subnet in your account.

Example request and response
curl -X PATCH https://networkcalc.com/api/account/subnets/235 \
  --header "Authorization: Bearer 2jdS83kfDdDfllHk" \
  --header "Content-Type: application/json" \
  --data '{
  "name": "My Favorite Subnet with Edits"
}'

{
  "status": "OK",
  "message": "1 record(s) updated."
}
This endpoint requires authorization. Read about API authorization or see NetworkCalc Pro pricing.

Request Headers

Content-Type
(Required) application/json

Request Body

{
  "network_address": "[string] The network address in dotted decimal notation. Also accepts any IP address in the subnet.",
  "subnet_bits": "[number] The number of bits representing the subnet mask.",
  "name": "[string] A display name for the subnet."
}

Response Codes

200
OK - Success.
401
INVALID_REQUEST - The authorization header is missing.
401
INVALID_GRANT - The given access token is expired or invalid.
400
MISSING_HEADER - A required header is missing.
400
MISSING_VALUES - One of the required parameters is missing from the body.
400
NOT_UPDATED - The subnet could not be saved. Verify the request and try again.
400
NOT_DELETED - The subnet could not be deleted. Verify the request and try again.
400
NOT_FOUND - A subnet with the given ID could not be found.
400
NETWORK_ADDRESS_INVALID - The supplied network address is incorrectly formatted or otherwise invalid.
400
SYSTEM_ERROR - A system error occurred. Try the request again.
https://networkcalc.com/api/account/subnets/

Delete a subnet in your account.

Example request and response
curl -X DELETE https://networkcalc.com/api/account/subnets/235 \
  --header "Authorization: Bearer 2jdS83kfDdDfllHk" \
  --header "Content-Type: application/json"

{
  "status": "OK"
}
This endpoint requires authorization. Read about API authorization or see NetworkCalc Pro pricing.

Request Headers

Content-Type
(Required) application/json

Response Codes

200
OK - Success.
401
INVALID_REQUEST - The authorization header is missing.
401
INVALID_GRANT - The given access token is expired or invalid.
400
MISSING_HEADER - A required header is missing.
400
MISSING_VALUES - One of the required parameters is missing from the body.
400
NOT_UPDATED - The subnet could not be saved. Verify the request and try again.
400
NOT_DELETED - The subnet could not be deleted. Verify the request and try again.
400
NOT_FOUND - A subnet with the given ID could not be found.
400
NETWORK_ADDRESS_INVALID - The supplied network address is incorrectly formatted or otherwise invalid.
400
SYSTEM_ERROR - A system error occurred. Try the request again.

Response Formats

{
  "status": "[string] The status of the request.",
  "subnets": "[array] An array of all subnets matching the request. See SubnetResponse."
}
{
  "octet_1": "[number] The first octet in the subnet address (decimal representation).",
  "octet_2": "[number] The second octet in the subnet address (decimal representation).",
  "octet_3": "[number] The third octet in the subnet address (decimal representation).",
  "octet_4": "[number] The fourth octet in the subnet address (decimal representation).",
  "subnet_bits": "[number] The number of bits representing the subnet mask.",
  "cidr_notation": "[string] The requested address in CIDR notation, per RFC 4632.",
  "subnet_mask": {
    "octet_1": "[string] The first octet in the subnet mask (decimal representation).",
    "octet_2": "[string] The second octet in the subnet mask (decimal representation).",
    "octet_3": "[string] The third octet in the subnet mask (decimal representation).",
    "octet_4": "[string] The fourth octet in the subnet mask (decimal representation)."
  },
  "assignable_hosts": "[number] The number of assignable hosts in the subnet.",
  "id": "[number] The subnet's unique identifier.",
  "is_active": "[number] 1 if the subnet is active, 0 otherwise.",
  "network_address": "[string] The network ID for the subnet (first address in the subnet; unassignable).",
  "name": "[string] The display name given to the subnet."
}
{
  "status": "[string] The status of the request.",
  "message": "[string] A detailed description of the request status.",
  "errors": "[array] A list of error messages. Only included if errors occurred."
}
{
  "status": "[string] The status of the request."
}