news
Serverspace Technologies in the UAE: Launch of Falconcloud
WT
July 21, 2023
Updated July 24, 2023

Creating a Zabbix API Tokens

Zabbix

Zabbix is a powerful open-source monitoring solution that enables you to monitor and manage IT infrastructure. The Zabbix API allows for programmatic interaction with the Zabbix server, facilitating automation and integration. In this tutorial, we will walk you through the process of creating a Zabbix API token, which grants access to the API's functionality.



Creating tokens

Access the Zabbix web interface using your preferred web browser and enter your login credentials to access the Zabbix dashboard.

Now you have two ways: you can either manage the tokens yourself or give Zabbix users the rights to create tokens for themselves.

If you want to create tokens by yourself you will need to go Administration → General → API tokens.

API tokens menu

Here you can see through the list of the tokens created for your Zabbix, disable or enable them if needed, or check the expiration date.

Click "create API token".

Creating tokens

Fill in the lines, hit add and you will see something like this:

Token created

Don’t forget to save the token somewhere safe, or you won’t be able to see it after the creation.

If you want the users to be able to create tokens for themselves - edit their user group permissions: Make access to API enable, also you can whitelist, or blacklist the API methods of your choosing here.

Zabbix API 4

After that the user will be able to see or create his token in this menu.

User setting - API tokens menu

Testing with cURL:

To test the API token, you can use cURL, a command-line tool for making HTTP requests.

Launch your terminal or command prompt to execute cURL commands.

Use the following cURL command template to make an API request:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_TOKEN" -d '{"jsonrpc":"2.0","method":"user.login","params":{"user":"YOUR_USERNAME","password":"YOUR_PASSWORD"},"id":1}' http://YOUR_ZABBIX_SERVER/api_jsonrpc.php

Make sure to replace the following placeholders with your actual information:

  • YOUR_API_TOKEN: Replace this with the API token you generated.
  • YOUR_USERNAME: Provide your Zabbix username.
  • YOUR_PASSWORD: Enter your Zabbix password.
  • YOUR_ZABBIX_SERVER: Enter the URL or IP address of your Zabbix server.

Copy and paste the constructed cURL command into your terminal or command prompt. Press Enter to execute the command.

Check the response returned by the Zabbix API. It should indicate the success or failure of your API request. You will receive something like this if everything is right:

Request result

Conclusion:

Congratulations! You have successfully created a Zabbix API token in Zabbix 6.4. This token allows you to programmatically interact with the Zabbix API and leverage its capabilities for automation and integration. By using tools like cURL, you can test the API token and verify its functionality. Explore the extensive Zabbix API documentation to discover the full range of possibilities for monitoring and managing your IT infrastructure.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.