What is an API ID?

When you retrieve content from the Prismic API, the API ID is used to identify the slice type in a list of slices. Prismic automatically generates the API ID for slices when you create the slice in your Custom Type.
 

How is the API ID Generated? 

When you create a slice and give it a name, this name is formatted with certain rules and set as the API ID. It will take the name you’ve given and do the following:

  1. Replace all spaces with underscores.
  2. Convert all uppercase characters to lowercase characters.

For instance : If you give a slice the name “Full Width Image”, Prismic will automatically generate the API ID "full_width_image".
 

What happens when you change the API ID?

When you change the API ID of a slice, all the existing content you have for that slice will disappear and you will need to create it again. If you want to get that content back, you just need to reset the API ID of the slice back to the original value.
 

How to modify the API ID?

It’s important to know that after you’ve initially created the Slice, when you modify the name of the Slice, the API ID will not automatically be updated. 

Here are the steps you need to take to change the API ID:

  1. Go to the edit page for the Custom Type where you need to modify the slice
  2. Click on the JSON editor. This will bring up the JSON definition of the Custom Type.
  3. Find the Slice that you would like to modify in the JSON code.
  4. Edit the API ID

How to view the API ID of a slice from the API Response 

API ID will be visible as the property slice_type in your Slice zone. Here is an image that shows the slice with the API ID of full_width_image .

Did this answer your question?