Connecting to the Pressable API
The Pressable API allows you to communicate with your managed WordPress hosted Pressable site using an external application written in any programming language. Some of the things you can do after you connect to the Pressable API include managing your site and performing operations such as creating a site, deleting a site, renaming a site, cloning a site, and a lot more.
How to connect to the API
From this page, you can give a custom name for your new API Application and assign the permission levels you’d like the app to have.
Once the API app is created a Client ID and Client Secret will be generated for you which you’ll need to connect to the API from any external application. Make sure you don’t share these tokens with anyone as they can be used to access your site.
How to Generate an Access/Bearer Token?
To successfully connect to the API you’ll need an Access Token (sometimes also referred to as a Bearer Token). To generate one go to the Pressable API docs and click on Authentication. Copy the cURL snippet and replace it with your generated Client ID and Client Secret.
Your end result should look similar to the snippet below but with your unique
curl --location --request POST 'https://my.pressable.com/auth/token' \ --form 'grant_type="client_credentials"' \ --form 'client_id="QbWIe7vxfNzZ1vZ7_YFIDNm_NCD7b5X43A68QX4qfzk"' \ --form 'client_secret="V8uqwz5sL0PdNVm8MUNo5WfdGdm_s1g4BMYSVF47H4k"'
Go to the command terminal on your computer then paste the cURL snippet containing your connection credentials.
You should see a response similar to the one in the screenshot below. From there you can copy the access_token as highlighted.
This Access Token will be used to authenticate requests made by your API application.
Note: The generated Access Token expires every 3599s which is approximately 59 mins or 1 hour. Once it expires you won’t be able to access the API and will need to generate a new one. If you are developing an app that consumes the Pressable API you’ll need to come up with a way to auto-generate the Access Token using a refresh token when it expires.
How to query the API?
You can use an API testing Tool like Postman to test your connection and also query the API.
To get started, download Postman from their official site. To connect to the Pressable API you’ll need your Access Token and the API URL you want to query. Examples of those endpoint URLs can be found on the API docs as seen in the screenshot below:
Pressable API basic endpoint URL
Examples of supported methods
A complete Pressable API endpoint URL should look similar to this:
How to use Postman API test tool to clear your Pressable site CDN cache
To successfully make a query to the API you’ll need to get the Pressable Site ID of the website you want to query.
Go to your MyPressable Control Panel and select the site you want to query by clicking on the site name or the settings icon from the site list page.
In the browser address bar, you should see your selected Pressable Site ID which you can copy for use in Postman.
You should now be able to form your endpoint URL to clear the cache of your website which should look like this with the Site ID added: https://my.pressable.com/v1/1219162/cache
/cache is the query object you’re querying which can be found in the API documentation under clear a site CDN cache.
Next, go to Postman and open a new window.
Enter the endpoint query URL containing your Site ID, e.g.
https://my.pressable.com/v1/1219162/cache. To clear the CDN cache, we’ll make a
Under the space you entered the endpoint query URL click on Authorization > Bearer Token > add your Token.
Once it is added you can go ahead and click on Send to query the API to clear your CDN cache for the site. This should return a 200 response if the query was successful.
For more information on how to use the Pressable API please refer to the API docs or reach out to the Pressable support team via chat or sending an email to email@example.com