Forge REST API v2

forge
api
rest

#1

We’ve been working on a new and updated API for Forge. This will ultimately replace the current v1 API, though for the time being, they will run side by side.

The goal of the v2 API was to really expose all the Forge features via a suite of endpoints, so you can freely experiment and build workflows that suit you.

The first and most significant change is the API authorisation system. In v1, you had complete access to all of your Forge sites using the given access token. This was like a skeleton key to your entire Forge account, making it very difficult to share with your team or collaborators.

In v2, we still have the account-wide token, but we’ve also introduced a Site token, scoping access to a specific site.

You can find your Account Token in https://getforge.com/#/account/settings and your Site Token in https://getforge.com/#/[site_id]/settings of the Forge Admin panel.

Site Details API

GET
Endpoint: api/v2/settings/site_info
Description: to retrieve information about one of your Forge sites
Parameters: site_token (string)

Site Settings API

POST
Endpoint: api/v2/settings/ssl_mode
Description: to enable or disable ssl_enabled.
Parameters: site_token (string), status (boolean)

POST
Endpoint: api/v2/settings/force_ssl_mode
Description: to enable or disable force_ssl_enabled (only valid if ssl_enabled == true)
Parameters: site_token (string), status (boolean)

POST
Endpoint: api/v2/settings/turbojs_mode
Description: to enable or disable Turbojs
Parameters: site_token (string), status (boolean)

POST
Endpoint: api/v2/settings/hammer_mode
Description: to enable or disable Hammer Cloud service.
Parameters: site_token (string), status (boolean)

POST
Endpoint: api/v2/settings/domain_name
Description: to change the site name. Custom domains are only valid with a paid Forge subscription.
Parameters: site_token (string), new_domain (string)

POST
Endpoint: api/v2/settings/deployment_method
Description: to change the deployment method.
Parameters:
for Dropbox: site_token (string), deployment_method (string e.g. 'dropbox'), folder_path (string. Relative to dropbox root folder, e.g. '/your_folder_in_root'). Dropbox must already be connected to your Forge Account.
for Github: site_token (string), deployment_method (string e.g. 'github'), branch (string e.g master). Github must already be connected to your Forge Account.
for Drag & Drop: site_token (string), deployment_method (string e.g. 'manually')

Site Bandwidth API

GET
Endpoint: api/v2/site_bandwidths
Description: to retrieve information about one of your Forge sites
Parameters: site_token (string), unit (string e.g. ‘last month’, ‘month’, 'week', ‘last week’), to (date e.g ‘2017-01-01’), after (date e.g. ‘2015-01-01’)

Account Plan API

GET
Endpoint: api/v2/account/subscription_plan
Description: to read the current Account Plan.
Parameters: account_token (string)

POST
Endpoint: api/v2/account/subscription_plan
Description: to change the Account Plan.
Parameters: account_token (string), new_plan (string)