# Get counterparty

Get one counterparty by code.

Returns the counterparty, including computed payment status and billed revenue. Payer score is refreshed when this endpoint is called. Identify the counterparty with its account_code.


- HTTP method: `GET`
- Path: `/api/v1/counterparties/:code`
- URL: `https://api.invunion.com/api/v1/counterparties/:code`
- Required scope: `counterparties:read`
- HTML docs: https://www.invunion.com/knowledge-base/api/get-counterparty/
- Markdown docs: https://www.invunion.com/knowledge-base/api/get-counterparty.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` | Wait and retry. The Retry-After header is the number of seconds to wait. |
| `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 \
  --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"
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")
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", {
  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", 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", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY"
  },
});
console.log(await response.json());
```

## Success (200)

```json
{
  "success": true,
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "tenant_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "name_original": "Leones Cars",
    "name_display": "Leones Cars",
    "account_code": "CPT-042",
    "category": "professional",
    "payment_terms_days": 30,
    "is_supplier": false,
    "is_client": true,
    "is_partner": false,
    "is_payer": true,
    "is_internal": false,
    "is_employee": false,
    "external_reference": "ERP-1842",
    "vat_number": "FR12345678901",
    "registration_number": "123456789",
    "electronic_address": "0208:123456789",
    "address": "12 Grove Street",
    "city": "Lyon",
    "postal_code": "69001",
    "country": "FR",
    "email": "carl@leonescars.fr",
    "phone": "+33472000000",
    "analytic_1": "SALES-EU",
    "analytic_2": "CHANNEL-DIRECT",
    "status": "up_to_date",
    "payer_score": 88,
    "payer_score_category": "good",
    "payment_score": 92,
    "avg_payment_days": 18,
    "total_invoiced": "12500.00",
    "total_revenue": 12500,
    "total_paid": "9800.00",
    "last_invoice_date": "2026-09-01",
    "last_payment_date": "2026-09-12",
    "invoice_count": 14,
    "outstanding_credit": "0.00",
    "unmatched_invoices_count": 2,
    "unmatched_transactions_count": 1,
    "is_system": false,
    "created_at": "2026-03-04T12:40:56.656Z",
    "updated_at": "2026-09-12T08:15:22.110Z",
    "metadata": {
      "erp_id": "C-1842"
    }
  }
}
```
