Skip to content

Update Site Settings (Partial Add/Update/Delete)

Overview

The API allows you to add, update and remove styles, scripts, HTML, server scripts, processes and control by status.

Preparations

Please create an "API Key" for the user operating the API.

Request

Send JSON data in the following request format:

Setting column Value
HTTP Method POST
Content-Type application/json
Character Code UTF-8
URL http://{server name}/api/items/{site ID}/updatesitesettings (*1)
Body Refer to Parameters and JSON below.

(*1) Please edit the {server name} and {site ID} parts to suit your environment as appropriate.

Parameters

The parameters to specify in the request are as follows:

Parameter Data Type Description
ApiVersion Numeric value Specify the API version.
ApiKey String Specify the API key.
Styles Object array Specify the style object. Refer to the Styles Parameters below for more information.
Scripts Object array Specify the script object. Refer to the Scripts Parameters below for more information.
Htmls Object array Specify the HTML object. Refer to the Htmls Parameters below for more information.
ServerScripts Object array Specify the server script object. Refer to the ServerScripts Parameters below for more information.
Processes Object array Specify the process object. Refer to the Processes Parameters below for more information.
StatusControls Object array Specify the control by status object. Refer to the StatusControls Parameters below for more information.

Styles Parameters

The list of Styles parameters is as follows.

(Click here to open/close the details)
Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added, if the ID exists, it will be updated.
Title String Yes Sample style Specify the title.
Disabled Boolean value - false Specify disabled.
Body String - header#Header Specify the style.
StyleAll Boolean value - true Specify to enable/disable all output destination.
StyleNew Boolean value - false Specify to enable/disable create new output destination.
StyleEdit Boolean value - false Specify to enable/disable edit output destination.
StyleIndex Boolean - false Specify to enable/disable the output destination List.
StyleCalendar Boolean - false Specify to enable/disable the output destination Calendar.
StyleCrosstab Boolean - false Specify to enable/disable the output destination Crosstab.
StyleGantt Boolean - false Specify to enable/disable the output destination Gantt Chart.
StyleBurnDown Boolean - false Specify to enable/disable the output destination Burndown Chart.
StyleTimeSeries Boolean - false Specify to enable/disable the output destination Time Series Chart.
StyleKamban Boolean - false Specify to enable/disable the output destination Kanban.
StyleImageLib Boolean value - false Specify to enable/disable the output destination Image Library.
Delete Numeric value - 0 Specify 0 or 1 as the value of this parameter. If 1 is set, the style specified by Id will be deleted.

Scripts Parameters

The list of Scripts parameters is as follows.

(Click here to open/close the details)
Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added, if the ID exists, it will be updated.
Title String Yes Sample script Specify the title.
Disabled Boolean value - false Specify disabled.
Body String - console.log('sample script'); Specify the script.
ScriptAll Boolean value - true Specify to enable/disable all output destination.
ScriptNew Boolean value - false Specify to enable/disable create new output destination.
ScriptEdit Boolean value - false Specify to enable/disable edit output destination.
ScriptIndex Boolean - false Specify to enable/disable the output destination List.
ScriptCalendar Boolean - false Specify to enable/disable the output destination Calendar.
ScriptCrosstab Boolean - false Specify to enable/disable the output destination Crosstab.
ScriptGantt Boolean - false Specify to enable/disable the output destination Gantt Chart.
ScriptBurnDown Boolean - false Specify to enable/disable the output destination Burndown Chart.
ScriptTimeSeries Boolean - false Specify to enable/disable the output destination Time Series Chart.
ScriptKamban Boolean - false Specify to enable/disable the output destination Kanban.
ScriptImageLib Boolean value - false Specify to enable/disable the output destination Image Library.
Delete Numeric value - 0 Specify 0 or 1 as the value of this parameter. If 1 is set, the script specified by Id will be deleted.

Htmls Parameters

