If you want to change Global Colors programatically, the following API calls will be required to do this. Using a PATCH on the /website/design endpoint will overwrite any Global Colors you send so you should always send a full list of Global Colors.



Things you will need
1. Domain name. When using the site API, any requests must be sent to http://{subdomain}.{tool-domain}/api.php/endpoint. e.g. http://demoapi.editortool.companyabc.com/api.php/login

2. The colors you wish to use in hexadecimal format (e.g. #FF0000)

Login
Before we can use the site API, we’ll need to log into the individual site. This can be done via either of the following API calls:

 

1. Site API (requires username and password)

POST http://demoapi.editortool.companyabc.com/api.php/login

{
     "username": "apidemo",
     "password": "apidemo123"
}

 

Response:

{
    "sessionId": "{session ID}",
    "message": "Set as cookie value for site_session",
    "sessionName: "site_session"
} 

 

2. HAL API (requires a token)

POST https://hal.mono.net/api/v1/reseller/account/site

{
    "userToken": "{your-token}",
    "command": "apiLogin",
    "siteId": {your site ID}
} 

 

Response:

{
    "status": {
       "code": 200,
       "text": "",
       "timeStamp": "2017-08-21T12:21:31+00:00"
   },
   "data": [
       {
           "sessionName": "site_session",
           "sessionId": "{session ID}"
       }
   ]
} 

Both calls will yield a session ID in the format 35 character alphanumeric. In any future calls we make, we must include the header 'Cookie=site_session={session ID}'

 

Get list of current Global Colors in use

GET http://demoapi.editortool.companyabc.com/api.php/globals 

 

Response:

[
   {
      "design": {
          "css": {
          "css-md": {},
          "css-sm": {},
          "colors": {
              "color_1": "rgb(255, 64, 0)",
              "color_2": "rgb(0, 96, 255)",
              "color_3": "rgb(64, 255, 0)",
              "color_7": "rgb(0, 0, 0)"
          }
      }
  }
] 

 

Overwrite a color

PATCH http://demoapi.editortool.companyabc.com/api.php/globals 
{

    "colors": {
       "color_1": "rgb(254, 64, 0)",
       "color_2": "rgb(0, 96, 255)",
       "color_3": "rgb(64, 255, 0)",
       "color_7": "rgb(200, 0, 0)"
       }
}

 

Response:

[]
Was this article helpful?
1 out of 2 found this helpful