# 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`](https://dev.nominal.io/api/_downloads/02a867e700d599b8b6edd938681dead7/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

`relations` array of [`RelationDefinition`](https://dev.nominal.io/api/rest/relation-service.md#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`](https://dev.nominal.io/api/rest/relation-service.md#relationend) required
    :   ​

        Fields of `RelationEnd`

        `typeRid` 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`](https://dev.nominal.io/api/rest/relation-service.md#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` [`Any`](https://dev.nominal.io/api/rest/relation-service.md#any)
                :   ​

                **exactly**

                `exactly` [`Exactly`](https://dev.nominal.io/api/rest/relation-service.md#exactly)
                :   ​

                    Fields of `Exactly`

                    `count` integer
                    :   At least 1.

                **range**

                `range` [`Range`](https://dev.nominal.io/api/rest/relation-service.md#range)
                :   ​

                    Fields of `Range`

                    `min` integer
                    :   At least 0.

                    `max` integer
                    :   At least min, and at least 1. At least 1.

                **atLeast**

                `atLeast` [`AtLeast`](https://dev.nominal.io/api/rest/relation-service.md#atleast)
                :   ​

                    Fields of `AtLeast`

                    `min` integer
                    :   At least 0.

                **atMost**

                `atMost` [`AtMost`](https://dev.nominal.io/api/rest/relation-service.md#atmost)
                :   ​

                    Fields of `AtMost`

                    `max` integer
                    :   At least 1.

    `right` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend) required
    :   ​

    `createdAt` string (date-time) output only
    :   ​

    `isArchived` boolean output only
    :   Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

Response

`relations` array of [`RelationDefinition`](https://dev.nominal.io/api/rest/relation-service.md#relationdefinition)
:   The created relations, in request order.

    Fields of `RelationDefinition`

    `rid` string
    :   Assigned when the relation is created.

    `left` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
    :   ​

        Fields of `RelationEnd`

        `typeRid` 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`](https://dev.nominal.io/api/rest/relation-service.md#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` [`Any`](https://dev.nominal.io/api/rest/relation-service.md#any)
                :   ​

                **exactly**

                `exactly` [`Exactly`](https://dev.nominal.io/api/rest/relation-service.md#exactly)
                :   ​

                    Fields of `Exactly`

                    `count` integer
                    :   At least 1.

                **range**

                `range` [`Range`](https://dev.nominal.io/api/rest/relation-service.md#range)
                :   ​

                    Fields of `Range`

                    `min` integer
                    :   At least 0.

                    `max` integer
                    :   At least min, and at least 1. At least 1.

                **atLeast**

                `atLeast` [`AtLeast`](https://dev.nominal.io/api/rest/relation-service.md#atleast)
                :   ​

                    Fields of `AtLeast`

                    `min` integer
                    :   At least 0.

                **atMost**

                `atMost` [`AtMost`](https://dev.nominal.io/api/rest/relation-service.md#atmost)
                :   ​

                    Fields of `AtMost`

                    `max` integer
                    :   At least 1.

    `right` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
    :   ​

    `createdAt` string (date-time)
    :   ​

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

Request

**curl**

```shell
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": {}
        }
      }
    }
  ]
}'
```

**requests**

```python
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())
```

**httpx**

```python
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())
```

**aiohttp**

```python
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`

```json
{
  "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

`workspace` string
:   At least 1 character.

`typeRids` 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.

`archivedStatuses` array of [`ArchivedStatus`](https://dev.nominal.io/api/rest/relation-service.md#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.

`pageSize` integer
:   Defaults to 100. From 1 to 1,000.

`pageToken` string
:   ​

Response

`relations` array of [`RelationDefinition`](https://dev.nominal.io/api/rest/relation-service.md#relationdefinition)
:   Oldest first, then by rid.

    Fields of `RelationDefinition`

    `rid` string
    :   Assigned when the relation is created.

    `left` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
    :   ​

        Fields of `RelationEnd`

        `typeRid` 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`](https://dev.nominal.io/api/rest/relation-service.md#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` [`Any`](https://dev.nominal.io/api/rest/relation-service.md#any)
                :   ​

                **exactly**

                `exactly` [`Exactly`](https://dev.nominal.io/api/rest/relation-service.md#exactly)
                :   ​

                    Fields of `Exactly`

                    `count` integer
                    :   At least 1.

                **range**

                `range` [`Range`](https://dev.nominal.io/api/rest/relation-service.md#range)
                :   ​

                    Fields of `Range`

                    `min` integer
                    :   At least 0.

                    `max` integer
                    :   At least min, and at least 1. At least 1.

                **atLeast**

                `atLeast` [`AtLeast`](https://dev.nominal.io/api/rest/relation-service.md#atleast)
                :   ​

                    Fields of `AtLeast`

                    `min` integer
                    :   At least 0.

                **atMost**

                `atMost` [`AtMost`](https://dev.nominal.io/api/rest/relation-service.md#atmost)
                :   ​

                    Fields of `AtMost`

                    `max` integer
                    :   At least 1.

    `right` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
    :   ​

    `createdAt` string (date-time)
    :   ​

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

`nextPageToken` string
:   Present while more relations may follow.

Request

**curl**

```shell
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>"
}'
```

**requests**

```python
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())
```

**httpx**

```python
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())
```

**aiohttp**

```python
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`

```json
{
  "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.rid` string required
:   Assigned when the relation is created.

Body

`left` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
:   ​

    Fields of `RelationEnd`

    `typeRid` 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`](https://dev.nominal.io/api/rest/relation-service.md#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` [`Any`](https://dev.nominal.io/api/rest/relation-service.md#any)
            :   ​

            **exactly**

            `exactly` [`Exactly`](https://dev.nominal.io/api/rest/relation-service.md#exactly)
            :   ​

                Fields of `Exactly`

                `count` integer
                :   At least 1.

            **range**

            `range` [`Range`](https://dev.nominal.io/api/rest/relation-service.md#range)
            :   ​

                Fields of `Range`

                `min` integer
                :   At least 0.

                `max` integer
                :   At least min, and at least 1. At least 1.

            **atLeast**

            `atLeast` [`AtLeast`](https://dev.nominal.io/api/rest/relation-service.md#atleast)
            :   ​

                Fields of `AtLeast`

                `min` integer
                :   At least 0.

            **atMost**

            `atMost` [`AtMost`](https://dev.nominal.io/api/rest/relation-service.md#atmost)
            :   ​

                Fields of `AtMost`

                `max` integer
                :   At least 1.

`right` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
:   ​

`createdAt` string (date-time) output only
:   ​

`isArchived` boolean output only
:   Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

Response

`relation` [`RelationDefinition`](https://dev.nominal.io/api/rest/relation-service.md#relationdefinition)
:   ​

    Fields of `RelationDefinition`

    `rid` string
    :   Assigned when the relation is created.

    `left` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
    :   ​

        Fields of `RelationEnd`

        `typeRid` 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`](https://dev.nominal.io/api/rest/relation-service.md#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` [`Any`](https://dev.nominal.io/api/rest/relation-service.md#any)
                :   ​

                **exactly**

                `exactly` [`Exactly`](https://dev.nominal.io/api/rest/relation-service.md#exactly)
                :   ​

                    Fields of `Exactly`

                    `count` integer
                    :   At least 1.

                **range**

                `range` [`Range`](https://dev.nominal.io/api/rest/relation-service.md#range)
                :   ​

                    Fields of `Range`

                    `min` integer
                    :   At least 0.

                    `max` integer
                    :   At least min, and at least 1. At least 1.

                **atLeast**

                `atLeast` [`AtLeast`](https://dev.nominal.io/api/rest/relation-service.md#atleast)
                :   ​

                    Fields of `AtLeast`

                    `min` integer
                    :   At least 0.

                **atMost**

                `atMost` [`AtMost`](https://dev.nominal.io/api/rest/relation-service.md#atmost)
                :   ​

                    Fields of `AtMost`

                    `max` integer
                    :   At least 1.

    `right` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend)
    :   ​

    `createdAt` string (date-time)
    :   ​

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

Request

**curl**

```shell
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": {}
    }
  }
}'
```

**requests**

```python
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())
```

**httpx**

```python
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())
```

**aiohttp**

```python
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`

```json
{
  "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

`relationRid` string required
:   ​

Response

An empty JSON object, `{}`.

Request

**curl**

```shell
curl -X DELETE "https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>" \
  -H "Authorization: Bearer <api key>"
```

**requests**

```python
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())
```

**httpx**

```python
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())
```

**aiohttp**

```python
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`

```json
{}
```

### 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

`relationRid` string required
:   ​

Response

An empty JSON object, `{}`.

Request

**curl**

```shell
curl -X POST "https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/archive" \
  -H "Authorization: Bearer <api key>"
```

**requests**

```python
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())
```

**httpx**

```python
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())
```

**aiohttp**

```python
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`

```json
{}
```

### 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

`relationRid` string required
:   ​

Response

An empty JSON object, `{}`.

Request

**curl**

```shell
curl -X POST "https://api.gov.nominal.io/api/asset/v2/relations/<relation rid>/unarchive" \
  -H "Authorization: Bearer <api key>"
```

**requests**

```python
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())
```

**httpx**

```python
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())
```

**aiohttp**

```python
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`

```json
{}
```

## Errors

[Errors](https://dev.nominal.io/api.md#errors) shows how these errors are sent.

Each error’s `errorName` is `NominalAssetV2:` followed by its name below.

| Status | Name | Notes |
| --- | --- | --- |
| 400 | `RelationErrorCountViolated` | RelationCountViolated |
| 400 | `RelationErrorInstancesOverlap` | RelationInstancesOverlap |
| 400 | `RelationErrorInvalidDefinition` | InvalidRelationDefinition |
| 400 | `RelationErrorInvalidRequest` | InvalidRelationRequest |
| 400 | `RelationErrorTooManyInstances` | TooManyRelationInstances |
| 404 | `RelationErrorNotFound` | RelationNotFound |
| 500 | `RelationErrorArchived` | RelationArchived |
| 500 | `RelationErrorCannotUnarchive` | 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_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` [`Any`](https://dev.nominal.io/api/rest/relation-service.md#any)
    :   ​

    **exactly**

    `exactly` [`Exactly`](https://dev.nominal.io/api/rest/relation-service.md#exactly)
    :   ​

    **range**

    `range` [`Range`](https://dev.nominal.io/api/rest/relation-service.md#range)
    :   ​

    **atLeast**

    `atLeast` [`AtLeast`](https://dev.nominal.io/api/rest/relation-service.md#atleast)
    :   ​

    **atMost**

    `atMost` [`AtMost`](https://dev.nominal.io/api/rest/relation-service.md#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`](https://dev.nominal.io/api/rest/relation-service.md#relationend) required
:   ​

`right` [`RelationEnd`](https://dev.nominal.io/api/rest/relation-service.md#relationend) required
:   ​

`createdAt` string (date-time) output only
:   ​

`isArchived` boolean output only
:   Set with ArchiveRelation and cleared with UnarchiveRelation. An archived relation keeps its instances but takes no new ones.

### RelationEnd

`typeRid` 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`](https://dev.nominal.io/api/rest/relation-service.md#cardinality) required
:   How many assets of the other end one asset of this end relates to at any instant.

Page design based on [Scalar](https://scalar.com), MIT License.
