# List relations

List the company group and the third-party payers of a counterparty.

Returns the relations of the counterparty. group holds the members of its company group with their open amounts, and is empty when it belongs to none. groupRelations holds the relations that name it as a subsidiary or a parent company. paidBy holds its third-party payers, and paysFor the counterparties whose invoices it pays. remainderPercent is what the counterparty itself owes of its invoices today when payers hold shares, and null otherwise. Relations outside their dates are returned too.


- HTTP method: `GET`
- Path: `/api/v1/counterparties/:code/relations`
- URL: `https://api.invunion.com/api/v1/counterparties/:code/relations`
- Required scope: `counterparties:read`
- HTML docs: https://www.invunion.com/knowledge-base/api/list-counterparty-relations/
- Markdown docs: https://www.invunion.com/knowledge-base/api/list-counterparty-relations.md

## Path parameters

| Name | Type | Required | Description | Allowed values | Example |
| --- | --- | --- | --- | --- | --- |
| `code` | string, max 50 | required | Counterparty code (`account_code`). |  | `CPT-042` |



## Errors

| Error | HTTP code | Description |
| --- | --- | --- |
| `Missing Bearer token` | `401` | The Authorization header is missing or is not a Bearer token. |
| `Invalid or revoked API key` | `401` | The API key is unknown, malformed, expired, or has been revoked. |
| `API key is missing scope counterparties:read` | `403` | The key does not include counterparties:read. A write scope does not imply the matching read scope. |
| `Too many requests, please try again later` | `429` | More than 100 requests in one minute from this API key or IP address. Wait for the Retry-After header (seconds) and retry. |
| `Counterparty not found` | `404` | No counterparty with this code exists in the authenticated tenant. |
| `Internal server error` | `500` | Unexpected server error. The JSON body includes correlationId. Retry with backoff. |

## Request (curl)

```bash
curl --request GET \
  --url https://api.invunion.com/api/v1/counterparties/CPT-042/relations \
  --header 'accept: application/json' \
  --header 'authorization: Bearer uk_live_YOUR_API_KEY'
```

## Request (Python)

```python
import requests

url = "https://api.invunion.com/api/v1/counterparties/CPT-042/relations"
headers = {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY",
}
response = requests.get(url, headers=headers)
print(response.json())
```

## Request (Ruby)

```ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI("https://api.invunion.com/api/v1/counterparties/CPT-042/relations")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Accept'] = 'application/json'
request['Authorization'] = 'Bearer uk_live_YOUR_API_KEY'
response = http.request(request)
puts response.body
```

## Request (JavaScript)

```javascript
const response = await fetch("https://api.invunion.com/api/v1/counterparties/CPT-042/relations", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY"
  },
});
const data = await response.json();
```

## Request (Go)

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.invunion.com/api/v1/counterparties/CPT-042/relations", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Accept", "application/json")
	req.Header.Set("Authorization", "Bearer uk_live_YOUR_API_KEY")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

## Request (Node)

```javascript
const response = await fetch("https://api.invunion.com/api/v1/counterparties/CPT-042/relations", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY"
  },
});
console.log(await response.json());
```

## Success (200)

```json
{
  "success": true,
  "data": {
    "counterpartyId": "d4e5f6a7-8b9c-4d0e-9f1a-2b3c4d5e6f7a",
    "group": [],
    "groupOpen": [],
    "groupRelations": [],
    "paidBy": [
      {
        "id": "3f2a9c1e-7b4d-4e8a-9c21-5d6e7f8a9b0c",
        "kind": "pays_for",
        "counterpartyId": "b7c1f0a2-5d3e-4f6a-8b9c-0d1e2f3a4b5c",
        "relatedCounterpartyId": "d4e5f6a7-8b9c-4d0e-9f1a-2b3c4d5e6f7a",
        "sharePercent": 70,
        "trust": "customer",
        "validFrom": "2026-01-01",
        "validTo": null,
        "source": "api",
        "notes": null,
        "payer": {
          "id": "b7c1f0a2-5d3e-4f6a-8b9c-0d1e2f3a4b5c",
          "accountCode": "CPT-007",
          "name": "Alpha Industries"
        }
      }
    ],
    "remainderPercent": 30,
    "paysFor": []
  }
}
```
