Professional Documents
Culture Documents
TOFFS API USER MANUAL v1.0
TOFFS API USER MANUAL v1.0
DOCUMENT HISTORY
Version Revision Details
Author Zhang Jun
Designation Senior Development Lead
Revision Date June 20, 2019
Summary of
Revisi
o
1.0 n
Reviewer
Designation
Review Date
Version Status
Approver
Designation
Approval Date
Table of Contents
OVERVIEW ................................................................................................................................................7
Introduction................................................................................................................................................................................................ 7
Purpose Getting Started .............................................................................................................................................................................7
1.4.1 Endpoints .................................................................................................................................................................................... 8
1.4.2 Requests ..................................................................................................................................................................................... 8
1.4.3 Required parameters ..................................................................................................................................................................8
1.4.4 Responses (Example) ..................................................................................................................................................................8
1.4.5 Error Code................................................................................................................................................................................... 9
1.4.6 Error Response (Example)........................................................................................................................................................... 9
1.4.7 HTTP Content-Type : application/json ........................................................................................................................................9
DATA STRUCTURE................................................................................................................................... 10
2.1 PAD Object definitions .......................................................................................................................................................................10
PAD APIS................................................................................................................................................. 11
3.1 Create new PAD API ..................................................................................................................................................................11
3.2 Get Pad API ............................................................................................................................................................................... 12
3.3 Get PADs List.............................................................................................................................................................................13
3.4 Get Pad Detail Info API ............................................................................................................................................................. 15
3.5 Update PAD Detail ....................................................................................................................................................................16
3.6 Update PAD SSL API ..................................................................................................................................................................18
3.7 Get PAD Challenge Detail API ..................................................................................................................................................... 19
3.8 Update PAD Challenge Detail API ............................................................................................................................................... 20
3.9 Get Proxy Set Header Host ....................................................................................................................................................... 21
3.10 Update Proxy Set Header Host................................................................................................................................................... 21
3.11 Get Proxy Hide Header ............................................................................................................................................................. 22
3.12 Update Proxy Hide Header ....................................................................................................................................................... 22
3.13 Get Customize Header .............................................................................................................................................................. 23
3.14 Update Customize Header ........................................................................................................................................................ 23
3.15 Get Origin Request Uri .............................................................................................................................................................. 24
3.16 Update Origin Request Uri ......................................................................................................................................................... 24
3.17 Get Force to WWW...................................................................................................................................................................25
3.18 Update Force to WWW ............................................................................................................................................................. 26
3.19 Get Cache Details ......................................................................................................................................................................26
3.20 Update Cache Details ................................................................................................................................................................ 27
3.21 Get CORS Details .......................................................................................................................................................................28
3.22 Update CORS Details .................................................................................................................................................................28
3.23 Get GZip Details ........................................................................................................................................................................29
3.24 Update GZip Details ...................................................................................................................................................................30
3.25 Get IP Whitelist(Bypass) ........................................................................................................................................................... 30
3.26 Update IP Whitelist(Bypass)....................................................................................................................................................... 31
© 2019 Toffs Technologies Pte Ltd
Commercial-In-Confidential
Version 1.0
June 2019
3.27 Get Geo IPs ............................................................................................................................................................................... 32
3.28 Update Geo IPs..........................................................................................................................................................................32
3.29 Get Geo Country .......................................................................................................................................................................33
3.30 Update Geo Country..................................................................................................................................................................34
3.31 Get Max Number of Connections .............................................................................................................................................35
3.32 Update Max Number of Connections .......................................................................................................................................35
3.33 Get IP+Path Rate Limiting ......................................................................................................................................................... 36
3.34 Add IP+Path Rate Limiting ........................................................................................................................................................ 36
3.35 Remove IP+Path Rate Limiting .................................................................................................................................................. 37
3.36 Get Origin failover Details ......................................................................................................................................................... 38
3.37 Update Origin failover Details .................................................................................................................................................... 38
3.38 Get SSL TLS Protocol .................................................................................................................................................................39
3.39 Update SSL TLS Protocol ............................................................................................................................................................ 40
3.40 Get SSL Cipher List ....................................................................................................................................................................41
3.41 Update SSL Cipher List ............................................................................................................................................................... 41
3.42 Get Enable Free SSL ..................................................................................................................................................................42
3.43 Update Enable Free SSL ............................................................................................................................................................ 42
3.44 Get Enable Auto Generate SSL .................................................................................................................................................. 43
3.45 Update Enable Auto Generate SSL ...........................................................................................................................................44
3.46 Generate SSL TXT Record.......................................................................................................................................................... 44
3.47 Finalize SSL ................................................................................................................................................................................ 45
3.48 Generate San SSL Certificate .................................................................................................................................................... 46
3.49 SSL Certificate Effective Check .................................................................................................................................................. 46
3.50 Get Disallow Bot .......................................................................................................................................................................47
3.51 Update Disallow Bot .................................................................................................................................................................47
3.52 Get WebSocket .........................................................................................................................................................................48
3.53 Update WebSocket ...................................................................................................................................................................49
3.54 Get Block XFF ............................................................................................................................................................................49
3.55 Update Block XFF ......................................................................................................................................................................50
3.56 Get Secure Link Token .............................................................................................................................................................. 50
3.57 Get Secure Link URL ..................................................................................................................................................................51
3.58 Split PAD ................................................................................................................................................................................... 52
3.59 Get Waf & SecuritySettings ...................................................................................................................................................... 53
3.60 Update Waf & Security Settings ............................................................................................................................................... 54
3.61 PAD release, Stop, Delete ......................................................................................................................................................... 56
HOST(ALIAS) APIS.................................................................................................................................... 57
4.1 Get PAD Detail by Host(Alias) ................................................................................................................................................... 57
4.2 Insert Host(Alias) to PAD alias ................................................................................................................................................. 57
4.3 Delete Host(Alias) from PAD alias ...........................................................................................................................................58
OVERVIEW
Introduction
The Toffs API is a RESTful API based on HTTPS requests and JSON responses. If
you are registered with Toffs , you can obtain your API key from the bottom of the "My
Account" page.
Purpose
Getting Started
The Toffs API is a RESTful API based on HTTPS requests and JSON responses. If
you are registered with Toffs , you can obtain your API key from the bottom of the "My
Account" page:
2. Scroll down to the bottom of the page, look for "API Token". Click on "Copy" to
copy the token to your clipboard. To reset the API Token , click on "Reset".
3. Please be noted that upon resetting API Token, all previous token will lose effect
immediately.
API INSTRUCTIONS
1.4.1 Endpoints
https://api.toffstech.com/v1/
1.4.2 Requests
Requests must be sent over HTTPS with any payload formatted in JSON. All requests
must include both and headers to authenticate.
The response format can be determined from the HTTP Content-Type header. Most
API responses are JSON (Content-Type: application/json).
DATA STRUCTURE
2.1 PAD Object definitions
Name Type Default Null Constraints
ID Int No Read only
Pad_name String No Max length: 128
Pad_aliases Array Max length: 65,535
Account_id Int
Customer_brand String Max length:100
Upstream_server Array No Max row:100
Created_at String Read only
Ssl_enable Bool false
Ssl_certificate_crt String Max length:65,535
Ssl_certificate_key String Max length:65,535
Ssl_force_redirect Bool false
Status Int 0 read only
"options": { "0":
"Pending",
"1": "Release",
"2": "Published",
"3": "Actived",
"4": "Remove to
Trash","5":
"Stopping",
"6": "Stopped"
}
Upstream_method Int 0 0=Round-robin
1=ip_hash
2=fair
3=least conn
Hsts_includesubdomains Int 0 0=false
1=true
Hsts Int 0 0=false
1=true
Listen_http_ports String 80 Max length:255
Listen_https_ports String 443 Max length:255
Cname String Read-only
http2 Int 1 0=false,1=true
Upstream_scheme String http- Values: Http-Only. Https-
only Only
Proxy_cache_key int 0 0=Standard,
1=Ignorequery string
PAD APIS
3.1 Create new PAD API
Method
POST pad
Return
3.2.1 Method
Response (Example)
3.3.1 Method
Response (Example)
3.4.1 Method
Response
3.5.1 Method
Response
3.6.1 Method
Return
3.7.1 Method
Response
3.8.1 Method
*To update Whitelist, Parameter “captcha_whitelist” and Parameter “captcha_whitelist_edit_type” must be both included.
**Acceptable value:
Response
3.9.1 Method
Response
3.10.1 Method
Response
3.11.1 Method
Response
3.12.1 Method
Response
3.13.1 Method
Response
3.14.1 Method
Response
3.15.1 Method
Response
3.16.1 Method
Response
3.17.1 Method
Response
3.18.1 Method
Response
3.19.1 Method
Response
3.20.1 Method
**Acceptable value:
Response
3.21.1 Method
Response
3.22.1 Method
Response
3.23.1 Method
Response
3.24.1 Method
**Acceptable value:
gzip_types:
Response
3.25.1 Method
Response
3.26.1 Method
Response
3.27.1 Method
Response
3.28.1 Method
Response
3.29.1 Method
Response
3.30.1 Method
Response
3.31.1 Method
Response
3.32.1 Method
**Acceptable value:
Response
3.33.1 Method
Response
3.34.1 Method
Response
3.35.1 Method
Response
3.36.1 Method
Response
3.37.1 Method
**Acceptable value:
"error" and "timeout" are default settings cannot be removed. Please set multiple "proxy_next_pustream" for
multiple options.
Response
3.38.1 Method
© 2019 Toffs Technologies Pte Ltd
Commercial-In-Confidential
Version 1.0
June 2019
Response
3.39.1 Method
**Acceptable value:
Response
3.40.1 Method
Response
3.41.1 Method
**Acceptable value:
Response
3.42.1 Method
Response
3.43.1 Method
Response
3.44.1 Method
Response
3.45.1 Method
*“Enable Free SSL” will be turned on automatically when turning on “Enable Auto Generate SSL” via API
Response
3.46.1 Method
Response
3.47.1 Method
Response
3.48.1 Method
Response
3.49.1 Method
Response
3.50.1 Method
Response
3.51.1 Method
Response
3.52.1 Method
Response
3.53.1 Method
Response
3.54.1 Method
Response
3.55.1 Method
Response
3.56.1 Method
© 2019 Toffs Technologies Pte Ltd
Commercial-In-Confidential
Version 1.0
June 2019
Response
3.57.1 Method
Response
3.58.1 Method
Response
3.59.1 Method
Response
© 2019 Toffs Technologies Pte Ltd
Commercial-In-Confidential
Version 1.0
June 2019
3.60.1 Method
Response
3.61.1 Method
Response
HOST(ALIAS) APIS
4.1.1 Method
Return
4.2.1 Method
4.3.1 Method
PURGE CACHE
5.1 Purge by pad
5.1.1 Method
5.2.1 Method
E.g.:
5.3.1 Method
5.4.1 Method
5.5.1 Method
7.2.1 Method
PAGE RULES
8.1.1 Method
curl -X GET \
https://api.toffstech.com/v1/pagerules?pad_id=5978 \
-H 'X-Auth-Email: t2api@toffstech.com' \
-H 'X-Auth-Token: 0284af49b1fd267248a7684f8b58e92a
Response (example)
"errors": [],
"message": [],
"result": [
"id": 131,
"pad_id": 5976,
"name": "api_pagerules_name_2",
"code": "redirect",
"data": "{\"status_code\":301,\"from\":\"https://www.aaa.com\",\"to\":\"https://www.bbb.com\"}"
},
"id": 130,
"pad_id": 5976,
"name": "api_pagerules_name_1",
"code": "redirect",
"data": "{\"status_code\":301,\"from\":\"https://www.aaa.com\",\"to\":\"https://www.bbb.com\"}"
],
"success": true
8.2.1 Method
GET pagerule/:pagerule_id
curl -X GET \
https://api.toffstech.com/v1/pagerule/131 \
-H 'X-Auth-Email: t2api@toffstech.com' \
-H 'X-Auth-Token: 0284af49b1fd267248a7684f8b58e92a'
Response Example
"errors": [],
"message": [],
"result": {
"id": 131,
"pad_id": 5976,
"name": "api_pagerules_name_update",
"code": "redirect",
"data": "{\"status_code\":301,\"from\":\"https://www.ccc.com\",\"to\":\"https://www.ddd.com\"}"
},
"success": true
8.3.1 Method
POST pagerule
pad_id
name
code
data
The data is JSON data, the specific format is determined by the code
a. Redirect
Dataformat
{"status_code":301,"from":"https://www.aaa.com","to":"https://www.bbb.com"}
b. Forwarding
Data Format:
{"status_code":303,"from":"/xx","to":"https://www.aaa.com"}
c. location_w_rules
Data format:
{"location":"/zh-cn/
","ignore_origin_cache_control":false,"cache_level":1,"edge_cache_ttl":
1800,"browser_cache_ttl":0}
d. Rewrite_url
Data format:
{"from":"/aa-web/xx.do","to":"/bb-web/xx"}
e. Rewrite_header
Data format:
{"header_name":"name_1","value":"value_1"}
f. Rewrite_cookie
Data format:
{"cookie_name":"name_2","value":"value_2"}
g. Proxy_set_header
Data format:
{"header_name":"proxy_set_header","value":"X-Real-IP $remote_addr"}
curl -X POST \
https://api.toffstech.com/v1/pagerule \
-H 'X-Auth-Email: t2api@toffstech.com' \
-H 'X-Auth-Token: 0284af49b1fd267248a7684f8b58e92a' \
-F pad_id=5976 \
-F name=api_pagerules_name \
-F code=redirect \
-F 'data={"status_code":301,"from":"https://www.aaa.com","to":"https://www.bbb.com"}'
"errors": [],
"message": [],
"result": {
"id": 59,
"pad_id": 5976,
"name": "api_pagerules_name",
"code": "redirect",
"data": "{\"status_code\":301,\"from\":\"https://www.aaa.com\",\"to\":\"https://www.bbb.com\"}"
},
"success": true
8.4.1 Method
PUT pagerule/<pagerule_id>
name
code
data
* The data is JSON data, the specific format is determined by the code
a. Redirect
Dataformat:
{"status_code":301,"from":"https://www.aaa.com","to":"https://www.bbb.com"}
b. Forwarding
Data format:
{"status_code":303,"from":"/xx","to":"https://www.aaa.com"}
c. Location_w_rules
Dataformat:
{"location":"/zh-cn/
","ignore_origin_cache_control":false,"cache_level":1,"edge_cache_ttl":
1800,"browser_cache_ttl":0}
d. Rewrite_url
Data format:
{"from":"/aa-web/xx.do","to":"/bb-web/xx"}
e. Rewrite_header
Data format:
{"header_name":"name_1","value":"value_1"}
f. Rewrite_cookie
Data format:
{"cookie_name":"name_2","value":"value_2"}
g. Proxy_set_header
Data format:
{"header_name":"proxy_set_header","value":"X-Real-IP $remote_addr"}
curl -X PUT \
https://api.toffstech.com/v1/pagerule/131 \
-H 'X-Auth-Email: t2api@toffstech.com' \
-H 'X-Auth-Token: 0284af49b1fd267248a7684f8b58e92a' \
-F name=api_pagerules_name_update \
-F code=redirect \
-F 'data={"status_code":301,"from":"https://www.ccc.com","to":"https://www.ddd.com"}
"errors": [],
"message": [],
"result": {
"id": 131,
"pad_id": 5976,
"name": "api_pagerules_name_update",
"code": "redirect",
"data": "{\"status_code\":301,\"from\":\"https://www.ccc.com\",\"to\":\"https://www.ddd.com\"}"
},
"success": true
8.5.1 Method
DELETE pagerule/:pagerule_id
curl -X DELETE \
https://api.toffstech.com/v1/pagerule/131 \
-H 'X-Auth-Email: t2api@toffstech.com' \
-H 'X-Auth-Token: 0284af49b1fd267248a7684f8b58e92a'
"errors": [],
"message": [],
"result":
{ "status":
true
},
"success": true
TOFFS IP List
9.1.1 Method
Response