The list of Htmls parameters is as follows.

(Click here to open/close the details)
Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added, and if the ID exists, it will be updated.
Title String Yes Sample HTML Specify the title.
HtmlPositionType String Yes Headtop Specify the HTML insertion position. Specify one of HeadTop / HeadBottom / BodyScriptTop / BodyScriptBottom as the value of this parameter.
Disabled Boolean - false Specify disabled.
Body String - \
sample html\
Specify HTML.
HtmlAll Boolean - true Specify to enable/disable all output destination.
HtmlNew Boolean value - false Specify to enable/disable create new output destination.
HtmlEdit Boolean value - false Specify to enable/disable edit output destination.
HtmlIndex Boolean value - false Specify to enable/disable the output destination List.
HtmlCalendar Boolean value - false Specify to enable/disable the output destination Calendar.
HtmlCrosstab Boolean value - false Specify to enable/disable the output destination Crosstab.
HtmlGantt Boolean value - false Specify to enable/disable the output destination Gantt Chart.
HtmlBurnDown Boolean value - false Specify to enable/disable the output destination Burndown Chart.
HtmlTimeSeries Boolean - false Specify to enable/disable the output destination Time Series Chart.
HtmlKamban Boolean - false Specify to enable/disable the output destination Kanban.
HtmlImageLib Boolean - false Specify to enable/disable the output destination Image Library.
Delete Numeric value - 0 Specify 0 or 1 for the value of this parameter. If 1 is set, the HTML specified by Id will be deleted.

ServerScripts Parameters

The list of ServerScripts parameters is as follows.

(Click here to open/close the details)
Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added, and if the ID exists, it will be updated.
Title String Yes Sample Server Script Specify the title.
Name String Yes SampleServerScript Specify the name.
Body String - context.Log('sample server script'); Specify the server script.
ServerScriptWhenloadingSiteSettings Boolean - true Specify to enable/disable the condition "When loading site settings".
ServerScriptWhenViewProcessing Boolean - false Specify to enable/disable the condition "When view processing".
ServerScriptWhenloadingRecord Boolean - false Specify to enable/disable the condition "When loading record".
ServerScriptBeforeFormula Boolean value - false Specify to enable/disable the condition "Before formulas".
ServerScriptAfterFormula Boolean value - false Specify to enable/disable the condition "After formulas".
ServerScriptBeforeCreate Boolean value - false Specify to enable/disable the condition "Before create".
ServerScriptAfterCreate Boolean value - false Specify to enable/disable the condition "After create".
ServerScriptBeforeUpdate Boolean value - false Specify to enable/disable the condition "Before update".
ServerScriptAfterUpdate Boolean value - false Specify to enable/disable the condition "After update".
ServerScriptBeforeDelete Boolean value - false Specify to enable/disable the condition "Before delete".
ServerScriptAfterDelete Boolean value - false Specify to enable/disable the condition "After delete".
ServerScriptBeforeOpeningPage Boolean value - false Specify to enable/disable the condition "Before opening the page".
ServerScriptBeforeOpeningRow Boolean value - false Specify to enable/disable the condition "Before opening the row".
ServerScriptShared Boolean value - false Specify to enable/disable the condition "Shared".
Delete Numeric value - 0 Specify the value of this parameter as 0 or 1. If 1 is set, the server script specified by Id will be deleted.

Processes Parameters

The list of Processes parameters is as follows.

