Published on

Connect a Sanity account

Introduction

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

Sanity schema overview

In order to add your Sanity account to Cloudpress, you will need to have some basic information regarding the schema for the Sanity content type you will be exporting 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 content of the document.

For the purposes of 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 that will allow Cloudpress to access your Sanity account. This token can be obtained on the project page in the 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.

Connecting your Sanity account

To connect your account, go to the Connections page in the Cloudpress Dashboard. Depending on whether or not you have previously connected other accounts, you will either see an empty list of accounts or a list of accounts that you have already linked. If you see an empty list, click on the Connect a Sanity account button:

Alternatively, click on the Connect another account drop-down menu, then select Connect a Sanity account:

This will take you to the Connect a Sanity account screen:

You will need an API token that will allow Cloudpress to access your Sanity account. To generate an access token, go to the Sanity Management Console and then to the Settings for the project you want to use.

On the API tab, scroll down to Tokens and click on the Add API Token button.

Give the token a descriptive name and be sure to select the Editor permission.

Click the Save button to generate the token.

After the token has been generated copy it to the clipboard. Return back to the Cloudpress website, paste the token in the API Token field and then click the Connect account button.

Next, you will see the Sanity account configuration screen:

Cloudpress will automatically use the name from your Sanity project as the name of the linked account. You are free to rename it to something else, but keep it descriptive so you know which Sanity project and account it refers to.

Select the dataset to which you want Cloudpress to export from the list. This list will correspond to the available datasets you have configured in your Sanity Management Console.

The document content type, title field and content field will depend on your Sanity schema. For the example schema that was given earlier in this guide, we can use post as the content type, title as the title field, and body as the content field.

Once you have specified all the values, you can click on the Save Configuration button.

Address

Unit 346, 3/F, Peninsula Centre
67 Mody Road, Tsim Sha Tsui
Kowloon, Hong Kong

Contact

hello@usecloudpress.com

© 2020 Cloudpress Limited. All rights reserved.