Migration API Technical Reference
The Migration API endpoint allows developers to create and update documents in a Prismic repository.
Migrating to Prismic?
For a better understanding of how to work with the Migration API, see the dedicated Migration article.
The data format for the Migration API is described below. The format follows the response format from the Document API, though the Document API includes properties that are unnecessary for the Migration API.
If you query a document object from the Document API and then send it to the Migration API, the Migration API will ignore the unnecessary properties and accept the rest.
Documents will be created as drafts, which you can publish in your repository.
By default, documents created or updated via the Migration API will be added to a migration release, accessible from the Migration Releases
tab in your repository.
To include media (images, files, videos) in your documents, you will need to upload the media to your repository (either via the UI or the Asset API) and then fetch the ID for the media asset to include in your request to the Migration API.
We recommend saving the id
from the POST response for each document upon creation, as you will also require this id
to make updates to existing documents.
You can't publish with the Migration API
Edits posted to the Migration API will be added as drafts. You can review and publish your changes in the Migration Release tab of your repository.
As a security measure, it is impossible to programmatically publish changes in Prismic.
- Each request to the API can contain one document, which will be saved in the repository as a draft.
- Requests are limited to one per second.
This feature is in beta and requires an access key
Admin users can try the Migration API using a demo key. Go to the Migration Releases tab in your repository for instructions.
{
"title": "Example Document",
"uid": "example-document",
"type": "example_type",
"lang": "en-US",
"tags": [
"Red",
"Yellow",
"Blue"
],
"alternate_language_id": "ZRFHsxIAAFYAsY--",
"data": {
"example_boolean": false,
"example_color": "#e0dbfd",
"example_date": "2024-12-23",
"example_timestamp": "2023-02-20T01:12:12+0100",
"example_integration": {
"id": "3"
},
"example_shopify_integration": {
"id": 7505689739510
},
"example_embed": {
"embed_url": "https://www.youtube.com/watch?v=S26CHpcD2zk"
},
"example_geopoint": {
"latitude": "-9",
"longitude": "-160"
},
"example_image_1": {
"id": "ZMgV5hAAAEADVsPS"
},
"example_image_2": {
"id": "ZMgV5hAAAEADVsPS",
"alt": "Example alt text",
"copyright": "Example copyright info",
"dimensions": {
"width": 800,
"height": 200
},
"edit": {
"x": 2,
"y": 28,
"zoom": 3,
"background": "#ffffff"
},
"mobile": {
"id": "ZMgV5hAAAEADVsPS",
"alt": "this is some alt text",
"copyright": "some copyright info"
}
},
"example_web_link": {
"link_type": "Web",
"text": "Click Here",
"url": "http://www.prismic.io"
},
"example_document_link": {
"link_type": "Document",
"id": "ZMI65RQAADkECUFM"
},
"example_media_link": {
"link_type": "Media",
"id": "ZMgV5hAAAEADVsPS"
},
"example_number": 23,
"example_select": "Apples",
"example_content_relationship": {
"link_type": "Document",
"id": "ZMI65RQAADkECUFM"
},
"example_group": [
{
"key_text_description": "Lorem",
"number_price": 55
},
{
"key_text_description": "Ipsum",
"number_price": 60
}
],
"example_rich_text": [
{
"type": "heading3",
"text": "This is a heading3",
"spans": []
},
{
"type": "paragraph",
"text": "Bold and italic example.",
"spans": [
{
"start": 0,
"end": 3,
"type": "strong"
},
{
"start": 8,
"end": 14,
"type": "em"
}
]
},
{
"type": "image",
"id": "ZPrkIhYAACcAYvyB",
"alt": "Example alt text",
"copyright": null,
"dimensions": {
"width": "512",
"height": "512"
}
},
{
"type": "embed",
"oembed": {
"embed_url": "https://prismic.io/"
}
}
],
"//": "The default slice zone is 'slices'",
"slices": [
{
"variation": "default",
"primary": {
"example_number": 11
},
"slice_type": "example_slice_type_1"
}
],
"example_slice_zone": [
{
"variation": "example_variation",
"items": [
{
"example_select": "Dog"
}
],
"slice_type": "example_slice_type_2"
}
]
}
}
Authorization
A permanent token or user session token from the Authentication API.
repository
The repository ID (e.g. your-repo-name
).
x-api-key
A key required for accessing the Migration API Beta. Find a demo key in the Migration Release tab of your repository.
https://migration.prismic.io/documents
The JSON body of every POST request must contain the following required properties:
title
type
uid
(if present on type)lang
data
alternate_language_id
(if creating a localized version of a singleton type)
https://migration.prismic.io/documents/:id/
:id
is the ID for an existing document.
The JSON body of every PUT request must contain the following required properties:
uid
(if present on type)data
The body can also include the following optional properties:
title
tags
The following properties cannot be modified on PUT requests and will be ignored if they are included in the body:
type
lang
alternate_language_id
title
A display title to appear in the document list.
type
ID of the document’s type. Required for POST requests.
lang
The document’s locale.
data
An object containing the content of the document. Each key in the object should be a field or slice zone, and each value should be the content. (See the structure of the fields below.)
tags
An optional list of tags for the document. (Existing tags will be deleted if this property is omitted in a PUT request.)
uid
The document’s UID, which must be unique to that type. Required if present on the type and disallowed if absent on the type.
alternate_language_id
An optional ID for the document for which you are creating a translation.
The data
property represents the content of the document. Each key in the data object should be a field
or slice zone
on the document type, and the value should be the content.
The content of data
must conform to the structure of the document type.
If the field has a default value configured, the default value will be used for null values.
The string must be a hexadecimal color value.
Same as the value for a link with a link_type
of "Document"
.
The string must match the format YYYY-MM-DD
.
The object can optionally contain an embed_url
property with a URL as its value. Other properties will be ignored.
An empty object or an object with latitude
and longitude
properties, each with a value string representing a number. The value of latitude
must be between -90 and 90. The value of longitude
must be between -180 and 180.
An array of field objects.
An object with the required property id
and optional properties alt
, copyright
, dimensions
, edit
, x
, y
, zoom
, and background
.
id
string (required)
A string that exactly matches the ID of an exiting image in Prismic’s media library.
alt
string
The alt text for the image.
copyright
string
Copyright information for the image.
dimensions
object
An object with optional width
and height
properties, with numbers for their values, defining the image resize. If thumbnail width or height is already configured in the type, this value will be ignored.
edit
object
Parameters for editing the image. The object can contain:
x
: X coordinate for crop as an integer
y
: Y coordinate for crop as an integer
zoom
: Zoom level as an integer
background
: Background color as a hexadecimal code (defaults to transparent for PNGs and #ffffff
for other file types)
The image object can also contain thumbnail properties. The key should be the name of the thumbnail and the value should be an object with properties as described in the table above.
The ID of an item from your integration.
For shopify integration, the ID comes from your Shopify catalog. For Custom API format, the ID property is defined by the endpoint and duplicated in blob
. See the Integration docs for more information.
A string of text.
An object with the required property link_type
and conditional properties depending on the type.
link_type
string (required)
One of "Document"
, "Web"
, or "Media"
.
id
string
Required if link_type
is "Document"
or "Media"
.
For "Document"
, id
must be the ID of any document in the repository, published or unpublished.
For "Media"
, id
must be the ID of an item from the Media Library.
url
string
Required if link_type
is "Web"
.
An absolute URL.
target
string
Where to open the linked URL (optional). Only accepts "_blank"
, to open links in a new window.
text
string
The optional display text of the link
Value must conform to max
and min
if either is defined in the type.
An array in which each object represents a block element.
A rich text field must contain an array of content blocks. Every block must have a type
property with one of the following values:
"paragraph"
"o-list-item"
"list-item"
"heading1"
"heading2"
"heading3"
"heading4"
"heading5"
"heading6"
"preformatted"
"embed"
"image"
Every block except for those with a type of embed or image can have the following properties:
text
string (required)
The text content of the block.
spans
array
An array of objects describing inline markup. Each object must have a type with the value of either "em"
, "strong"
, or "hyperlink"
. Each object must also have start
and end
properties denoting the starting and ending indexes of the span. Spans can overlap. Spans of type hyperlink
must also have the properties defined for a link field.
direction
string
Value can only be "rtl"
, which defines the text as right-to-left.
oembed
object
Required only for blocks with a type
of "embed"
. The object should contain an embed_url
property with an absolute URL as the value.
Blocks with a type of "image"
must have the properties defined for the image field.
If value is a string, the string must match one of the options defined in the type. If the field has a default value configured, it will be used for null values.
Each slice zone property must be an array of zero or more slice objects. By default, all types in Prismic have a slice zone property called slices
, but the developer can change the name of the slice zone and add other slice zones.
Each slice object must have the following properties:
slice_type
string (required)
The ID of the slice type (e.g. "hero_image"
).
variation
string (required)
Must match one of the variations defined in the configuration for the slice type, even if there is only one variation. The default variation for slice types is called default
.
id
string
A optional string in the following format: slice_type
+ $
+ uuid v4
. Must be unique within the document. If omitted, it will be generated automatically.
slice_label
string
A label that will appear in the Document API response. If omitted, it will be set to null
.
primary
object
An object containing the fields of the slice.
items
array
An array of objects containing the fields of the repeatable zone of the slice (deprecated).
In addition to an error code, detailed error messages are displayed in the JSON body of the response. Enable your user agent to receive the error response body.
Examples:
[
{
"property": "data.richtext.2.type",
"value": "heading2",
"error": "Invalid block type. Supported block types are: paragraph, embed"
}
]
[
{
"property": "title",
"error": "The value must be a string"
}
]
Can't find what you're looking for?
Need technical Support? Spot an error in the documentation? Get in touch with us on our Community Forum.