New API docs help you automate workflows

10 Jul 2019
Nick Anderegg
Developer Relations Engineer

Look ma! No hands!

Although our main API is Git itself, Platform.sh has a powerful RESTful API that enables you to manage nearly every aspect of your account and the projects you host with us.

Today, we’re happy to announce that we’re launching a new documentation site that details our entire RESTful API, so you can use it to build robust development and management workflows, as well as integrations with your CI systems and internal services.

You can check out these docs right now.

What can I do with the API?

Everything! If you’re already a Platform.sh customer, you’re likely accustomed to interacting with your projects through our management console or our CLI tool. With our API, you can automate all of those interactions! You can create a new project to run your app, and manage snapshots of your production and development environments. Or integrate your project with third-party services, like Git repositories, health notification services, and webhooks.

How you actually use this API is totally up to you. From a simple action—like adding new domains to a project—to a complex task—like automating the process of creating and configuring new projects for each of your clients’ applications—there’s virtually no limit to what you can build.

How do I get started?

Because this is a REST API, all you need to get started is an API token. Once you have that, you can start making calls directly, or you can check out one of our libraries on GitHub that make it easier to access the API, such as our PHP API client or our JavaScript API client.

If you already have an account with us, you can visit your accounts-setting page to generate a new API token.

Your API token can be exchanged for an access token with a POST request from your tool of choice. Here’s an example using cURL:

curl -X POST \
  https://accounts.platform.sh/oauth2/token \
  -H 'Content-Type: application/json' \
  -d '{
         "client_id": "platform-api-user",
         "grant_type": "api_token",
         "api_token": "YOUR_API_TOKEN"
  }'

The response to your request will include an access token you can use to authenticate subsequent API requests.

{
    "access_token": "abcdefghij1234567890",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "account"
}

If you don’t already have an account on Platform.sh, and you want to see what our API can do, we have a free trial available, so you can start building right now!