Relation service (gRPC)#

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.

Endpoints#

Archive relation#

gRPC /nominal.asset.v2.RelationService/ArchiveRelation

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.

Request: ArchiveRelationRequest

relation_rid string

​

Response: ArchiveRelationResponse

A message with no fields.

Request

import grpc
from nominal.protos.asset.v2 import relation_pb2, relation_pb2_grpc

channel = grpc.secure_channel("api.gov.nominal.io:443", grpc.ssl_channel_credentials())
relation_service = relation_pb2_grpc.RelationServiceStub(channel)
auth = [("authorization", "Bearer <api key>")]

request = relation_pb2.ArchiveRelationRequest(relation_rid="<relation rid>")
response = relation_service.ArchiveRelation(request, metadata=auth)
print(response)

Response

{}

Batch create relations#

gRPC /nominal.asset.v2.RelationService/BatchCreateRelations

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.

Request: BatchCreateRelationsRequest

relations array of RelationDefinition

The relations to create, all between asset types in one workspace. A rid is ignored. 1 to 50 items.

Fields of RelationDefinition
rid string

Assigned when the relation is created.

left RelationEnd required

​

Fields of RelationEnd
type_rid string

At least 1 character.

name string

What 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.

cardinality Cardinality required

How many assets of the other end one asset of this end relates to at any instant.

Fields of Cardinality
one of 5 fields required

​

any Any

​

exactly Exactly

​

Fields of Exactly
count integer

At least 1.

range Range

​

Fields of Range
min integer

At least 0.

max integer

At least min, and at least 1. At least 1.

at_least AtLeast

​

Fields of AtLeast
min integer

At least 0.

at_most AtMost

​

Fields of AtMost
max integer

At least 1.

right RelationEnd required

​

created_at string (date-time) output only

​

is_archived boolean output only

Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

Response: BatchCreateRelationsResponse

relations array of RelationDefinition

The created relations, in request order.

Fields of RelationDefinition
rid string

Assigned when the relation is created.

left RelationEnd

​

Fields of RelationEnd
type_rid string

At least 1 character.

name string

What 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.

cardinality Cardinality

How many assets of the other end one asset of this end relates to at any instant.

Fields of Cardinality
one of 5 fields

​

any Any

​

exactly Exactly

​

Fields of Exactly
count integer

At least 1.

range Range

​

Fields of Range
min integer

At least 0.

max integer

At least min, and at least 1. At least 1.

at_least AtLeast

​

Fields of AtLeast
min integer

At least 0.

at_most AtMost

​

Fields of AtMost
max integer

At least 1.

right RelationEnd

​

created_at string (date-time)

​

is_archived boolean

Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

Request

import grpc
from nominal.protos.asset.v2 import relation_pb2, relation_pb2_grpc

channel = grpc.secure_channel("api.gov.nominal.io:443", grpc.ssl_channel_credentials())
relation_service = relation_pb2_grpc.RelationServiceStub(channel)
auth = [("authorization", "Bearer <api key>")]

request = relation_pb2.BatchCreateRelationsRequest(
    relations=[
        {"left": {"cardinality": {"any": {}}}, "right": {"cardinality": {"any": {}}}},
    ],
)
response = relation_service.BatchCreateRelations(request, metadata=auth)
print(response)

Response

{
  "relations": [
    {
      "rid": "<rid>",
      "left": {
        "type_rid": "<type rid>",
        "name": "<name>",
        "cardinality": {
          "any": {}
        }
      },
      "right": {
        "type_rid": "<type rid>",
        "name": "<name>",
        "cardinality": {
          "any": {}
        }
      },
      "created_at": "2026-01-01T00:00:00Z",
      "is_archived": true
    }
  ]
}

Delete relation#

gRPC /nominal.asset.v2.RelationService/DeleteRelation

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.

Request: DeleteRelationRequest

relation_rid string

​

Response: DeleteRelationResponse

A message with no fields.

Request

import grpc
from nominal.protos.asset.v2 import relation_pb2, relation_pb2_grpc

channel = grpc.secure_channel("api.gov.nominal.io:443", grpc.ssl_channel_credentials())
relation_service = relation_pb2_grpc.RelationServiceStub(channel)
auth = [("authorization", "Bearer <api key>")]

