Custom Protected Endpoint in Self-Hosted Ghost?

Hi everybody :slight_smile:

I’m new to Ghost and was hoping to fast-track my knowledge in terms of what I can and can’t do with it.

I was wondering if there’s a way to create a custom endpoint on my self-hosted Ghost platform e.g. /api/custom/premium-content and make it only accessible by users on certain membership tiers?

Any help would be appreciated (a hard “not possible” is as useful). Thank you!

Basically all of Ghost is open source. So you can absolutely do that if you’re self hosting and can run a custom version of Ghost.

Having said that, forking the Ghost core and adding an endpoint is not a trivial job, and maintaining a fork (assuming you continue to want the new features that the dev team rolls out) can be an ongoing job.

You might consider sharing what you’re actually trying to accomplish - there may be easier options.

Thank you @Cathy_Sarisky!

I want users in a specific membership tier to access functionality provided by a 3rd party API, specifically a recipe API like FatSecret or Spoonacular for recipe filtering.

I can also use Ghost’s events to create a separate system outside of my server, but still need something on the server that will at least pass user content to my external system.

I specifically want to use Ghost for a “lite” version of a larger suite of products as it eliminates the overhead of user management and responsive blog rendering for me.

So it might be more straightforward to set up your proxy to pass calls to /whatever/your/api/endpoint to a separate service, which might or might not be co-located. Have the server for that endpoint confirm the user’s identity (you’ll need to include the result of /members/api/session/ in the request to your new endpoint, and have the server validate it using /members/.well-known/jwks.json), then have your server confirm with the Admin API that the user is on the appropriate tier.

1 Like

Thank you for this! I was not aware of the /members/api/session/ endpoint (a further indictment to why maintaining a fork may be a challenge right now). I got this to work. This gives me a great way of augmenting custom functionality while not touching Ghost’s core.

1 Like