Relation service#
Relations between asset types: what each end is called and how many assets each asset relates to. Assets fill a relation in with instances through the asset service.
OpenAPI file: nominal.asset.v2.json
Endpoints#
Batch create relations#
POST /asset/v2/relations/batch-create
Creates relations between asset types, all or none of them. Returns the created relations.
Each relation’s asset types must exist and be unarchived, and all of them must be in one workspace. Two unarchived relations between the same asset types must differ in the name of at least one end, and an asset type can have at most 50 unarchived relations. The caller needs permission to edit the workspace configuration.
Errors:
NOT_FOUND (TypeNotFound): an asset type does not exist or the caller cannot edit its workspace configuration.
INVALID_ARGUMENT (InvalidRelationRequest): a RID is malformed.
INVALID_ARGUMENT (InvalidRelationDefinition): a set end name is blank, a cardinality is invalid, the asset types are in more than one workspace or an asset type is archived, or the relations break an end name or relation count rule.
Body
relationsarray ofRelationDefinitionThe relations to create, all between asset types in one workspace. A rid is ignored. 1 to 50 items.
Fields of
RelationDefinitionridstringAssigned when the relation is created.
leftRelationEndrequired
Fields of
RelationEndtypeRidstringAt least 1 character.
namestringWhat assets of this end’s asset type call the relation, such as “engines” on a plane. Unset leaves the end unnamed. A relation needs names only to tell it apart from another unarchived relation between the same asset types: two such relations must differ in the name of at least one end. Must not be blank when set. 1 to 100 characters.
cardinalityCardinalityrequiredHow many assets of the other end one asset of this end relates to at any instant.
Fields of
Cardinality- one of 5 fields required
rightRelationEndrequired
createdAtstring (date-time) output only
isArchivedboolean output onlySet with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.
Response
relationsarray ofRelationDefinitionThe created relations, in request order.
Fields of
RelationDefinitionridstringAssigned when the relation is created.
leftRelationEnd
Fields of
RelationEndtypeRidstringAt least 1 character.
namestringWhat assets of this end’s asset type call the relation, such as “engines” on a plane. Unset leaves the end unnamed. A relation needs names only to tell it apart from another unarchived relation between the same asset types: two such relations must differ in the name of at least one end. Must not be blank when set. 1 to 100 characters.
cardinalityCardinalityHow many assets of the other end one asset of this end relates to at any instant.
Fields of
Cardinality- one of 5 fields
rightRelationEnd
createdAtstring (date-time)
isArchivedbooleanSet with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.
Request
curl -X POST "https://api.gov.nominal.io/api/asset/v2/relations/batch-create" \
-H "Authorization: Bearer <api key>" \
-H "Content-Type: application/json" \
--data '{
"relations": [
{
"left": {
"cardinality": {
"any": {}
}
},
"right": {
"cardinality": {
"any": {}
}
}
}
]
}'
import requests
response = requests.post(
"https://api.gov.nominal.io/api/asset/v2/relations/batch-create",
headers={"Authorization": "Bearer <api key>"},
json={
"relations": [
{
"left": {"cardinality": {"any": {}}},
"right": {"cardinality": {"any": {}}},
},
],
},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.post(
"https://api.gov.nominal.io/api/asset/v2/relations/batch-create",
headers={"Authorization": "Bearer <api key>"},
json={
"relations": [
{
"left": {"cardinality": {"any": {}}},
"right": {"cardinality": {"any": {}}},
},
],
},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.gov.nominal.io/api/asset/v2/relations/batch-create",
headers={"Authorization": "Bearer <api key>"},
json={
"relations": [
{
"left": {"cardinality": {"any": {}}},
"right": {"cardinality": {"any": {}}},
},
],
},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{
"relations": [
{
"rid": "<rid>",
"left": {
"typeRid": "<type rid>",
"name": "<name>",
"cardinality": {
"any": {}
}
},
"right": {
"typeRid": "<type rid>",
"name": "<name>",
"cardinality": {
"any": {}
}
},
"createdAt": "2026-01-01T00:00:00Z",
"isArchived": true
}
]
}
Search relations#
POST /asset/v2/relations/search
Searches the relations between asset types in one workspace, optionally only those with an end on some asset types. Returns a page of relation definitions with both ends, oldest first.
A workspace the caller cannot view matches no relations. Archived relations are left out unless archived_statuses includes them. An asset type has at most 50 unarchived relations, so the relations of a few asset types usually fit one page.
Errors:
INVALID_ARGUMENT (InvalidRelationRequest): page_token is not a token from a previous response, or a RID is malformed.
Body
workspacestringAt least 1 character.
typeRidsarray of stringLimits the results to relations with an end on one of these asset types. Empty returns every relation in the workspace. An asset type outside the workspace matches nothing. At most 100 items.
archivedStatusesarray ofArchivedStatusWhich relations to return by archived status. Empty returns unarchived relations only.
Values of
ArchivedStatusARCHIVED_STATUS_UNSPECIFIED
NOT_ARCHIVEDThe resource is not archived.
ARCHIVEDThe resource is archived.
pageSizeintegerDefaults to 100. From 1 to 1,000.
pageTokenstring
Response
relationsarray ofRelationDefinitionOldest first, then by rid.
Fields of
RelationDefinitionridstringAssigned when the relation is created.
leftRelationEnd
Fields of
RelationEndtypeRidstringAt least 1 character.
namestringWhat assets of this end’s asset type call the relation, such as “engines” on a plane. Unset leaves the end unnamed. A relation needs names only to tell it apart from another unarchived relation between the same asset types: two such relations must differ in the name of at least one end. Must not be blank when set. 1 to 100 characters.
cardinalityCardinalityHow many assets of the other end one asset of this end relates to at any instant.
Fields of
Cardinality- one of 5 fields
rightRelationEnd
createdAtstring (date-time)
isArchivedbooleanSet with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.
nextPageTokenstringPresent while more relations may follow.
Request
curl -X POST "https://api.gov.nominal.io/api/asset/v2/relations/search" \
-H "Authorization: Bearer <api key>" \
-H "Content-Type: application/json" \
--data '{
"workspace": "<workspace>",
"typeRids": [
"<type rids>"
],
"archivedStatuses": [
"NOT_ARCHIVED"
],
"pageSize": 1,
"pageToken": "<page token>"
}'
import requests
response = requests.post(
"https://api.gov.nominal.io/api/asset/v2/relations/search",
headers={"Authorization": "Bearer <api key>"},
json={
"workspace": "<workspace>",
"typeRids": ["<type rids>"],
"archivedStatuses": ["NOT_ARCHIVED"],
"pageSize": 1,
"pageToken": "<page token>",
},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.post(
"https://api.gov.nominal.io/api/asset/v2/relations/search",
headers={"Authorization": "Bearer <api key>"},
json={
"workspace": "<workspace>",
"typeRids": ["<type rids>"],
"archivedStatuses": ["NOT_ARCHIVED"],
"pageSize": 1,
"pageToken": "<page token>",
},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.gov.nominal.io/api/asset/v2/relations/search",
headers={"Authorization": "Bearer <api key>"},
json={
"workspace": "<workspace>",
"typeRids": ["<type rids>"],
"archivedStatuses": ["NOT_ARCHIVED"],
"pageSize": 1,
"pageToken": "<page token>",
},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{
"relations": [
{
"rid": "<rid>",
"left": {
"typeRid": "<type rid>",
"name": "<name>",
"cardinality": {
"any": {}
}
},
"right": {
"typeRid": "<type rid>",
"name": "<name>",
"cardinality": {
"any": {}
}
},
"createdAt": "2026-01-01T00:00:00Z",
"isArchived": true
}
],
"nextPageToken": "<next page token>"
}
Update relation#
PATCH /asset/v2/relations/{relation.rid}
Sets a relation’s end names and cardinalities. Returns the updated relation.
A relation’s asset types never change. A cardinality can always be loosened, but only tightened while the relation has no instances. An archived relation, or one with an end on an archived asset type, cannot change until it or its asset type is unarchived. The caller needs permission to edit the workspace configuration.
Errors:
NOT_FOUND (RelationNotFound): the relation does not exist or the caller cannot edit its workspace configuration.
INVALID_ARGUMENT (InvalidRelationRequest): the rid is missing or a RID is malformed.
INVALID_ARGUMENT (InvalidRelationDefinition): a set end name is blank, a cardinality is invalid, an asset type differs from the relation’s, the relation or one of its asset types is archived, a cardinality is tightened while the relation has instances, or the new end names match another relation between the same asset types.
Path parameters
relation.ridstring requiredAssigned when the relation is created.
Body
leftRelationEnd
Fields of
RelationEndtypeRidstringAt least 1 character.
namestringWhat assets of this end’s asset type call the relation, such as “engines” on a plane. Unset leaves the end unnamed. A relation needs names only to tell it apart from another unarchived relation between the same asset types: two such relations must differ in the name of at least one end. Must not be blank when set. 1 to 100 characters.
cardinalityCardinalityrequiredHow many assets of the other end one asset of this end relates to at any instant.
Fields of
Cardinality- one of 5 fields required
rightRelationEnd
createdAtstring (date-time) output only
isArchivedboolean output onlySet with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.
Response
relationRelationDefinition
Fields of
RelationDefinitionridstringAssigned when the relation is created.
leftRelationEnd
Fields of
RelationEndtypeRidstringAt least 1 character.
namestringWhat assets of this end’s asset type call the relation, such as “engines” on a plane. Unset leaves the end unnamed. A relation needs names only to tell it apart from another unarchived relation between the same asset types: two such relations must differ in the name of at least one end. Must not be blank when set. 1 to 100 characters.
cardinalityCardinalityHow many assets of the other end one asset of this end relates to at any instant.
Fields of
Cardinality- one of 5 fields
rightRelationEnd
createdAtstring (date-time)
isArchivedbooleanSet with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.
Request
curl -X PATCH "https://api.gov.nominal.io/api/asset/v2/relations/<relation.rid>" \
-H "Authorization: Bearer <api key>" \
-H "Content-Type: application/json" \
--data '{
"left": {
"cardinality": {
"any": {}
}
},
"right": {
"cardinality": {
"any": {}
}
}
}'
import requests
response = requests.patch(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation.rid>",
headers={"Authorization": "Bearer <api key>"},
json={"left": {"cardinality": {"any": {}}}, "right": {"cardinality": {"any": {}}}},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.patch(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation.rid>",
headers={"Authorization": "Bearer <api key>"},
json={"left": {"cardinality": {"any": {}}}, "right": {"cardinality": {"any": {}}}},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.patch(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation.rid>",
headers={"Authorization": "Bearer <api key>"},
json={
"left": {"cardinality": {"any": {}}},
"right": {"cardinality": {"any": {}}},
},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{
"relation": {
"rid": "<rid>",
"left": {
"typeRid": "<type rid>",
"name": "<name>",
"cardinality": {
"any": {}
}
},
"right": {
"typeRid": "<type rid>",
"name": "<name>",
"cardinality": {
"any": {}
}
},
"createdAt": "2026-01-01T00:00:00Z",
"isArchived": true
}
}
Delete relation#
DELETE /asset/v2/relations/{relationRid}
Deletes a relation and all of its instances, archived or not. The caller needs permission to edit the workspace configuration.
Errors:
NOT_FOUND (RelationNotFound): the relation does not exist or the caller cannot edit its workspace configuration.
Path parameters
relationRidstring required
Response
An empty JSON object, {}.
Request
curl -X DELETE "https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>" \
-H "Authorization: Bearer <api key>"
import requests
response = requests.delete(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.delete(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.delete(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>",
headers={"Authorization": "Bearer <api key>"},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{}
Archive relation#
POST /asset/v2/relations/{relationRid}/archive
Archives a relation. Its instances stay, but asset writes can no longer change them.
An archived relation does not count toward the 50-relation limit or end name uniqueness, cannot be updated, and is skipped by SearchRelations unless asked. Reverse it with UnarchiveRelation. Archiving an archived relation does nothing. The caller needs permission to edit the workspace configuration.
Errors:
NOT_FOUND (RelationNotFound): the relation does not exist or the caller cannot edit its workspace configuration.
Path parameters
relationRidstring required
Response
An empty JSON object, {}.
Request
curl -X POST "https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/archive" \
-H "Authorization: Bearer <api key>"
import requests
response = requests.post(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/archive",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.post(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/archive",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/archive",
headers={"Authorization": "Bearer <api key>"},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{}
Unarchive relation#
POST /asset/v2/relations/{relationRid}/unarchive
Unarchives a relation, so asset writes can change its instances again.
The relation’s end names must still be unique on each of its asset types, and each of them must stay within 50 relations. Unarchiving an unarchived relation does nothing. The caller needs permission to edit the workspace configuration.
Errors:
NOT_FOUND (RelationNotFound): the relation does not exist or the caller cannot edit its workspace configuration.
FAILED_PRECONDITION (RelationCannotBeUnarchived): an end name is now taken on its asset type, or an asset type already has 50 relations.
Path parameters
relationRidstring required
Response
An empty JSON object, {}.
Request
curl -X POST "https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/unarchive" \
-H "Authorization: Bearer <api key>"
import requests
response = requests.post(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/unarchive",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.post(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/unarchive",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/unarchive",
headers={"Authorization": "Bearer <api key>"},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{}
Errors#
Errors shows how these errors are sent.
Each error’s errorName is NominalAssetV2: followed by its name below.
Status |
Name |
Notes |
|---|---|---|
400 |
|
RelationCountViolated |
400 |
|
RelationInstancesOverlap |
400 |
|
InvalidRelationDefinition |
400 |
|
InvalidRelationRequest |
400 |
|
TooManyRelationInstances |
404 |
|
RelationNotFound |
500 |
|
RelationArchived |
500 |
|
RelationCannotBeUnarchived |
Types#
Any#
Any count, including none.
An empty JSON object, {}.
ArchivedStatus#
Whether a resource is archived. A search uses it to choose which resources to return.
ARCHIVED_STATUS_UNSPECIFIED
NOT_ARCHIVEDThe resource is not archived.
ARCHIVEDThe resource is archived.
AtLeast#
minintegerAt least 0.
AtMost#
maxintegerAt least 1.
Cardinality#
An inclusive bound on a count. Responses use the narrowest kind that states the bound. Clients should treat an unset oneof as a bound they cannot display: it is a kind added after the client was built.
Set exactly one of the fields below.
- one of 5 fields required
Exactly#
countintegerAt least 1.
Range#
minintegerAt least 0.
maxintegerAt least min, and at least 1. At least 1.
RelationDefinition#
A relation between assets of two asset types, such as the engines of a plane. Both asset types are in one workspace, and deleting either of them deletes the relation. An asset type can relate to itself. Which end is left only names the end.
ridstringAssigned when the relation is created.
leftRelationEndrequired
rightRelationEndrequired
createdAtstring (date-time) output only
isArchivedboolean output onlySet with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.
RelationEnd#
typeRidstringAt least 1 character.
namestringWhat assets of this end’s asset type call the relation, such as “engines” on a plane. Unset leaves the end unnamed. A relation needs names only to tell it apart from another unarchived relation between the same asset types: two such relations must differ in the name of at least one end. Must not be blank when set. 1 to 100 characters.
cardinalityCardinalityrequiredHow many assets of the other end one asset of this end relates to at any instant.
Page design based on Scalar, MIT License.