(Click here to open/close the details)
Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be processed as an addition; if the ID exists, it will be processed as an update.
Name String Yes A1_Application(Common) Specify the name.
DisplayName String - A1_Application(Common) Specify the name displayed.
ScreenType Numeric value - 10 Specify the screen type. For new creation, specify 10; for editing, specify 20.
CurrentStatus Numeric value - 100 Specify the status code to select under the current situation. If "*", specify -1.
ChangedStatus Numeric value - 200 Specify the status code to select after the change. If "*", specify -1.
Description String - Submit an application and request approval from the Section Manager Specify the description.
Tooltip String - Submit an application and request approval Specify the tooltip.
ConfirmationMessage String - Are you sure you want to submit with the entered content? Specify the confirmation message.
SuccessMessage String - Submitted application Specify the success message.
OnClick String - console.log('Process has been executed.'); Specify the script to be executed when the button added by the process function is clicked.
ExecutionType Numeric value - 10 Specify the execution type. The specification is as follows:
0: Added button
10: New or update
ActionType Numeric value - 10 Specify the action type. The specification is as follows:
0: Save
10: Postback
90: None
AllowBulkProcessing Boolean - true Specify true if bulk processing is allowed.
ValidationType Numeric value - 0 Specify the input validation type. The specification is as follows:
0: Merge
10: Replace
90: None
ValidateInputs Object array - - Specify the object for input validation of the process. For details, see the ValidateInputs parameters below.
View Object - - Specify the condition object for the process. For details, refer to the View Parameters below.
DataChanges Object array - - Specify the data change objects for the process. For details, refer to the DataChanges Parameters below.
AutoNumbering Object - - Specify the object for auto-numbering of the process. For details, see the AutoNumbering Parameters below.
Notifications Object array - - Specify the notification objects for the process. For details, refer to the Notifications parameters below.
Depts Array - [1,2] Specify the departments to grant access control permissions for the process. Specify the department IDs.
Groups Array - [3,4,5] Specify the groups to grant access control permissions for the process. Specify the group IDs.
Users Array - [11,12,13,14] Specify the users to grant access control permissions for the process. Specify the user IDs.
Delete Numeric value - 0 Specify 0 or 1 for the value of this parameter. If 1 is set, the process specified by Id will be deleted.

ValidateInputs Parameters

Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added; if it exists, it will be updated.
ColumnName String Yes Title Specify the column by "Column Name", not name displayed.
Required Boolean - true Specify true if the input is required.
ClientRegexValidation String - ^0[789]0\d{8}$ Specify the client-side regular expression. Effective when specifying classification or description column by ColumnName.
ServerRegexValidation String - ^0[789]0\d{8}$ Specify the server-side regular expression. Effective when specifying classification or description column by ColumnName.
RegexValidationMessage String - There is an error in the mobile phone number. Specify the error message to be displayed when a regular expression error occurs.
Max Numeric value - 99999 Specify the maximum allowable input value. Effective when specifying numeric value column by ColumnName.
Min Numeric value - 0 Specify the minimum allowable input value. Effective when specifying numeric value column by ColumnName.
Delete Numeric value - 0 Specify 0 or 1 for the value of this parameter. If 1 is set, the process specified in Id will be deleted.

View Parameters

Parameter Data type Required e.g. Description
Incomplete Boolean - true Specify true if checking for incomplete status.
Own Boolean - true Specify true if checking for own records.
ColumnFilterHash String - Specify the conditions. For details, refer to "View" and "ColumnFilterHash".
Search String - -Implem Specify the search keyword.
ErrorMessage String - Conditions not met. Specify the error message.

DataChanges Parameters

Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added; if it exists, it will be updated.
Type String - InputValue Specify the type of change. The specifications are as follows:
CopyValue: Copy name displayed
CopyDisplayValue: Copy display value
InputValue: Input value
InputDate: Input date
InputDateTime: Input date and time
InputDept: Input department
InputUser: Input user
ColumnName String - ClassA Specify the column by column name, not name displayed.
Value String - ClassB
123
7,Days
Specify the source or value. For source, specify the column by column name. For value, specify any string to be input. If the change type is "Input date" or "Input datetime", specify 'value, period'. The period can be specified as follows:
Days: Days
Months: Months
Years: Years
Hours: Hours
Minutes: Minutes
Seconds: Seconds
BaseDateTime String - CurrentDate Specify the reference date and time if the change type is "Input date" or "Input datetime". Besides specifying by "column Name", the following can be specified:
CurrentDate: Current date
CurrentTime: Current time

