REST API v1
Forge has a basic REST API currently, which we created to enable our CLI tool and to test automated deployments.
Authentication
First, you need to login your user (they need to have an existing account from Forge 7
POST https://getforge.com/api/cli/login
curl -X POST "https://getforge.com/api/cli/login" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-d '{
"email": "YOUR_EMAIL",
"password": "YOUR_PASSWORD"
}'
Response Example:
`{"name":"USERNAME","token":"YOUR_TOKEN"}`
You’ll want to store the token somewhere safe for further requests to the user account.
Fetch Sites
You’ll probably want to retrieve a list of the Forge users sites at some stage, in order for User to select a site to perform some action.
You can do that like this…
GET https://getforge.com/api/cli/sites
curl -X GET -H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
"https://getforge.com/api/cli/sites?token=YOUR_TOKEN"
Publish Site
You can upload an archive (.zip) of your site to publish on Forge. You need to specify the site you wish to deploy to in the params, along with the user token. The site should be submitted as multipart form data.
POST https://getforge.com/api/cli/deploy
Since multipart form data via cURL is a bit fiddly, here’s what it would look like via Postman REST Client
:rrot {
--color-ui-primary: theme('colors.orange.600');
}