> ## Documentation Index
> Fetch the complete documentation index at: https://docs.4mica.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get a clearing action

> Read the ClearingHouse call and Merkle proof that pay a net debit or claim a net credit.

`GET /core/cycles/{cycle_id}/participants/{participant}/clearing-action`

When core commits a netted cycle, it publishes a Merkle root of every participant's net position on the `ClearingHouse`. To pay a net debit or claim a net credit, the caller proves the participant's position against that root. This endpoint returns the contract, function, amount, and proof for the call. The SDKs and the facilitator's sponsored endpoints use it for you.

## Authorization

**Authorization** `string` *required*

`Bearer <access_token>`. The token needs the scope `payment:read`. A `claim_net_credit` action is served to any such caller, because the claim always pays the creditor. A `pay_net_debit` action is served only to the participant, or to the `admin` or `facilitator` role.

## Path parameters

**cycle\_id** `string` *required*

Core's text ID for the cycle (`cycle_id_text`), not the on-chain ID. Read it from [positions](https://docs.4mica.io/api-reference/operator/positions.md).

**participant** `string` *required*

## Query parameters

**action** `string` *required*

## Responses

**contract\_address** `string` *required*

The `ClearingHouse` address.

**function\_name** `string` *required*

`payNetDebit` or `claimNetCreditFor`.

**action** `string` *required*

**cycle\_id** `string` *required*

On-chain cycle ID, the value the contract call takes.

**cycle\_id\_text** `string` *required*

**asset\_address** `string` *required*

**participant** `string` *required*

**amount** `string` *required*

The amount argument, in base units as a decimal string.

**payable\_value** `string` *required*

Native value to attach to the transaction. Non-zero only when a debtor pays a native ETH debit.

**proof** `string[]` *required*

Merkle proof of the participant's position.

```bash cURL theme={null}
curl "https://base.sepolia.api.4mica.io/core/cycles/0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f:1796256000/participants/0x1111111111111111111111111111111111111111/clearing-action?action=pay_net_debit" \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

```javascript title="Fetch" theme={null}
const response = await fetch("https://base.sepolia.api.4mica.io/core/cycles/0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f:1796256000/participants/0x1111111111111111111111111111111111111111/clearing-action?action=pay_net_debit", {
  headers: { Authorization: `Bearer ${process.env.ACCESS_TOKEN}` },
});
console.log(await response.json());
```

```python Python theme={null}
import os
import requests
url = "https://base.sepolia.api.4mica.io/core/cycles/0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f:1796256000/participants/0x1111111111111111111111111111111111111111/clearing-action?action=pay_net_debit"
print(requests.get(url, headers={"Authorization": f"Bearer {os.environ['ACCESS_TOKEN']}"}).json())
```

```json 200 OK theme={null}
{
  "contract_address": "0x6666666666666666666666666666666666666666",
  "function_name": "payNetDebit",
  "action": "pay_net_debit",
  "cycle_id": "0x4444444444444444444444444444444444444444444444444444444444444444",
  "cycle_id_text": "0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f:1796256000",
  "asset_address": "0xba50Cd2A20f6DA35D788639E581bca8d0B5d4D5f",
  "participant": "0x1111111111111111111111111111111111111111",
  "amount": "370000",
  "payable_value": "0",
  "proof": [
    "0x7777777777777777777777777777777777777777777777777777777777777777"
  ]
}
```

```json 401 Unauthorized theme={null}
{ "error": "participant clearing action access denied" }
```

## Status codes

| Code | Description |
| - | - |
| `200` | The action and its proof. |
| `400` | The participant's role does not match the action, the participant has no net position, or a parameter is malformed. A missing or unknown `action` is answered by the request parser with a plain-text body rather than JSON. |
| `401` | The bearer token is missing or invalid, lacks `payment:read`, or may not read this participant's payment action. |
| `404` | The cycle or the participant's position in it does not exist. |
| `500` | Core could not build the action. |

## Proof only

`GET /core/cycles/{cycle_id}/participants/{participant}/clearing-proof` returns the position and proof without choosing a call. It takes no query parameter. The token needs the scope `payment:read`, and the proof is served only to the participant, or to the `admin` or `facilitator` role; anyone else gets `401`.

It answers `400` with `{ "error": "flat participants do not have a clearing proof" }` for a participant whose debits and credits cancel, and `400` for a malformed address or a cycle that has no clearing batch yet. It answers `404` when the cycle does not exist or the participant has no position in it.

```json theme={null}
{
  "cycle_id": "0x4444444444444444444444444444444444444444444444444444444444444444",
  "cycle_id_text": "0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f:1796256000",
  "asset_address": "0xba50Cd2A20f6DA35D788639E581bca8d0B5d4D5f",
  "participant": "0x1111111111111111111111111111111111111111",
  "role": "NET_DEBTOR",
  "amount": "370000",
  "net_debit": "370000",
  "net_credit": "0",
  "leaf": "0x8888888888888888888888888888888888888888888888888888888888888888",
  "merkle_root": "0x9999999999999999999999999999999999999999999999999999999999999999",
  "proof": [
    "0x7777777777777777777777777777777777777777777777777777777777777777"
  ]
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.