Build SaaS with Polar using our API, Webhooks & OAuth
Our mission at Polar is for developers to get paid coding on their passions. Empowering open source- and indie developers to build independent careers and businesses. All the way from first donation to IPO.
Today, we're introducing OAuth & Webhooks to support developers to build custom community- and customer experiences across their docs, sites and services.
Enabling use cases like:
- Celebrate & reward sponsors, donors & issue backers on your sites
- Grant access to online courses
- Unlock premium content for subscribers
- Enable cloud services for customers
We can't wait to see what you build 🚀 Have an exciting idea and want to build it open source? Join our Discord and let's chat - we'd love to sponsor a few promising efforts ♥️
OAuth 2.0 with OpenID Connect support
Polar is now an OAuth 2.0 provider with OpenID Connect support to automatically work with existing - compatible - clients using our discovery endpoint: https://api.polar.sh/.well-known/openid-configuration
Let's start with creating your first Polar OAuth App.
Create Polar OAuth App
- Go to your user settings
- Scroll down to the
Developer Settings
section - Click
New OAuth App
- Set the
Application Name
,Redirect URIs
,Homepage URL
and select desiredScopes
. - Optional: Add a
Logotype
and link to your customTerms of Service
&Privacy Policy
for the application. - Click
Create
. - Store the given
Client ID
andClient Secret
somewhere safe & secret.
You're now ready to integrate the Polar OAuth App 🎉 Follow our complete integration guide here.
User Authentication Flow
Your docs, site or services can now authenticate users with their Polar account to gain access to their profile, subscriptions, orders, granted benefits and more. All you need to build completely custom experiences for your community members, sponsors and customers.
Just redirect users to the generated OAuth authorize
URL and they'll be able to grant the permissions requested before being redirected back to your redirect_uri
with an authorization code.
You then exchange it for an access token polar_at_XXX
and you're ready to make API requests.
curl -X GET https://api.polar.sh/api/v1/oauth2/userinfo \
-H 'Authorization: Bearer polar_at_XXX'
Organization Authentication Flow
We also support authenticating an organization similar to GitHub. Admins will then be prompted to grant access for a specific organization they manage.
Great, that covers synchronous requests, but what about asynchronous updates? Polling is so 2010.
Webhooks
Polar supports the following Webhook events (with more to come):
subscription.created
subscription.updated
product.created
product.updated
benefit.created
benefit.updated
organization.updated
pledge.created
pledge.updated
donation.created
We follow the Standard Webhook guidelines to make integration intuitive and familiar. Checkout our docs for integration details and payload schemas for the available events.
Add Webhook Endpoint(s)
- Go back to your Developer Settings
- Click
Add Endpoint
in theWebhooks
section - Set the endpoint
URL
,Secret
(for webhook validation) and the events you want to subscribe to.
That's it. Get ready to start receiving webhooks for the requested events 😍
Delivery Log
We also provide a delivery overview for each Webhook Endpoint URL to make development easy. So you can debug historic webhooks sent along with their entire payload.
[!NOTE] This is meant to aid development or debugging recent production issues vs. be an all-time historic database. Don't rely on more than 24-48h worth of history in the future.
API & Docs (beta) 🏗️
Our ambition is to make the Polar REST API world-class with innovative documentation features and outstanding content. It's going to be our #1 product with Polar itself being an excellent open source example of how to integrate all of it's capabilities.
So we've committed to something crazy... We're building our own docs engine to support the groundbreaking DX features we have in mind. Combined with updating our API endpoints to be :chef-kiss:
We're building it in public and open source (as always). Over the coming months a lot is going to be improved with our current docs (early iteration in need of love and content) and API. So make sure to join our Discord for continuous updates and integration support as needed in the meantime.
Sponsoring Open Source Integration Kits
We love open source at Polar. Do you have an exciting idea for an integration use case and want to build it open source? We'd love to chat with you as we're excited to sponsor a few developers and use cases. Join our Discord and let's explore!
We're going to do a lot more of this towards the autumn too 😎