Introducing Workflow API
Hey there,
It’s been a while since our last post. However, we didn’t chill out but worked hard to deliver a new feature. And today we are happy to announce that now Pixboost supports workflows API.
What is it?
There are things that you could do manually. For instance, you can login to Pixboost and clear the image cache for the specific image or path. Though, you might need to do this on some event automatically from your code. With a cache clearing, it could be the case when image changed, but filename didn’t. If it happens one time, then it’s okay, but what if you need to repeat cache clearing many more times?
NOTE: We encourage you to not rely on cache clearing in your apps and use different file names once image changes.
You might also need to automate this process. And that’s where our new workflow API would help.
How is it different from transformation API?
Pixboost already has API that transforms images. So, how workflow API different? The main difference between them is that workflow API is private and you should not call it publicly. For example, you shouldn’t call workflow API from HTML or JS code on your website from the browser. You would instead call it from the server-side code. Additionally, there is a different method of authentication. Instead of using API keys, workflows are using API secrets. You manage API secrets from the dashboard:
You will see the value of the secret only once after you created it. We do not store the plain value of the secret and only have a hash. So, if you loose a secret, then you would need to recreate it.
Secrets then are used for authentication during API call and passed by using “auth” query parameter.
Let’s go back to the API. Currently, we implemented only one endpoint — cache clearing. You could call it like this:
curl -X DELETE ‘https://pixboost.com/api/2/img/<http://yoursite/image-to-clear.png>?auth=<YOUR_SECRET>'
Cache clearing is not happening synchronously and could take from 1 to 5 minutes. You’ll receive 202 response code from the endpoint which means that request successfully added to a queue.
We’ve implemented only one endpoint because it has been requested by one of our existing clients. But we have more coming. If you need other endpoints, then please email it to customer.service@pixboost.com, and I will move it to the top of our backlog.
Cache Invalidation Workflow
We’ve implemented reference design of the workflow that clears Pixboost CDN cache once files in AWS S3 bucket are modified:
You can find all the sources of the implementation on GitHub.
Conclusion
Having API foundation built opens a lot of opportunities for us to implement more advanced features. We are looking forward to adding new endpoints and make our platform more flexible.
Another highlight of this feature is the fact that it came from the existing customer. There couldn’t be more pleasure than adding useful features. Let us know if you have one in your mind!