request = relation_pb2.DeleteRelationRequest(relation_rid="<relation rid>")
response = relation_service.DeleteRelation(request, metadata=auth)
print(response)

Response

{}

Search relations#

gRPC /nominal.asset.v2.RelationService/SearchRelations

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.

Request: SearchRelationsRequest

workspace string

At least 1 character.

type_rids array of string

Limits 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.

archived_statuses array of ArchivedStatus

Which relations to return by archived status. Empty returns unarchived relations only.

Values of ArchivedStatus
ARCHIVED_STATUS_UNSPECIFIED

​

NOT_ARCHIVED

The resource is not archived.

ARCHIVED

The resource is archived.

page_size integer

Defaults to 100. From 1 to 1,000.

page_token string

​

Response: SearchRelationsResponse

relations array of RelationDefinition

Oldest first, then by rid.

Fields of RelationDefinition
rid string

Assigned when the relation is created.

left RelationEnd

​

Fields of RelationEnd
type_rid string

At least 1 character.

name string

What 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.

cardinality Cardinality

How many assets of the other end one asset of this end relates to at any instant.

Fields of Cardinality
one of 5 fields

​

any Any

​

exactly Exactly

​

Fields of Exactly
count integer

At least 1.

range Range

​

Fields of Range
min integer

At least 0.

max integer

At least min, and at least 1. At least 1.

at_least AtLeast

​

Fields of AtLeast
min integer

At least 0.

at_most AtMost

​

Fields of AtMost
max integer

At least 1.

right RelationEnd

​

created_at string (date-time)

​

is_archived boolean

Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

next_page_token string

Present while more relations may follow.

Request

import grpc
from nominal.protos.asset.v2 import relation_pb2, relation_pb2_grpc

channel = grpc.secure_channel("api.gov.nominal.io:443", grpc.ssl_channel_credentials())
relation_service = relation_pb2_grpc.RelationServiceStub(channel)
auth = [("authorization", "Bearer <api key>")]

request = relation_pb2.SearchRelationsRequest(
    workspace="<workspace>",
    type_rids=["<type rids>"],
    archived_statuses=["NOT_ARCHIVED"],
    page_size=1,
    page_token="<page token>",
)
response = relation_service.SearchRelations(request, metadata=auth)
print(response)

Response

{
  "relations": [
    {
      "rid": "<rid>",
      "left": {
        "type_rid": "<type rid>",
        "name": "<name>",
        "cardinality": {
          "any": {}
        }
      },
      "right": {
        "type_rid": "<type rid>",
        "name": "<name>",
        "cardinality": {
          "any": {}
        }
      },
      "created_at": "2026-01-01T00:00:00Z",
      "is_archived": true
    }
  ],
  "next_page_token": "<next page token>"
}

Unarchive relation#

gRPC /nominal.asset.v2.RelationService/UnarchiveRelation

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.

Request: UnarchiveRelationRequest

relation_rid string

​

Response: UnarchiveRelationResponse

A message with no fields.

Request

import grpc
from nominal.protos.asset.v2 import relation_pb2, relation_pb2_grpc

channel = grpc.secure_channel("api.gov.nominal.io:443", grpc.ssl_channel_credentials())
relation_service = relation_pb2_grpc.RelationServiceStub(channel)
auth = [("authorization", "Bearer <api key>")]

request = relation_pb2.UnarchiveRelationRequest(relation_rid="<relation rid>")
response = relation_service.UnarchiveRelation(request, metadata=auth)
print(response)

Response

{}

Update relation#

gRPC /nominal.asset.v2.RelationService/UpdateRelation

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.

Request: UpdateRelationRequest

relation RelationDefinition required

The relation to update, picked by its rid, with its end names and cardinalities as they should be. Its asset types must be the ones it already has, at the same ends.

Fields of RelationDefinition
rid string

Assigned when the relation is created.

left RelationEnd required

​

Fields of RelationEnd
type_rid string

At least 1 character.

name string

What 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.

cardinality Cardinality required

How many assets of the other end one asset of this end relates to at any instant.

Fields of Cardinality
one of 5 fields required

​

any Any

​

