How to Use the CleanTalk APIs to Work With the Website Settings
The API interface is available here: cleantalk.org/my/services_templates
Contents:
General Information
API services_templates_get
API services_templates_add
API services_templates_update
API services_templates_delete
API services_templates_set
General Information
Protocol - https
Hostname - api.cleantalk.org
API services_templates_get
Input Parameters
Transfer parameters methods GET or POST.
Necessary
method_name allowed values: services_templates_get
user_token or auth_key allowed values: user_token (you can get it in your profile settings in your CleanTalk Control Panel), auth_key (you can use it from any of your active licenses of the Anti-Spam Service or Security Service).
Example:
https://api.cleantalk.org/?method_name=services_templates_get&user_token=USER_TOKEN
Optional
search[field] uses field for searching, available values of field:
- template_id - integer, template ID
- product_id - integer, product ID, allowed values: 1 - Anti-Spam, 4 - Website Security
- name - string, template name, full or partial matching
- created - string, creation date, exact matching. Format: Y-m-d H:i:s
- created[gte] - string, creation date of the beginning of the time period. Format: Y-m-d
- created[lte] - string, creation date of the end of the time period. Format: Y-m-d
- updated - string, update date, exact matching. Format: Y-m-d H:i:s
- updated[gte] - string, update date of the beginning of the time period. Format: Y-m-d
- updated[lte] - string, update date of the end of the time period. Format: Y-m-d
- service_id_last_used - integer, the latest service ID that was used to apply the template on
- set_as_default - integer, is it a default template? Allowed values: 0 - no, 1 - yes.
- options_cloud - integer, does your Control Panel keep these settings? Allowed values: 0 - no, 1 - yes.
- options_site - integer, does your website keep these settings? Allowed values: 0 - no, 1 - yes.
start position of the first record of the list, by default is 0
length how many records in the response, by default is 0 (no limits are set).
order[0][dir] sorting direction of the records in the list, allowed values: asc, desc
order[0][column] field index the sorting is based on
columns[0][data] field name of record sorting, allowed values: template_id, product_id, name, created, updated, service_id_last_used, set_as_default
draw arbitrary value, it will be sent in the response for asynchronous requests.
Example:
https://api.cleantalk.org/?method_name=services_templates_get&auth_key=AUTH_KEY&draw=1&search[created][gte]=2021-01-01
Output Parameters
recordsTotal total number of records
recordsFiltered total number of records after the filters were applied
draw arbitrary value, being taken from the input parameters
operation_status what the operation status is, allowed values: SUCCESS, FAILED
operation_message error message
data array of records:
- template_id record ID
- product_id product type
- name template name
- options_cloud setting from your Control Panel
- options_site setting from your website
- created when the record was created
- updated when the record was updated
- service_id_last_used the latest service ID that was used to apply the template on
- user_id client ID
- set_as_default is it a default template?
Example:
{"draw":1,"recordsTotal":3,"recordsFiltered":3,"data":[{"template_id":108,"product_id":1,"name":"for_antispam","options_cloud":"{"response_lang":"es","stop_list_enable":"0","move_to_spam_enable":"1","allow_links_enable":"1","send_log_to_email":"1","server_response":null,"server_response_combine":"0","logging_restriction":"1"}","options_site":"","created":"2021-02-26 17:27:13","updated":"2021-02-26 17:27:13","service_id_last_used":null,"user_id":577205,"set_as_default":1},{"template_id":110,"product_id":4,"name":"for_security","options_cloud":"{"notify_admin_login":"1","auto_whitelist_owner_ip":"1","ct_in_list_db":"1","2fa_enable":"0","backend_logs_enable":"1"}","options_site":"","created":"2021-02-26 17:42:41","updated":"2021-02-26 17:42:41","service_id_last_used":null,"user_id":577205,"set_as_default":1}],"operation_message":"","operation_status":"SUCCESS"}
Possible Errors
- Unknown access key.
- User token not found
- Service disabled, please go to Dashboard https://cleantalk.org/my. Wrong start
- Too big start
- Wrong length
- Wrong columns
- Wrong order
- Wrong columns or order
API services_templates_add
Input Parameters
Transfer parameters methods GET or POST.
Necessary
method_name allowed values: services_templates_add
auth_key allowed values: auth_key (you can use it from any of your active licenses of the Anti-Spam Service or Security Service. Your template will be created for the respective service).
name allowed values: a unique string with the length of no more than 127 symbols
Example:
https://api.cleantalk.org/?method_name=services_templates_add&auth_key=AUTH_KEY&name=test
Optional
options_cloud settings from your Control Panel, if this parameter wasn’t transferred then the settings will be taken from the service your auth_key belongs to
options_site settings from your website, if this parameter wasn’t transferred then the settings will be taken from the service your auth_key belongs to
set_as_default is it a default settings template?
Example:
https://api.cleantalk.org/?method_name=services_templates_add&auth_key=AUTH_KEY&name=test&set_as_default=1
Output Parameters
data array of records:
- template_id record ID
- product_id product type
- created when the record was created
- updated when the record was updated
- operation_status was the operation successful, allowed values: SUCCESS, FAILED
- operation_message error message
Example:
{"data":[{"template_id":7,"product_id":4,"created":"2021-03-25 09:05:35","updated":"2021-03-25 09:05:35","operation_status":"SUCCESS","operation_message":""}]}
Possible Errors
- Unknown access key.
- Service disabled, please go to Dashboard https://cleantalk.org/my. Wrong start
- Please fill in the name
- Data too long for name
- The name must be unique
- Please fill in the options_cloud or optoins_site
- Wrong options_cloud
- Wrong options_cloud in template.
- Wrong optoins_site
- Too many templates
API services_templates_update
Input Parameters
Transfer parameters methods GET or POST.
Necessary
method_name allowed values: services_templates_update
auth_key allowed values: auth_key (you can use it from any of your active licenses of the Anti-Spam Service or Security Service. Your template will be created for the respective service).
template_id allowed values: template ID for update
Optional
(at least one parameter must be transferred)
name allowed values: a unique string with the length of no more than 127 symbols
options_cloud settings from your Control Panel
options_site settings from your website
set_as_default is it a default settings template?
Example:
https://api.cleantalk.org/?method_name=services_templates_update&auth_key=AUTH_KEY&template_id=7&name=test7&set_as_default=1
Output Parameters
data array of records:
- template_id record ID
- operation_status was the operation successful, allowed values: SUCCESS, FAILED
- operation_message error message
Example:
{"data":[{"template_id":7,"operation_message":"","operation_code":"","operation_status":"SUCCESS"}]}
Possible Errors
- Unknown access key.
- Service disabled, please go to Dashboard https://cleantalk.org/my. Wrong start
- Wrong template_id
- Template not found
- Please fill in the name or options_cloud or options_site or set_as_default
- Wrong name
- Data too long for name
- The name must be unique
- Wrong options_cloud
- Wrong options_cloud in template.
- Wrong options_site
- This method does not support service by authkey
API services_templates_delete
Input Parameters
Transfer parameters methods GET or POST.
Necessary
method_name allowed values: services_templates_update
user_token or auth_key allowed values: user_token (you can get it in your profile settings in your CleanTalk Control Panel), auth_key (you can use it from any of your active licenses of the Anti-Spam Service or Security Service).
template_ids allowed values: array of template IDs or a string of template IDs separated by commas.
Example:
https://api.cleantalk.org/?method_name=services_templates_delete&user_token=USER_TOKEN&template_ids=1,2
https://api.cleantalk.org/?method_name=services_templates_delete&auth_key=AUTH_KEY&template_ids[]=1&template_ids[]=2
Output Parameters
data array of records:
- number_of_delete_templates ID of the deleted record
- operation_status was the operation successful, allowed values: SUCCESS, FAILED
- operation_message error message
Example:
{"data":[{"number_of_delete_templates":1,"operation_status":"SUCCESS","operation_message":"","operation_code":""},{"number_of_delete_templates":2,"operation_status":"FAILED","operation_message":"Template not found","operation_code":21}]}
Possible Errors
- Unknown access key.
- User token not found
- Service disabled, please go to Dashboard https://cleantalk.org/my. Wrong start
- Wrong template_ids
- Wrong template_ids. Array of integer
API services_templates_set
Input Parameters
Transfer parameters methods GET or POST.
Necessary
method_name allowed values: services_templates_set
user_token or auth_key allowed values: user_token (you can get it in your profile settings in your CleanTalk Control Panel), auth_key (you can use it from any of your active licenses of the Anti-Spam Service or Security Service).
services_ids allowed values: array of service IDs or a string of service IDs separated by commas.
template_id allowed values: template ID.
mode settings type, allowed values:
- CLOUD - apply settings to your Control Panel only
- SITE - apply settings to your website only
- BOTH - apply settings to both
Example:
https://api.cleantalk.org/?method_name=services_templates_set&auth_key=AUTH_KEY&services_ids=840411,843291&template_id=3&mode=cloud
https://api.cleantalk.org/?method_name=services_templates_set&user_token=USER_TOKEN&services_ids[]=840411&template_id=10&mode=cloud
Output Parameters
data array of records:
- number_of_set_services ID of the modified service
- operation_status was the operation successful, allowed values: SUCCESS, FAILED
- operation_message error message
Example:
{"data":[{"number_of_set_services":840411,"operation_status":"FAILED","operation_message":"Wrong product_id","operation_code":21},{"number_of_set_services":843291,"operation_status":"SUCCESS","operation_message":"","operation_code":""}]}
Possible Errors
Unknown access key.
User token not found
Service disabled, please go to Dashboard https://cleantalk.org/my. Wrong start
Wrong services_ids
Wrong services_ids. Array of integer
Wrong template_id
Wrong mode
Empty options_cloud
Wrong options_cloud in template.
Empty options_site