Sites

Create a New Site

POST /_config/sites/

Description Create a new site with the specified site information.

HTTP Method POST

Endpoint: /_config/sites/

Request Header Authorization Basic <token>

Request Parameters

Body Parameters

  • site_name (string, required): The name of the site.

  • location (string, required): The location of the site.

  • edge_firmware (object, required): Information about the edge firmware, including the current_version and previous_version.

  • timezone (string, required): The timezone of the site.

  • latitude (string, required): Latitude of the site.

  • longitude (string, required): Longitude of the site.

  • retention_period (long, optional): Time period of data retention of the site(collected in months,by default it is 6 months).The value by default is 180 days or 6 months.

Note

  • Parameter “retention_period” although collected from user in number of months, is sent as number of days through the Request.

Sample Request

curl --location 'https://app.4pointx.com/_config/sites/' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Basic <token>' \
     -data '{
        "site_name": "sample_site_0",
        "location": "bangalore",
        "latitude": "",
        "longitude": "",
        "timezone": "UTC",
        "retention_period": 180,
        "edge_firmware": {
            "current_version": "1.0.9",
            "previous_version": ""
        }
      }'

Sample Response

Success

{
  "id": "5e175ff8-6d1b-4092-ace1-e6eeb8535065"
}

Error

{
  "error": {
    "status": 401,
    "message": "Unauthorized access to module by general-user"
  }
}
{
  "error": {
    "status": 400,
    "message": "Invalid Content Type"
  }
}
{
  "error": {
    "status": 400,
    "message": "Insufficient Inputs"
  }
}
{
  "error": {
    "status": 400,
    "message": "sample_site_0 already exists"
  }
}
{
  "error": {
    "status": 400,
    "message": "Error occured during site creation"
  }
}

Delete Site

DELETE /_config/sites/<site_id>

Description Delete a specific site by its ID.

HTTP Method DELETE

Endpoint /_config/sites/<site_id>

Request Header Authorization Basic <token>

Request Parameters

URL Parameters

  • site_id (string, required) The ID of the site to delete.

Sample Request

curl --location --request DELETE 'https://app.4pointx.com/_config/sites/5e175ff8-6d1b-4092-ace1-e6eeb8535065' \
     --header 'Authorization: Basic <token>' \
     --data ''

Sample Response

Success

"Site deleted"

Error

{
  "error": {
    "status": 401,
    "message": "Unauthorized access to module by general-user"
  }
}
{
  "error": {
    "status": 400,
    "message": "Invalid site 12380-32974-8291-29273"
  }
}
{
  "error": {
    "status": 400,
    "message": "Plants exists on this site"
  }
}

Update Site

PUT /_config/sites/<site_id>

Description Update the information of a specific site by its ID.

HTTP Method PUT

Endpoint /_config/sites/<site_id>

Request Header Authorization Basic <token>

Request Parameters

Body Parameters

  • location (string, required): The updated location of the site.

  • timezone (string, optional): The updated timezone of the site.

  • edge_firmware (object, optional): Updated information about the edge firmware, including the current_version and previous_version.

  • latitude (string, optional): Latitude of the site.

  • longitude (string, optional): Longitude of the site.

  • retention_period (long, required): The updated time period of data retention of the site(collected in months,by default it is 6 months).

URL Parameters

  • site_id (string, required) The ID of the site to update.

Sample Request

curl --location --request PUT 'https://app.4pointx.com/_config/sites/5e175ff8-6d1b-4092-ace1-e6eeb8535065' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic <token>' \
    --data '{
        "site_name": "sample_site_0",
        "location": "Karnataka",
        "latitude": "45",
        "longitude": "90",
        "timezone": "US/Samoa",
        "retention_period" : 180,
        "edge_firmware": {
            "current_version": "1.0.9",
            "previous_version": ""
            }
        }'

Sample Response

Success

"Site Updated"

Error

{
  "error": {
    "status": 401,
    "message": "Unauthorized access to module by general-user"
  }
}
{
  "error": {
    "status": 400,
    "message": "Invalid Content Type"
  }
}
{
  "error": {
    "status": 400,
    "message":  "Insufficient Inputs"
  }
}
{
  "error": {
    "status": 400,
    "message":  "Invalid site"
  }
}

Fetch Site

GET /_config/sites/<site_id>

Description Retrieve details of a specific site by its ID.

HTTP Method GET

Endpoint /_config/sites/<site_id>

Request Header Authorization Basic <token>

Request Parameters

URL Parameters

  • site_id (string, required): The ID of the site for which you want to retrieve details.

Sample Request

curl --location 'https://app.4pointx.com/_config/sites/5e175ff8-6d1b-4092-ace1-e6eeb8535065' \
     --header 'Authorization: Basic <token>'

Sample Response

Success

[
  {
      "site_name": "sample_site_0",
      "location": "Karnataka",
      "latitude": "45",
      "longitude": "90",
      "edge_firmware": {
          "current_version": "1.0.8",
          "previous_version": ""
      },
      "timezone": "US/Samoa",
      "retention_period": 180,
      "site_id": "5e175ff8-6d1b-4092-ace1-e6eeb8535065"
  }
]

Error

{
  "error": {
    "status": 401,
    "message": "Unauthorized access to module by general-user"
  }
}
{
  "error": {
    "status": 400,
    "message":  "Invalid Site 5476481-48e5-b2a0-ae810a948839"
  }
}
{
  "error": {
    "status": 405,
    "message":  "Method Not Allowed"
  }
}

Fetch List of Sites

GET /_config/sites/_list

Description Retrieve a list of all available sites.

HTTP Method GET

Endpoint /_config/sites/_list

Request Header Authorization Basic <token>

Request Parameters

None

Sample Request

curl --location 'https://app.4pointx.com/_config/sites/_list' \
     --header 'Authorization: Basic <token>'

Sample Response

Success

[
  {
    "site_name": "firmware test",
    "location": "test",
    "latitude": "1",
    "longitude": "-1",
    "edge_firmware": {
        "previous_version": "1.0.8",
        "current_version": "1.0.13",
        "latest_version": "1.0.13"
    },
    "retention_period": 180,
    "timezone": "Asia/Kolkata",
    "site_id": "d83f2d95-f099-41ce-958b-e9472a3e556a"
  },
  {
    "site_name": "4PX Test",
    "location": "4PX Lab Bengaluru",
    "latitude": "0",
    "longitude": "0",
    "site_id": "4230adcb-f349-4780-bf79-4a8c94a3b13b",
    "edge_firmware": {
        "previous_version": "1.0.9",
        "current_version": "1.0.12",
        "latest_version": "1.0.13"
    },
    "retention_period": 180,
    "timezone": "Asia/Kolkata"
  },
]

Error

{
  "error": {
    "status": 401,
    "message": "Unauthorized access to module by general-user"
  }
}