Central API Examples
[](/)
Development
Central API
Central API Examples
On this page
In the examples below use the following placeholder variables to match commonly-needed parameters:
$ZT_TOKEN: an API token associated with an active account on Central
$NWID: an active network ID
info
See the Central API Tokens guide for an explanation of how to create and manage API tokens.
The examples below are intended to run in a system terminal, and require the following command-line tools:
curl
jq
Each of them will fetch network information and produce CSV as output. You can then import that CSV into your choice of database, spreadsheet, or configuration-management tool(s).
Networks
Network Members
Authorize Member
Deauthorize Member
Development
Central API
Central API Examples
On this page
In the examples below use the following placeholder variables to match commonly-needed parameters:
$ZT_TOKEN: an API token associated with an active account on Central
$NWID: an active network ID
info
See the Central API Tokens guide for an explanation of how to create and manage API tokens.
Exporting Data from the Central API[](#exporting-data-from-the-central-api "Direct link to Exporting Data from the Central API")
The examples below are intended to run in a system terminal, and require the following command-line tools:
curl
jq
Each of them will fetch network information and produce CSV as output. You can then import that CSV into your choice of database, spreadsheet, or configuration-management tool(s).
Networks
Network Members
List current networks[](#list-current-networks "Direct link to List current networks")
curl -s -H "Authorization: token $ZT_TOKEN" \ "https://api.zerotier.com/api/v1/network" \ | jq '.[] | [ .id, .config.name, .config.description, .totalMemberCount, .config.creationTime, .config.ipAssignmentPools[0].ipRangeStart, .config.ipAssignmentPools[0].ipRangeEnd ]' \ | jq -rs '.[] | @csv'
List network members[](#list-network-members "Direct link to List network members")
curl -H "Authorization: token $ZT_TOKEN" \ "https://api.zerotier.com/api/v1/network/$NWID/member" \ | jq '.[] | [ .id, .lastSeen, .physicalAddress, .ipAssignments[0], .name ]' \ | jq -rs '.[] | @csv
Authorize and Deauthorize Network Members[](#authorize-and-deauthorize-network-members "Direct link to Authorize and Deauthorize Network Members")
Authorize Member
Deauthorize Member
Authorize a network member[](#authorize-a-network-member "Direct link to Authorize a network member")
curl -H "Authorization: token $ZT_TOKEN" -X POST \ "https://api.zerotier.com/api/v1/network/$NWID/member/$MEMBER_ID" \ --data '{"config": {"authorized": true}}'
Deauthorize a network member[](#deauthorize-a-network-member "Direct link to Deauthorize a network member")
curl -H "Authorization: token $ZT_TOKEN" -X POST \ "https://api.zerotier.com/api/v1/network/$NWID/member/$MEMBER_ID" \ --data '{"config": {"authorized": false}}'
Updated on: 12/07/2024
Thank you!