AutoNumbering parameters

Refer to "Manage Table: Editor: Column Advanced Settings: Automatic Numbering" for more details.

Parameter Data type Required e.g. Description
ColumnName String - ClassA Specify the column by "Column Name", not name displayed.
Format String - [yyyyMMdd]-[ClassA]-[NNNN] Specify the format.
ResetType String - Year Specify the reset type. The specifications are as follows:
Year: Year
Month: Month
Day: Day
String: String
Default Numeric value - 1 Specify the default value.
Step Numeric value - 1 Specify the step.

Notifications Parameters

Refer to "Manage Table: Notification" for more details.

Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added; if it exists, it will be updated.
Type Numeric value Yes 1 Specify the notification type. The specifications are as follows:
1: Email
2: Slack
3: ChatWork
4: Line
5: Line Group
6: Teams
7: Rocket.Chat
8: InCircle
Subject String Yes Applied Specify the subject. You can use the column value by writing "[Name Displayed]".
Address String Yes test@example.com Specify any email address, WebHook, roomID URL, or LINE UserID or GroupID.
Token Character string - xxx... Specify the token obtained from chatwork, the access token of the LINE bot account, or the InCircle token.
Body Character string Yes Application content: [Content] Specify the content. You can use the column value by writing "[Name Displayed]".

StatusControls Parameters

The list of StatusControls parameters is as follows.

(Click here to open/close the details)
Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added; if it exists, it will be updated.
Name String Yes 01_Waiting for application (common) Specify the name.
Description String - Approval column should be hidden when submitting Specify the description.
Status Numeric value - 100 Specify the status code. If "*", specify -1.
ReadOnly Boolean - true Specify true if checking for read-only record control.
ColumnHash Object - { "Status": "ReadOnly", "Owner": "Hidden", "ClassA": "Requied" } Specify in the format of "Column name": "Settings". Specify the column in "Column name". The "ColumnName" specifies the column. The settings are as follows:
Required: Required input
ReadOnly: Read-only
Hidden: Hidden
View Object - - Specify the condition object for control by status. For details, refer to the View Parameters below.
Depts Array - [1,2] Specify the departments to grant access control permissions for the process. Specify the department IDs.
Groups Array - [3,4,5] Specify the groups to grant access control permissions for the process. Specify the group IDs.
Users Array - [11,12,13,14] Specify the users to grant access control permissions for the process. Specify the user IDs.
Delete Numeric value - 0 Specify 0 or 1 for the value of this parameter. If 1 is set, the process specified by Id will be deleted.

View Parameters

Parameter Data type Required e.g. Description
Id Numeric value Yes 3 Specify the ID. If the ID does not exist, it will be added; if it exists, it will be updated.
Incomplete Boolean value Yes true Specify true if checking for incomplete status.
Own Boolean value - true Specify true if checking for own records.
ColumnFilterHash String - - Specify the conditions. For details, refer to "View" and "ColumnFilterHash".
Search String - Specify the search keyword.

JSON

A sample of the request (JSON) to send is as follows. The setting changes will apply to the specified parameters.
*For the script with Id:1 in Scripts, only Title, Body, and ScriptAll will be subject to setting changes. The values ​​of parameters that are not specified, such as Disabled, will not be changed.