exactly Exactly

​

Fields of Exactly
count integer

At least 1.

range Range

​

Fields of Range
min integer

At least 0.

max integer

At least min, and at least 1. At least 1.

at_least AtLeast

​

Fields of AtLeast
min integer

At least 0.

at_most AtMost

​

Fields of AtMost
max integer

At least 1.

right RelationEnd required

​

created_at string (date-time) output only

​

is_archived boolean output only

Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

Response: UpdateRelationResponse

relation RelationDefinition

​

Fields of RelationDefinition
rid string

Assigned when the relation is created.

left RelationEnd

​

Fields of RelationEnd
type_rid string

At least 1 character.

name string

What 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.

cardinality Cardinality

How many assets of the other end one asset of this end relates to at any instant.

Fields of Cardinality
one of 5 fields

​

any Any

​

exactly Exactly

​

Fields of Exactly
count integer

At least 1.

range Range

​

Fields of Range
min integer

At least 0.

max integer

At least min, and at least 1. At least 1.

at_least AtLeast

​

Fields of AtLeast
min integer

At least 0.

at_most AtMost

​

Fields of AtMost
max integer

At least 1.

right RelationEnd

​

created_at string (date-time)

​

is_archived boolean

Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

Request

import grpc
from nominal.protos.asset.v2 import relation_pb2, relation_pb2_grpc

channel = grpc.secure_channel("api.gov.nominal.io:443", grpc.ssl_channel_credentials())
relation_service = relation_pb2_grpc.RelationServiceStub(channel)
auth = [("authorization", "Bearer <api key>")]

request = relation_pb2.UpdateRelationRequest(
    relation={
        "left": {"cardinality": {"any": {}}},
        "right": {"cardinality": {"any": {}}},
    },
)
response = relation_service.UpdateRelation(request, metadata=auth)
print(response)

Response

{
  "relation": {
    "rid": "<rid>",
    "left": {
      "type_rid": "<type rid>",
      "name": "<name>",
      "cardinality": {
        "any": {}
      }
    },
    "right": {
      "type_rid": "<type rid>",
      "name": "<name>",
      "cardinality": {
        "any": {}
      }
    },
    "created_at": "2026-01-01T00:00:00Z",
    "is_archived": true
  }
}

Errors#

Errors shows how these errors are sent.

Code

Reason

Message

INVALID_ARGUMENT

RELATION_ERROR_COUNT_VIOLATED

RelationCountViolated

INVALID_ARGUMENT

RELATION_ERROR_INSTANCES_OVERLAP

RelationInstancesOverlap

INVALID_ARGUMENT

RELATION_ERROR_INVALID_DEFINITION

InvalidRelationDefinition

INVALID_ARGUMENT

RELATION_ERROR_INVALID_REQUEST

InvalidRelationRequest

INVALID_ARGUMENT

RELATION_ERROR_TOO_MANY_INSTANCES

TooManyRelationInstances

NOT_FOUND

RELATION_ERROR_NOT_FOUND

RelationNotFound

FAILED_PRECONDITION

RELATION_ERROR_ARCHIVED

RelationArchived

FAILED_PRECONDITION

RELATION_ERROR_CANNOT_UNARCHIVE

RelationCannotBeUnarchived

Types#

Any#

Any count, including none.

A message with no fields.

ArchivedStatus#

Whether a resource is archived. A search uses it to choose which resources to return.

ARCHIVED_STATUS_UNSPECIFIED

​

NOT_ARCHIVED

The resource is not archived.

ARCHIVED

The resource is archived.

AtLeast#

min integer

At least 0.

AtMost#

max integer

At 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

​

any Any

​

exactly Exactly

​

range Range

​

at_least AtLeast

​

at_most AtMost

​

Exactly#

count integer

At least 1.

Range#

min integer

At least 0.

max integer

At 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.

rid string

Assigned when the relation is created.

left RelationEnd required

​

right RelationEnd required

​

created_at string (date-time) output only

​

is_archived boolean output only

Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

RelationEnd#

type_rid string

At least 1 character.

name string

What 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.

cardinality Cardinality required

How many assets of the other end one asset of this end relates to at any instant.

Page design based on Scalar, MIT License.