# Assigning Related Resources

You can manage relationships between resources using the `PATCH` methods.
Relationships can be either **to-one** (a single related resource) or **to-many** (multiple related resources).

Important

- Use `PATCH` to replace or remove relationships.
- Servers may return **403 Forbidden** if complete replacement is not allowed.

---



## Updating to-one relationships

Use a `PATCH` request to update a to-one relationship.

*Update an inbound trunk for a DID*

This request updates the inbound trunk assigned to a DID:

[[DIDWW-API-EXAMPLE-START]]

http

```
PATCH /v3/dids/f10d40c7-fd0b-4d63-bb9b-27810a1a8f5c HTTP/1.1
Host: api.didww.com
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "dids",
    "id": "f10d40c7-fd0b-4d63-bb9b-27810a1a8f5c",
    "relationships": {
      "voice_in_trunk": {
        "data": { "type": "voice_in_trunks", "id": "d9b6ec47-0b72-452b-b4b4-23dd9d5be7e6" }
      }
    }
  }
}
```

curl

```
curl -i -X PATCH https://api.didww.com/v3/dids/f10d40c7-fd0b-4d63-bb9b-27810a1a8f5c -H "Accept: application/vnd.api+json" -H "Content-Type: application/vnd.api+json" --data-raw '{"data": {"id": "f10d40c7-fd0b-4d63-bb9b-27810a1a8f5c", "relationships": {"voice_in_trunk": {"data": {"id": "d9b6ec47-0b72-452b-b4b4-23dd9d5be7e6", "type": "voice_in_trunks"}}}, "type": "dids"}}'
```

[[DIDWW-API-EXAMPLE-END]]


*Remove an inbound trunk from a DID*

This request clears the inbound trunk relationship by setting it to `null`:

[[DIDWW-API-EXAMPLE-START]]

http

```
PATCH /v3/dids/f10d40c7-fd0b-4d63-bb9b-27810a1a8f5c HTTP/1.1
Host: api.didww.com
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "dids",
    "id": "1e0c45b1-1fea-4552-b41b-ffa9f5eb44c5",
    "relationships": {
      "voice_in_trunk": {
        "data": null
      }
    }
  }
}
```

curl

```
curl -i -X PATCH https://api.didww.com/v3/dids/f10d40c7-fd0b-4d63-bb9b-27810a1a8f5c -H "Accept: application/vnd.api+json" -H "Content-Type: application/vnd.api+json" --data-raw '{"data": {"id": "1e0c45b1-1fea-4552-b41b-ffa9f5eb44c5", "relationships": {"voice_in_trunk": {"data": null}}, "type": "dids"}}'
```

[[DIDWW-API-EXAMPLE-END]]

---

## Updating to-many relationships

Use `PATCH` to replace all members of a to-many relationship or clear them.

*Replace all inbound trunks in an inbound trunk group*

[[DIDWW-API-EXAMPLE-START]]

http

```
PATCH /v3/voice_in_trunk_groups/714e8148-0aea-4cb6-8680-bd1d06453418 HTTP/1.1
Host: api.didww.com
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "id": "714e8148-0aea-4cb6-8680-bd1d06453418",
    "type": "voice_in_trunk_groups",
    "relationships": {
      "voice_in_trunks": {
        "data": [
          { "type": "voice_in_trunks", "id": "ca7da6d0-aa0b-447d-8fc0-1bc58b51298c"},
          { "type": "voice_in_trunks", "id": "e9c1b7e9-253b-46c8-b7e9-5a930ab594c5" }
        ]
      }
    }
  }
}
```

curl

```
curl -i -X PATCH https://api.didww.com/v3/voice_in_trunk_groups/714e8148-0aea-4cb6-8680-bd1d06453418 -H "Accept: application/vnd.api+json" -H "Content-Type: application/vnd.api+json" --data-raw '{"data": {"id": "714e8148-0aea-4cb6-8680-bd1d06453418", "relationships": {"voice_in_trunks": {"data": [{"type": "voice_in_trunks", "id": "ca7da6d0-aa0b-447d-8fc0-1bc58b51298c"}, {"type": "voice_in_trunks", "id": "e9c1b7e9-253b-46c8-b7e9-5a930ab594c5"}]}}, "type": "voice_in_trunk_groups"}}'
```

[[DIDWW-API-EXAMPLE-END]]


*Clear all inbound trunks in an inbound trunk group*

[[DIDWW-API-EXAMPLE-START]]

http

```
PATCH /v3/voice_in_trunk_groups/c07815fc-bf9e-4cbf-a3fc-9c99b8de14d8 HTTP/1.1
Host: api.didww.com
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "id": "c07815fc-bf9e-4cbf-a3fc-9c99b8de14d8",
    "type": "voice_in_trunk_groups",
    "relationships": {
      "voice_in_trunks": {
        "data": []
      }
    }
  }
}
```

curl

```
curl -i -X PATCH https://api.didww.com/v3/voice_in_trunk_groups/c07815fc-bf9e-4cbf-a3fc-9c99b8de14d8 -H "Accept: application/vnd.api+json" -H "Content-Type: application/vnd.api+json" --data-raw '{"data": {"id": "c07815fc-bf9e-4cbf-a3fc-9c99b8de14d8", "relationships": {"voice_in_trunks": {"data": []}}, "type": "voice_in_trunk_groups"}}'
```

[[DIDWW-API-EXAMPLE-END]]

On this page
