CloudDocs
Getting started
Weebly Cloud Account
The first step in using the Weebly Cloud API is to create a Weebly Cloud account. This account gives you access to the Weebly Cloud Admin where you can create your API key and secret. If you don't have a Weebly Cloud account, then email our team here.
RESTful API
Now that you have your Weebly Cloud account let's learn how to start using the Weebly Cloud API. The API is a RESTful API that utilizes HTTP verbs GET, POST, PUT, PATCH and DELETE.
Signing and Authenticating Requests
The API is validated using both a public key and a private HMAC Hash of the request contents. These values must be passed in the request header as X-Public-Key and X-Signed-Request-Hash. To get started making requests you will need YOURAPIKEY and YOURAPISECRET which can be generated and obtained on the Settings tab in the Weebly Cloud Admin provided for your account. YOURAPISECRET is a shared secret known only to you and Weebly Cloud. Do not share YOURAPISECRET.
Example Request Header
POST /hosts/user/39793399/site HTTP/1.1 User-Agent: curl/7.30.0 Host: api.weeblycloud.com Accept: */* Content-type: application/json X-Public-Key: YOURAPIKEY X-Signed-Request-Hash: YOURSECRETHASH
In the example above, YOURAPIKEY refers to your API Key. This API Key is used by our system to identify your account. YOURSECRETHASH refers to the computed HMAC-SHA256 signature. The signature will need to be computed for each request. You can generate YOURSECRETHASH using an HMAC-SHA256 hash of the request TYPE (Ex. POST), URL (ex. user/234256/loginLink) and any REQUEST DATA (ex. { 'package_id': 34 }) using YOURAPISECRET as the key. Any requests that do not contain a valid signature will be rejected. Since YOURAPISECRET is shared only by you and Weebly Cloud, we are able to validate your request by generating the same HMAC-SHA256 signature and match it against YOURSECRETHASH.
Example request made using HMAC-SHA256 with PHP
$base_api = "https://api.weeblycloud.com/hosts/"; $api_key = YOURAPIKEY; $api_secret = YOURAPISECRET; $request_type = "POST"; $url = "user/39793399/site"; $data = array( "domain" => "test-site.com" ); $content = json_encode($data); $hash = hash_hmac('SHA256', $request_type . "\n" . $url . "\n" . $content, $api_secret); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $base_api.$url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_type); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-type: application/json', 'X-Public-Key: ' . $api_key, 'X-Signed-Request-Hash: ' . $hash )); $out = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); $result = json_decode($out); if ($info['http_code'] === 200) { //Successful Request } else { //handle error }
Note the line below which generates the hash for this request.
$hash = hash_hmac('SHA256', $request_type . "\n" . $url . "\n" . $content, $api_secret);
Test Mode
When first getting acquainted with the Weebly Cloud API your Weebly Cloud account will be in test mode. This defaults any users and sites created to be denoted as test. You won't be charged for these sites and users. They will be periodically removed from the system, but after your Weebly Cloud account is in production mode.
Once in production mode you can still create a test user by passing the optional parameter of "test_mode". Learn more about the User API.
Once in production mode you can still create a test user by passing the optional parameter of "test_mode". Learn more about the User API.
Errors
Weebly Cloud returns an error object containing an error code and a description of the error
Error response from a bad request
{ "error": { "code": 900, "message": "brand_name field missing" } }
Error code summary
100
|
Invalid hash provided.
The hash provided does not match the request. |
101
|
Unknown api key provided.
Check the Admin Portal to verify that your key still exists. |
102
|
This Weebly Cloud account does not have api access.
|
200
|
This Weebly Cloud account does not have access to this user.
|
201
|
This Weebly Cloud account does not have access to this site.
|
999
|
An unknown error occurred.
|
900
|
Invalid Request.
|
-32001
|
invalid namespace or function name
|
-32002
|
Class not found
|
-32404
|
Invalid Request
|
-32600
|
Invalid Request
|
-32601
|
Method not found
|
-32602
|
Invalid params - too few
|
Site Info
|
More
|
|