{
    "ApiVersion": 1.1,
    "ApiKey": "xxxxx...",
    "Scripts": [
        {
            "Id": 1,
            "Title": "sample script 1",
            "Body": "console.log('script 1');",
            "ScriptAll": true
        },
        {
            "Id": 2,
            "Title": "sample script 2",
            "Body": "console.log('script 2');",
            "ScriptAll": true
        }
    ],
    "ServerScripts": [
        {
            "Id": 9,
            "Title": "sample serverscript 9",
            "Name": "SampleServerScript9",
            "Body": "context.Log('sample serverscript 9');",
            "ServerScriptWhenloadingSiteSettings": true
        },
        {
            "Id": 10,
            "Title": "test10",
            "Delete": 1
        }
    ],
    "Styles": [
        {
            "Id": 2,
            "Title": "test2",
            "StyleNew": false
        }
    ],
    "Htmls": [
        {
            "Id": 3,
            "Title": "sample html 3",
            "HtmlPositionType": "HeadTop",
            "Body": "<div>sample html 3</div>"
        }
    ],
    "Processes": [
        {
            "Id": 1,
            "Name": "A1_Application (common)",
            "DisplayName": "Apply",
            "CurrentStatus": 100,
            "ChangedStatus": 200,
            "Description": "Submit an application and request approval from the section manager",
            "Tooltip": "Submit an application and request approval",
            "ConfirmationMessage": "Are you sure you want to submit with the entered content?",
            "SuccessMessage": "Applied",
            "ValidateInputs": [
                {
                    "Id": 1,
                    "ColumnName": "NumA",
                    "Required": true,
                    "Min": 1.0,
                    "Max": 5000000.0
                },
                {
                    "Id": 4,
                    "Delete": 1
                }
            ],
            "View": {
                "Own": true
            },
            "DataChanges": [
                {
                    "Id": 1,
                    "Type": "InputDateTime",
                    "ColumnName": "DateA",
                    "BaseDateTime": "CurrentTime",
                    "Value": "0,Days"
                },
                {
                    "Id": 5,
                    "Delete": 1
                }
            ]
        },
        {
            "Id": 17,
            "Name": "E4_Return by accounting",
            "Delete": 1
        }
    ],
    "StatusControls": [
        {
            "Id": 1,
            "Name": "01_Application pending (common)",
            "Description": "Approval column should be hidden when creating a document",
            "Status": 100,
            "ColumnHash": {
                "Status": "ReadOnly",
                "Owner": "Hidden",
                "ClassA": "Hidden",
                "DateA": "Required",
               "DescriptionB": "ReadOnly",
            }
        },
        {
            "Id": 11,
            "Name": "06-4_Complete γ",
            "Delete": 1
        }
    ]    
}

Response

The JSON data will be returned in the following format:

When site settings could be updated (partial add/update/delete)

{
    "Id": 6714,
    "StatusCode": 200,
    "Message": The "\"Recorded Table\" has been updated."
}

When an API key of a user without site management permissions was used

{
    "Id": 123,
    "StatusCode": 403,
    "Message": "You do not have permission to perform this action。"
}

If required parameters were not present

{
    "Id": 123,
    "StatusCode": 404,
    "Message": "The specified information was not found."
}

Code Samples

Modify 【 ... 】 in the code as necessary.
1. Register a JavaScript file to all specified sites

Reads a JavaScript file stored in a folder of your choice and adds the code to the server script of each site specified in the code.

Python(api_site_update_sitesettings.py)
# Library for using OS-related functions
import os

# Library for handling JSON
import json

# Library for path operations
from pathlib import Path

# Library for type hints
from typing import List, Optional

# Library for sending HTTP requests
import requests

# =========
# Settings
# =========
BASE_URL = "【URL】"
API_KEY = "【API key】"

# IDs of the sites to update (multiple)
SITE_IDS: List[int] = [【Site ID】, 【Site ID】]

# Specify the server script information
SERVER_SCRIPT_NAME = "【Server script name】"  # e.g., any server script name
SERVER_SCRIPT_ID = 【Server script ID】
# Specify the server script conditions as an array
# See below for the conditions
SERVER_SCRIPT_CONDITIONS = [
    {
        "Type": "【Server script condition】",
        "Enabled": True,
    },
    {
        "Type": "【Server script condition】",
        "Enabled": True,
    },
]

