Account relationships
You can use the PolicyCenter Cloud API to associate accounts with one another. In PolicyCenter, accounts that are associated with one another are referred to as related accounts.
- accountId
- The ID of the account for which you are adding, updating, or deleting the account relationship.
- relationshipType
- The relationship of a related account is identified by one of the following
names and codes:
Name Code Parent of parentChild of childCommon Ownership commonowner - relationshipId
- Each account relationship on an account has a
relationshipIdthat you use to update or delete the relationship. TheGET /accounts/{accountId}/relationshipsendpoint returns therelationshipIdfor existing account relationships.
When you add an account relationship, PolicyCenter updates both accounts with the appropriate relationship. For example, if you add account B with a Child of relationship to account A, PolicyCenter also updates account B to reflect a Parent of relationship to account A.
For more information on related accounts, see Application Guide.
Query account relationships on an account
- GET
/accounts/{accountId}/relationships - GET
/accounts/{accountId}/relationships/{relationshipId}
For example, the following query returns a list of account relationships for account pc:2:
GET /accounts/pc:2/relationships{
"count": 1,
"data": [
{
"attributes": {
"id": "pc:1",
"relatedAccount": {
"displayName": "9736776741",
"id": "pc:68",
"type": "Account",
"uri": "/account/v1/accounts/pc:68"
},
"relationshipType": {
"code": "parent",
"name": "Parent of"
}
},
"checksum": "0",
"links": {
"self": {
"href": "/account/v1/accounts/pc:2/relationships/pc:1",
"methods": [
"delete",
"get",
"patch"
]
}
}
}
],
"links": {
"first": {
"href": "/account/v1/accounts/pc:2/relationships",
"methods": [
"get"
]
},
"self": {
"href": "/account/v1/accounts/pc:2/relationships",
"methods": [
"get"
]
}
}
}In the response, the id pc:1 is the
relationshipId that you can use to update or delete this
particular account relationship.Add an account relationship
- POST
/accounts/{accountId}/relationships
idof therelatedAccountcodeof therelationshipType
For example, the following request adds a common owner relationship between account pc:69 and account pc:2:
POST /accounts/pc:2/relationships{
"data": {
"attributes": {
"relatedAccount": {
"id": "pc:69"
},
"relationshipType": {
"code": "commonowner"
}
}
}
}Update an account relationship
You can update the relationship type of an existing account relationship. However,
you cannot update the account id associated with an existing
account relationship.
- PATCH
/accounts/{accountId}/relationships/{relationshipId}
This endpoint requires the code field of the
relationshipType.
For example, the following request updates the pc:1 relationship on account pc:2 to a parent relationship:
PATCH accounts/pc:2/relationships/pc:1{
"data": {
"attributes": {
"relationshipType": {
"code": "parent"
}
}
}
}{
"data": {
"attributes": {
"id": "pc:1",
"relatedAccount": {
"displayName": "9736776741",
"id": "pc:68",
"type": "Account",
"uri": "/account/v1/accounts/pc:68"
},
"relationshipType": {
"code": "parent",
"name": "Parent of"
}
},
"checksum": "0",
"links": {
"self": {
"href": "/account/v1/accounts/pc:2/relationships/pc:1",
"methods": [
"delete",
"get",
"patch"
]
}
}
}
}
The request also updates account pc:68 to reflect the change in relationship type between it and pc:2
Delete an account relationship
- DELETE
/accounts/{accountId}/relationships/{relationshipId}
For example, the following request deletes account relationship pc:1 from account pc:2:
DELETE /accounts/pc:2/relationships/pc:1This request also deletes account relationship pc:1 from the related account.