Relationships in the Reactor API
Resources in the Reactor API are often related to each other. This document provides an overview of how resource relationships are established in the API, and the relationship requirements of each resource type.
Depending on the type of resource in question, some relationships are required. A required relationship implies that the parent resource cannot exist without the relationship. All other relationships are optional.
Regardless of whether they are required or optional, relationships are either automatically established by the system when relevant resources are created, or they must be created manually. In the case of creating relationships manually, there are two possible methods depending on the resource in question:
- Create by payload
- Create by URL (for libraries only)
Refer to the section on relationship requirements for a list of the compatible relationships for each resource type, and the methods required to establish those relationships where applicable.
Create a relationship by payload payload
Some relationships must be manually established when you initially create a resource. To accomplish this, you must provide a relationship object in the request payload when you first create the parent resource. Examples of these relationships include:
- Creating a data element with the required extensions
- Creating an environment with the required host relationship
API format
POST /properties/{PROPERTY_ID}/{RESOURCE_TYPE}
{PROPERTY_ID}{RESOURCE_TYPE}Request
The following request creates a new rule_component, establishing relationships with rules and an extension.
curl -X POST \
https://reactor.adobe.io/properties/PRf606dbddfbdc44f580fc6f342b5ff9be/rule_components \
-H 'Authorization: Bearer [TOKEN]' \
-H 'x-api-key: [KEY]' \
-H 'x-gw-ims-org-id: [ORG_ID]' \
-H 'Accept: application/vnd.api+json;revision=1' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"attributes": {
"delegate_descriptor_id": "kessel-test::events::click",
"name": "My Example Click Event",
"settings": "{\"elementSelector\":\".accordion\",\"bubbleFireIfChildFired\":true}"
},
"relationships": {
"extension": {
"data": {
"id": "EXa2865f4d14204fa094f247406424371b",
"type": "extensions"
}
},
"rules": {
"data": [
{
"id": "RLd53598e3f1884e63bbc8e9c95e463dcf",
"type": "rules"
}
]
}
},
"type": "rule_components"
}
}'
relationshipsextension and rules relationships are established, which are particular to rule_components. For more information on compatible relationship types for different resources, see the section on relationship requirements by resource.datarelationship object must contain a data property, which references the id and type of the resource a relationship is being established with. You can create a relationship with multiple resources of the same type by formatting the data property as an array of objects, with each object containing the id and type of an applicable resource.idid must be accompanied with a sibling type property, indicating the type of resource in question.typeid field. Accepted values include data_elements, rules, extensions, and environments.Create a relationship by URL url
Unlike other resources, libraries establish relationships through their own dedicated /relationship endpoints. Examples include:
API format
POST /properties/{PROPERTY_ID}/libraries/{LIBRARY_ID}/relationships/{RESOURCE_TYPE}
{PROPERTY_ID}{LIBRARY_ID}{RESOURCE_TYPE}environment, data_elements, extensions, and rules.Request
The following request uses the /relationships/environment endpoint for a library to create a relationship with an environment.
curl -X POST \
https://reactor.adobe.io/properties/PRf606dbddfbdc44f580fc6f342b5ff9be/libraries/LB10c1fd171cd347f19fcb8659a8d679ef/relationships/environment \
-H 'Authorization: Bearer [TOKEN]' \
-H 'x-api-key: [KEY]' \
-H 'x-gw-ims-org-id: [ORG_ID]' \
-H 'Accept: application/vnd.api+json;revision=1' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"id": "ENf395a477d2b24ad696d65b901055b9dc",
"type": "environments",
}
}'
dataid and type of the target resource for the relationship. If you are creating a relationship with multiple resources of the same type (such as extensions and rules), the data property must be formatted as an array of objects, with each object containing the id and type of an applicable resource.idid must be accompanied with a sibling type property, indicating the type of resource in question.typeid field. Accepted values include data_elements, rules, extensions, and environments.Relationship requirements by resource requirements
The following tables outline the available relationships for each resource type, whether or not those relationships are required, and the accepted method to manually create the relationship where applicable.
Audit events
propertyentityBuilds
data_elementsextensionsrulesenvironmentlibrarypropertyCallbacks
propertyCompanies
propertiesData elements
librariesrevisionsnotespropertyoriginextensionupdated_with_extensionupdated_with_extension_packageEnvironments
librarybuildshostpropertyExtensions
librariesrevisionsnotespropertyoriginextension_packageupdated_with_extension_packageHosts
propertyLibraries
buildsenvironmentdata_elementsextensionsrulesnotesupstream_librarypropertylast_buildNotes
resourceProperties
companycallbacksenvironmentslibrariesdata_elementsextensionsextensionsRule components
updated_with_extensions_packageupdated_with_extensionextensionnotesoriginpropertyrulesrevisionsRules
librariesrevisionsnotespropertyoriginrule_componentsSecrets
propertyenvironment