# Local JS file (the content to put in Body)
JS_FILE_PATH = r"【Path name】\【JavaScript file name】"

# Timeout, etc.
TIMEOUT_SEC = 30

def read_js_file(path: str) -> str:
    p = Path(path)
    if not p.exists():
        raise FileNotFoundError(f"JS file not found: {p}")
    # Read as text so that Pleasanter handles it as is, including line breaks
    return p.read_text(encoding="utf-8")

def build_payload(
    body_js: str, script_name: str, script_id: Optional[int] = None
) -> dict:
    # ServerScripts element (minimum)
    script_obj = {
        "Name": script_name,
        "Title": script_name,
        "Body": body_js,
    }
    if script_id is not None:
        script_obj["Id"] = script_id

    for SERVER_SCRIPT_CONDITION in SERVER_SCRIPT_CONDITIONS:
        script_obj[SERVER_SCRIPT_CONDITION["Type"]] = SERVER_SCRIPT_CONDITION["Enabled"]

    # Pattern A: an array directly
    payload = {
        "ApiVersion": 1,
        "ApiKey": API_KEY,
        "ServerScripts": [script_obj],
    }
    return payload

def update_site_settings(site_id: int, payload: dict) -> requests.Response:
    url = f"{BASE_URL.rstrip('/')}/api/items/{site_id}/updatesitesettings"
    headers = {
        "Content-Type": "application/json",
    }
    return requests.post(
        url, headers=headers, data=json.dumps(payload), timeout=TIMEOUT_SEC
    )

def main():
    body_js = read_js_file(JS_FILE_PATH)
    print(f"body_js={body_js}")

    # e.g., update the same ServerScript name on all sites
    for site_id in SITE_IDS:
        payload = build_payload(
            body_js=body_js, script_name=SERVER_SCRIPT_NAME, script_id=SERVER_SCRIPT_ID
        )

        try:
            resp = update_site_settings(site_id, payload)
        except requests.RequestException as e:
            print(f"[ERROR] site_id={site_id} request failed: {e}")
            continue

        if resp.ok:
            print(f"[OK] site_id={site_id} updated. status={resp.status_code}")
        else:
            # On failure, output the response body so that the cause can be traced
            print(f"[NG] site_id={site_id} status={resp.status_code}")
            print(resp.text)

if __name__ == "__main__":
    main()
Condition Settings
Condition Setting value
When loading site settings ServerScriptWhenloadingSiteSettings
When view processing ServerScriptWhenViewProcessing
When loading record ServerScriptWhenloadingRecord
Before formulas ServerScriptBeforeFormula
After formulas ServerScriptAfterFormula
Before create ServerScriptBeforeCreate
After create ServerScriptAfterCreate
Before update ServerScriptBeforeUpdate
After update ServerScriptAfterUpdate
Before delete ServerScriptBeforeDelete
After delete ServerScriptAfterDelete
Before bulk delete ServerScriptBeforeBulkDelete
After bulk delete ServerScriptAfterBulkDelete
Before opening the page ServerScriptBeforeOpeningPage
Before opening the row ServerScriptBeforeOpeningRow
Shared ServerScriptShared

Setting example

SERVER_SCRIPT_CONDITIONS = [
    {
        "Type": "ServerScriptBeforeOpeningPage",
        "Enabled": True,
    },
    {
        "Type": "ServerScriptBeforeOpeningRow",
        "Enabled": True,
    },
]

Run
>python api_site_update_sitesettings.py
Execution Result
body_js=【The content of the body to be inserted is displayed here】

[OK] site_id=9001 updated. status=200
[OK] site_id=9002 updated. status=200

Supported Versions

Supported versions Body
1.4.11.0 and later Added Icon to the Processes parameters
1.4.16.0 and later Added ServerScriptBeforeBulkDelete and ServerScriptAfterBulkDelete to the ServerScripts parameters