ZPE Cloud API Resources
    • 26 Aug 2024
    • 4 Minutes to read
    • Dark
      Light
    • PDF

    ZPE Cloud API Resources

    • Dark
      Light
    • PDF

    Article summary

    ZPE Cloud provides an embedded Representational State Transfer (RESTful) API. This includes API calls to access and modify the ZPE Cloud configuration. Once configured, the REST-based interface is enabled for the users to:

    • Submit the requests supporting GET, POST, UPDATE/PUT, and DELETE operations. Use POST requests to submit the commands to the server. Use GET to retrieve information from the server. Use UPDATE/PUT to modify the parameter values. Use DELETE to delete a user or device from the site, group, profile, backup, or organization.

    • Retrieve configured data in JSON format.

    • Use endpoints, which interact with the API to perform various operations. Each endpoint corresponds to a particular function. For example, user_authenticate is the endpoint for a user to log into the application.

    Users can execute the API calls using the REST API GUI explorer provided via ZPE Cloud. For API developers, ZPE Cloud API resources are available here:

    To access the REST API GUI explorer use the following steps:

    1. Log in to the ZPE Cloud application.

    2. Enter your credentials.

    3. Click About.

    4. Select the applicable API. For example, for the user authentication API, select User API. You will be navigated to the page containing the list of APIs for that function.

    5. On the left panel, click the right arrow to display API calls for that function. You can also perform a search with the API name.

    Base URL

    The ZPE Cloud APIs are available via a secure HTTPS connection. The base URL for all the ZPE Cloud functions is:

    https://api.zpecloud.com ( For US users)
    https://api.zpecloud.eu (For EU Cloud users)

    Response Codes

    ZPE Cloud APIs use the following response codes:

    Status

    Description

    200

    Success

    204

    Delete request

    400

    Bad request. The payload syntax might be incorrect.

    401

    Unauthorized, mandatory field missing, or invalid credentials

    403

    Authentication credentials are not provided

    404

    Not found. The endpoint or resource was not found

    406

    User not authorized

    409

    User already exists

    500

    Internal server error

    Authenticate User

    This section shows the API to authenticate users to make the API calls to ZPE Cloud.

    Endpoint

    /user/auth - This is the endpoint for user login into the application.

    Request

    {
      "email": "user1@example.com",
      "password": "pwd@1234"
    }

    Response

    {
    "id": 2,
    "username": "user1",
    "email": "user1@example.com",
    "first_name": "testuserfn",
    "last_name": "testuserln",
    "type": "CA",
    "first_access": true,
    "creation_type": "local",
    "company": "ABC",
    "companies_count": "1",
    "setup_pwd": "pwd@1234",
    "session_timeout": 10,
    "access_level": "3"
    }

    The following table shows the list of values you may see in the response.

    Parameter

    Description

    id

    User ID of the user logged into the ZPE Cloud.

    username

    Name of the user to log in to the ZPE Cloud.

    email

    Email address of the user registered for the ZPE Cloud account.

    first name

    First name of the user registered for ZPE Cloud.

    last name

    Last name of the user registered for ZPE Cloud.

    type

    User type logged into the ZPE Cloud. Includes types such as CA, SA, and GA.

    first-access

    Determines if a user is logged into the ZPE Cloud for the first time.

    creation-type

    Determine if a user is a local user or a remote user.

    company

    Name of the company to which the user is registered.

    companies_count

    Number of companies to which the user is registered in ZPE Cloud.

    setup-pwd

    Password to log into the ZPE Cloud.

    session timeout

    Inactivity session timeout.

    access_level

    Defines if users have access level:
    0- Super Admin

    1- User

    2- Operator

    3- Administrator

    Examples

    This section shows the process of interacting with the ZPE Cloud company's API using cURL for basic operations such as:

    1. Logging into the Cloud company using company credentials.

    2. Performing a series of API requests: a POST request to add a new group to the company, a GET request to verify the successful addition of the group, a PUT request to edit the newly created group, and a DELETE request to remove the group.

    3. Logging out from the ZPE Cloud company.

    NOTE:

    It is recommended to use Linux prompts, such as those in Ubuntu, to execute these commands. Using Windows can cause issues with extra characters, such as backslashes \ and line breaks, which you will need to remove for the commands to work correctly.

    These step-by-step instructions will ensure you understand how to manage groups within the ZPE Cloud company's environment using API calls.

    Logging in ZPE Cloud

    1. Open the command prompt.

    2. Execute the following command to log into the ZPE cloud:

      curl -i -X POST 'https://api.staging-zpecloud.com/user/auth' \
      --header 'Content-Type: application/json' \
      --data '{"email": "doc-user.01@zpesystems.com", "password": "-2g3#h&Y}v=4[h|G}lkjhBkk}k[t8<PP&bgDxFVUj$)T*bG^.Qu"}'
      
      

    3. Copy the set-cookie parameter value. See the above screenshot. The cookie is used in the header in the following operations.

    Adding Group

    Execute the following command to add a group:

    curl -i -X POST 'https://api.staging-zpecloud.com/group' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;" \
    --data '{"name": "group_test", "access_level": "1"}'
    

    Getting List of Groups

    Execute the following command to get the list of groups:

    curl -i -X GET 'https://api.staging-zpecloud.com/group' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;"
    

    Editing Group

    Execute the following command to edit group using the group ID:

    curl -i -X PUT 'https://api.staging-zpecloud.com/group/64598' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;" \
    --data '{"name": "group_test_edited", "access_level": "3"}'

    Getting Current Group

    Execute the following command to get current group using the group ID:

    curl -i -X GET 'https://api.staging-zpecloud.com/group/64598' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;"

    Deleting Group

    Execute the following command to delete a group:

    curl -i -X DELETE 'https://api.staging-zpecloud.com/group/64598' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;"

    Getting List of Groups

    Execute the following command to get the list of groups (after the deletion):

    curl -i -X DELETE 'https://api.staging-zpecloud.com/group/64598' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;"

    Logging out from ZPE Cloud

    Execute the following command to log out from ZPE Cloud:

    curl -i -X POST 'https://api.staging-zpecloud.com/user/logout' \
    --header 'Content-Type: application/json' \
    --header "Cookie: session=uwfmzdngvgw2n5whta73japizga7u53w;"


    Was this article helpful?

    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence