Cross-space references
Cross-space references
Cross-space references (formerly known as References across spaces) allow you to link content across multiple spaces. Using cross-space references, you can create reusable content and update multiple spaces with the same piece of content.
To accommodate referencing across multiple spaces, the ResourceLink field type has been added. The ResourceLink field carries references to entities in separate spaces. All ResourceLink fields are configured in the ContentType definitions as usual fields and accept the allowedResources validation rule. This validation restricts the entities that can be linked by the field.
Supported field properties: localized, required, omitted and disabled.
Contentful Resource Names
With cross-space references, the Contentful Resource Name (crn) API identifier is used.
A crn is a formatted string used to describe an object in the API domain. It uses a shared syntax that can be resolved across Contentful services.
Currently, crn is only used in the context of cross-space references to recognize a Contentful space, environment, or entry.
The respective syntax templates are:
crn:contentful:::content:spaces/<:spaceId>
crn:contentful:::content:spaces/<:spaceId>/environments/<:environmentId>
crn:contentful:::content:spaces/<:spaceId>/entries/<:entryId>
crn:contentful:::content:spaces/<:spaceId>/environments/<:environmentId>/entries/<:entryId>
The <:spaceId>, <:environmentId>, and <:entryId> portions must contain standard resource IDs. In the following snippets, the “{crn}” placeholder will be used where one of these is needed.
crn is equivalent to referencing the master environment.Create a content type with a ResourceLink field
To create a content type with a ResourceLink field, use the Create a content type with POST endpoint. The ResourceLink field is set in the request body, see example:
Update a content type with a ResourceLink field
To update a content type with a ResourceLink field, use the Create a content type with PUT endpoint. The ResourceLink field is set in the request body, see example:
Use this endpoint to add a ResourceLink field to a content type or update an existing ResourceLink field.
Allowed resources
The ResourceLink field definition expects an allowedResources array as additional property, restricting which resources can be linked through the field.
Validations
For each field definition property, you can add or remove validations to the fields in the content type schema by specifying the validations property of a field.
Create an entry with a ResourceLink field
To create an entry with a ResourceLink field, use the Create an entry endpoint. The ResourceLink field is set in the request body, see example:
Update an entry with a ResourceLink field
To update an entry with a ResourceLink field, use the Create an entry with ID endpoint. The ResourceLink field is set in the request body, see example: