Documentation Archive

Developer

CloudKit Web Services Reference

On This Page

Referencing Existing Assets (assets/rereference)

You can add another reference to an existing asset.

Path

POST [path]/database/[version]/[container]/[environment]/[database]/assets/rereference

Parameters

path

The URL to the CloudKit web service, which is https://api.apple-cloudkit.com.

version

The protocol version—currently, 1.

container

A unique identifier for the app’s container. The container ID begins with iCloud..

environment

The version of the app’s container. Pass development to use the environment that is not accessible by apps available on the store. Pass production to use the environment that is accessible by development apps and apps available on the store.

database

The database to store the data within the container. Pass public to use the database that is accessible to all users of the app. Pass private to use the database that is visible only to the currently signed-in user.

Request

The POST request is a JSON dictionary containing the following keys:

Key

Description

zoneID

Dictionary that identifies a record zone in the database, described in Zone ID Dictionary.

assets

Array of asset fields, described in Assets Field Dictionary, to fetch. This key is required.

Assets Field Dictionary

Dictionary that identifies a field of type Asset in a record.

Key

Description

recordName

The unique name used to identify the record within a zone. The default value is a random UUID. This key is required.

fieldName

The name of a field belonging to the record type. This key is required.

Response

The response contains an array of asset value dictionaries, described in Asset Dictionary. There’s one asset value for each asset field in the request.

Discussion

Request an existing asset if you want to use it in another record. This request returns asset values that you can use to set asset fields in other records. Assets are deleted only when all references to it are removed.