Introduction

To connect your Sanity account to Cloudpress, you will need to give Cloudpress information about your Sanity project. This document will walk you through the process of connecting your account.

Sanity schema overview

To add your Sanity account to Cloudpress, you will need details of the schema for the Sanity document type you will be exporting content to. You will need to know the name of the schema, the name of the field that contains the title of the document, as well as the name of the field that contains the document’s content.

For this guide, let’s assume that we have a schema named post with a title field that contains the title of the document, as well as a body field that is defined as blockContent that contains the content of the document.

Here is the configuration of the sample schema:

export default {
  name: 'post',
  title: 'Post',
  type: 'document',
  fields: [
	{
  	name: 'title',
  	title: 'Title',
  	type: 'string',
	},
	{
  	name: 'slug',
  	title: 'Slug',
  	type: 'slug',
  	options: {
    	source: 'title',
    	maxLength: 96,
  	},
	},
	{
  	name: 'body',
  	title: 'Body',
  	type: 'blockContent',
	},
  ]
}

You will also need an API Token allowing Cloudpress to access your Sanity account. This token can be obtained on the project page in Sanity Management Console and will be covered in the section below.

Be sure that you either have access to the Management Console yourself or get a token from a person that does have access to it.

Generate an API Token

You will need an API token to give Cloudpress access to your Sanity account. Open the Sanity Management Console and select your project. Navigate to the API tab and scroll down to Tokens section.

Your API Tokens in Sanity

Click on the Add API Token button. Give the token a descriptive name, and select the Editor permission.

Generate a new API Token

Click the Save button to generate the token. Copy the token to the clipboard, as you will need it in the following step.

Connect your Sanity account

Go to the Connections page in Cloudpress, click on the Add Connection button and then select Sanity from the list.

Select Sanity from the available account types

This will take you to the Connect a Sanity account step.

Enter the API Token for your Sanity account

Paste the API Token you previously generated in Sanity, then click Continue. Next, you will be prompted to select the project you want to export to. Select your project from the list.

Select the project you want to export to

The next step is to configure your data model. You will need to select the dataset you want to use and tell Cloudpress the name of the content type, title field, and content field you want to use.

Configure your Sanity data model

The screenshot above demonstrates the configuration for exporting to the example schema at the beginning of this document. It will export the content to the post type. The document title will be expored to the title field, and the content of the document will be exported to the body field.

The final step is to confirm your connection configuration and give the connection a descriptive name. Click the Create Connection button to continue.

Confirm the configuration of your new Sanity connection