Custom type upsert endpoint

Feature Idea (one per thread):

An endpoint in Custom types REST API which inserts custom or updates custom type based on existence of given type ID.

Issue that it solves:

Currently, one has to check if type exists before creating or updating it. Given that payload for both update and create API calls is the same it would be easier and faster to have one call checking existence of custom type internally.

Hello @konstantin.azizov, welcome to the Community!

This feature already exists in Prismic!

It's called Custom Types API. It allows you to hit an endpoint to retrieve and post your full Custom Types with their Slices. The use cases for this tool include programmatically creating backups for your Custom Types, automatic creation of Typescript Types, and building your Gatsby Schema dynamically, and more.

Here's the full documentation:

Let me know if you have any questions or suggestions.

Hi @Pau, thanks for prompt reply!

I might've not been entirely clear on the description. The issue that I'm facing is while using Custom Types API there is an additional step if I need to programmatically manage type definitions. For example, if I have a Custom Type defined in my script, I would first have to send /update request(to update) and if it fails try /insert request(to create) or, more gracefully, first check if type exists by fetching it and then deciding between /update and /insert.

My proposal is to have a new /upsert endpoint, accepting the same payload as /update and /insert but allowing managing creation or an update internally without needing extra step.

Hope it clarifies my idea a bit, let me know if you have any questions!

Thank you for the clarification. It makes a lot of sense.
I'll update the feature request.

This is being tracked as an open feature request.

If you have another use-case for this feature, you can 'Flag' this topic to reopen. Please use the :heart: button to show your support for the feature and check out our Feature Request Guidelines.