> For the complete documentation index, see [llms.txt](https://crypto-chief.gitbook.io/chief-event-stream/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crypto-chief.gitbook.io/chief-event-stream/guides/first-stream.md). Agents can also search and read this documentation through its [MCP server](https://crypto-chief.gitbook.io/chief-event-stream/~gitbook/mcp).

# Your First Stream

## Your First Stream

This guide creates a subscription for incoming USDT TRC-20 transfers to one `TRON_MAINNET` address. EventStream delivers them to your HTTPS endpoint. Each step continues the code of the previous one.

### 1. Credentials

Set `CC_MERCHANT` to the project's Merchant ID and `CC_API_KEY` to its API key, and define `request()` from [Authentication](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/authentication.md#examples). The `capabilities` call below tests your request signing and shows whether `TRON_MAINNET` offers `transfer.token`.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const caps = await request("capabilities", {});
const pair = caps.event_types.find(
  (t) => t.network === "TRON_MAINNET" && t.event_type === "transfer.token"
);
console.log(pair ? pair.stages : "transfer.token is not offered on TRON_MAINNET");
```

{% endtab %}

{% tab title="PHP" %}

```php
$caps = request('capabilities', new stdClass());
$pair = null;
foreach ($caps['event_types'] as $t) {
    if ($t['network'] === 'TRON_MAINNET' && $t['event_type'] === 'transfer.token') {
        $pair = $t;
    }
}
echo $pair ? implode(',', $pair['stages']) : 'transfer.token is not offered on TRON_MAINNET', "\n";
```

{% endtab %}

{% tab title="GO" %}

```go
caps, err := request("capabilities", map[string]any{}, "")
if err != nil {
	log.Fatal(err)
}
for _, raw := range caps["event_types"].([]any) {
	t := raw.(map[string]any)
	if t["network"] == "TRON_MAINNET" && t["event_type"] == "transfer.token" {
		fmt.Println(t["stages"])
	}
}
```

{% endtab %}

{% tab title="Python" %}

```python
caps = request("capabilities", {})
pair = next(
    (t for t in caps["event_types"]
     if t["network"] == "TRON_MAINNET" and t["event_type"] == "transfer.token"),
    None,
)
print(pair["stages"] if pair else "transfer.token is not offered on TRON_MAINNET")
```

{% endtab %}

{% tab title="curl" %}

```bash
request capabilities '{}' \
  | jq '.event_types[] | select(.network == "TRON_MAINNET" and .event_type == "transfer.token") | .stages'
```

{% endtab %}
{% endtabs %}

### 2. Create an HTTPS sink

`sinks/create` registers the endpoint that receives events. The URL must pass the [destination URL rules](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md#destination-url-rules). Other sink kinds: [Sink Types](https://crypto-chief.gitbook.io/chief-event-stream/sinks/overview.md).

The response contains `secret`, the key that signs every webhook. Store it: `sinks/get` and `sinks/list` do not return it. If the response is lost, repeat the call with the same body and `Idempotency-Key` within `24` hours ([Signing secret](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md#signing-secret)).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const sink = await request(
  "sinks/create",
  { kind: "https", config: { url: "https://merchant.example/events" } },
  "first-stream-sink-0001"
);

console.log("sink_id:", sink.sink_id); // store sink.secret in your secret store
```

{% endtab %}

{% tab title="PHP" %}

```php
$sink = request('sinks/create', [
    'kind'   => 'https',
    'config' => ['url' => 'https://merchant.example/events'],
], 'first-stream-sink-0001');

echo "sink_id: {$sink['sink_id']}\n"; // store $sink['secret'] in your secret store
```

{% endtab %}

{% tab title="GO" %}

```go
sink, err := request("sinks/create", map[string]any{
	"kind":   "https",
	"config": map[string]any{"url": "https://merchant.example/events"},
}, "first-stream-sink-0001")
if err != nil {
	log.Fatal(err)
}

fmt.Println("sink_id:", sink["sink_id"]) // store sink["secret"] in your secret store
```

{% endtab %}

{% tab title="Python" %}

```python
sink = request(
    "sinks/create",
    {"kind": "https", "config": {"url": "https://merchant.example/events"}},
    "first-stream-sink-0001",
)

print("sink_id:", sink["sink_id"])  # store sink["secret"] in your secret store
```

{% endtab %}

{% tab title="curl" %}

```bash
sink=$(request sinks/create '{"kind":"https","config":{"url":"https://merchant.example/events"}}' first-stream-sink-0001)
SINK_ID=$(jq -r .sink_id <<< "$sink")
jq -r .secret <<< "$sink"   # store it in your secret store
```

{% endtab %}
{% endtabs %}

### 3. Send a test delivery

Start the receiver from step 6 at the sink URL first. `sinks/test` queues a free `system.test` event to the sink. The receiver logs it as a test probe; its `event_id` equals `delivery_id`. `deliveries/info` returns the delivery `status` and its attempts. `succeeded` means the endpoint answered `2xx`. After a failed attempt, `error_code` names the cause ([Attempt fields](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/deliveries.md#attempt-fields)).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const probe = await request(
  "sinks/test",
  { sink_id: sink.sink_id, sample_type: "system.test" },
  crypto.randomUUID()
);

let info;
do {
  await new Promise((r) => setTimeout(r, 2000));
  info = await request("deliveries/info", { delivery_id: probe.delivery_id });
} while (info.attempts.length === 0);

const last = info.attempts.at(-1);
console.log(info.status, last.result, last.http_status, last.error_code);
```

{% endtab %}

{% tab title="PHP" %}

```php
$probe = request('sinks/test', [
    'sink_id'     => $sink['sink_id'],
    'sample_type' => 'system.test',
], bin2hex(random_bytes(16)));

do {
    sleep(2);
    $info = request('deliveries/info', ['delivery_id' => $probe['delivery_id']]);
} while ($info['attempts'] === []);

$last = end($info['attempts']);
echo "{$info['status']} {$last['result']} {$last['http_status']} {$last['error_code']}\n";
```

{% endtab %}

{% tab title="GO" %}

```go
key := make([]byte, 16)
if _, err := rand.Read(key); err != nil {
	log.Fatal(err)
}
probe, err := request("sinks/test", map[string]any{
	"sink_id":     sink["sink_id"],
	"sample_type": "system.test",
}, hex.EncodeToString(key))
if err != nil {
	log.Fatal(err)
}

var info map[string]any
for {
	time.Sleep(2 * time.Second)
	if info, err = request("deliveries/info", map[string]any{"delivery_id": probe["delivery_id"]}, ""); err != nil {
		log.Fatal(err)
	}
	if len(info["attempts"].([]any)) > 0 {
		break
	}
}

attempts := info["attempts"].([]any)
last := attempts[len(attempts)-1].(map[string]any)
fmt.Println(info["status"], last["result"], last["http_status"], last["error_code"])
```

{% endtab %}

{% tab title="Python" %}

```python
probe = request(
    "sinks/test",
    {"sink_id": sink["sink_id"], "sample_type": "system.test"},
    secrets.token_hex(16),
)

while True:
    time.sleep(2)
    info = request("deliveries/info", {"delivery_id": probe["delivery_id"]})
    if info["attempts"]:
        break

last = info["attempts"][-1]
print(info["status"], last["result"], last["http_status"], last["error_code"])
```

{% endtab %}

{% tab title="curl" %}

```bash
probe=$(request sinks/test "{\"sink_id\":\"$SINK_ID\",\"sample_type\":\"system.test\"}" "$(openssl rand -hex 16)")
DELIVERY_ID=$(jq -r .delivery_id <<< "$probe")

until info=$(request deliveries/info "{\"delivery_id\":\"$DELIVERY_ID\"}") \
  && jq -e '.attempts | length > 0' > /dev/null <<< "$info"; do
  sleep 2
done
jq '{status, attempt: .attempts[-1]}' <<< "$info"
```

{% endtab %}
{% endtabs %}

### 4. Create a subscription

The subscription delivers every non-zero incoming transfer of USDT (`TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t`) to one address at stages `confirmed` and `reorged`. The body has every required field; [Create a Subscription](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/subscriptions.md#create-a-subscription) describes each one.

* **Addresses** in `selection` are Base58Check `T...`; events carry them as `41` + 40 lowercase hex characters ([Address formats](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/networks-and-event-types.md#address-formats)).
* **`confirmations: {}`** keeps the network default: `confirmed` at `2` confirmations on `TRON_MAINNET`, which has no `final` stage ([Confirmations and Reorgs](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/confirmations-and-reorgs.md)). To credit funds on `confirmed`, set a deeper threshold, for example `{"TRON_MAINNET": 19}` ([Stage to credit funds on](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/confirmations-and-reorgs.md#stage-to-credit-funds-on)).
* **`limits`** caps the capture rate and the events per UTC day ([Limits](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/limits.md)).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const ADDRESS = "TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi"; // the address that receives USDT

let sub = await request(
  "subscriptions/create",
  {
    name: "USDT TRC-20 incoming",
    selection: {
      networks: ["TRON_MAINNET"],
      types: ["transfer.token"],
      addresses: [{ network: "TRON_MAINNET", address: ADDRESS }],
      directions: ["in"],
      assets: [
        { network: "TRON_MAINNET", kind: "token", id: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" },
      ],
      minimum_raw: "0",
      include_zero: false,
    },
    stages: ["confirmed", "reorged"],
    confirmations: {},
    scripts: { language: "esjs/1" },
    enrichment: {},
    sink_ids: [sink.sink_id],
    limits: {
      events_per_second: 10,
      max_events_per_day: "1000",
      max_source_credits_per_day: "0",
    },
    allow_partial_activation: false,
  },
  "first-stream-sub-0001"
);

console.log(sub.subscription_id, sub.status);
```

{% endtab %}

{% tab title="PHP" %}

```php
const ADDRESS = 'TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi'; // the address that receives USDT

$sub = request('subscriptions/create', [
    'name' => 'USDT TRC-20 incoming',
    'selection' => [
        'networks'     => ['TRON_MAINNET'],
        'types'        => ['transfer.token'],
        'addresses'    => [['network' => 'TRON_MAINNET', 'address' => ADDRESS]],
        'directions'   => ['in'],
        'assets'       => [
            ['network' => 'TRON_MAINNET', 'kind' => 'token', 'id' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'],
        ],
        'minimum_raw'  => '0',
        'include_zero' => false,
    ],
    'stages'        => ['confirmed', 'reorged'],
    'confirmations' => new stdClass(),
    'scripts'       => ['language' => 'esjs/1'],
    'enrichment'    => new stdClass(),
    'sink_ids'      => [$sink['sink_id']],
    'limits' => [
        'events_per_second'          => 10,
        'max_events_per_day'         => '1000',
        'max_source_credits_per_day' => '0',
    ],
    'allow_partial_activation' => false,
], 'first-stream-sub-0001');

echo "{$sub['subscription_id']} {$sub['status']}\n";
```

{% endtab %}

{% tab title="GO" %}

```go
const address = "TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi" // the address that receives USDT

sub, err := request("subscriptions/create", map[string]any{
	"name": "USDT TRC-20 incoming",
	"selection": map[string]any{
		"networks":   []string{"TRON_MAINNET"},
		"types":      []string{"transfer.token"},
		"addresses":  []map[string]any{{"network": "TRON_MAINNET", "address": address}},
		"directions": []string{"in"},
		"assets": []map[string]any{
			{"network": "TRON_MAINNET", "kind": "token", "id": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"},
		},
		"minimum_raw":  "0",
		"include_zero": false,
	},
	"stages":        []string{"confirmed", "reorged"},
	"confirmations": map[string]any{},
	"scripts":       map[string]any{"language": "esjs/1"},
	"enrichment":    map[string]any{},
	"sink_ids":      []any{sink["sink_id"]},
	"limits": map[string]any{
		"events_per_second":          10,
		"max_events_per_day":         "1000",
		"max_source_credits_per_day": "0",
	},
	"allow_partial_activation": false,
}, "first-stream-sub-0001")
if err != nil {
	log.Fatal(err)
}

fmt.Println(sub["subscription_id"], sub["status"])
```

{% endtab %}

{% tab title="Python" %}

```python
ADDRESS = "TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi"  # the address that receives USDT

sub = request(
    "subscriptions/create",
    {
        "name": "USDT TRC-20 incoming",
        "selection": {
            "networks": ["TRON_MAINNET"],
            "types": ["transfer.token"],
            "addresses": [{"network": "TRON_MAINNET", "address": ADDRESS}],
            "directions": ["in"],
            "assets": [
                {"network": "TRON_MAINNET", "kind": "token", "id": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"},
            ],
            "minimum_raw": "0",
            "include_zero": False,
        },
        "stages": ["confirmed", "reorged"],
        "confirmations": {},
        "scripts": {"language": "esjs/1"},
        "enrichment": {},
        "sink_ids": [sink["sink_id"]],
        "limits": {
            "events_per_second": 10,
            "max_events_per_day": "1000",
            "max_source_credits_per_day": "0",
        },
        "allow_partial_activation": False,
    },
    "first-stream-sub-0001",
)

print(sub["subscription_id"], sub["status"])
```

{% endtab %}

{% tab title="curl" %}

```bash
ADDRESS="TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi"   # the address that receives USDT

body=$(jq -nc --arg address "$ADDRESS" --arg sink "$SINK_ID" '{
  name: "USDT TRC-20 incoming",
  selection: {
    networks: ["TRON_MAINNET"],
    types: ["transfer.token"],
    addresses: [{network: "TRON_MAINNET", address: $address}],
    directions: ["in"],
    assets: [{network: "TRON_MAINNET", kind: "token", id: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"}],
    minimum_raw: "0",
    include_zero: false
  },
  stages: ["confirmed", "reorged"],
  confirmations: {},
  scripts: {language: "esjs/1"},
  enrichment: {},
  sink_ids: [$sink],
  limits: {events_per_second: 10, max_events_per_day: "1000", max_source_credits_per_day: "0"},
  allow_partial_activation: false
}')

sub=$(request subscriptions/create "$body" first-stream-sub-0001)
SUB_ID=$(jq -r .subscription_id <<< "$sub")
jq '{subscription_id, status}' <<< "$sub"
```

{% endtab %}
{% endtabs %}

### 5. Wait for `active`

A new subscription stays `pending` until `TRON_MAINNET` starts capturing for it at a block boundary. `activation[].from_height` is the first block it evaluates. Every `paused_*` status carries `pause_reason` ([Statuses and pause reasons](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/subscriptions.md#statuses-and-pause-reasons)).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
while (sub.status === "pending") {
  await new Promise((r) => setTimeout(r, 5000));
  sub = await request("subscriptions/get", { subscription_id: sub.subscription_id });
}
if (sub.status !== "active") {
  throw new Error(`${sub.status}: ${sub.pause_reason}`);
}

console.log("active from block", sub.activation[0].from_height);
```

{% endtab %}

{% tab title="PHP" %}

```php
while ($sub['status'] === 'pending') {
    sleep(5);
    $sub = request('subscriptions/get', ['subscription_id' => $sub['subscription_id']]);
}
if ($sub['status'] !== 'active') {
    throw new RuntimeException("{$sub['status']}: {$sub['pause_reason']}");
}

echo "active from block {$sub['activation'][0]['from_height']}\n";
```

{% endtab %}

{% tab title="GO" %}

```go
for sub["status"] == "pending" {
	time.Sleep(5 * time.Second)
	if sub, err = request("subscriptions/get", map[string]any{"subscription_id": sub["subscription_id"]}, ""); err != nil {
		log.Fatal(err)
	}
}
if sub["status"] != "active" {
	log.Fatalf("%v: %v", sub["status"], sub["pause_reason"])
}

activation := sub["activation"].([]any)[0].(map[string]any)
fmt.Println("active from block", activation["from_height"])
```

{% endtab %}

{% tab title="Python" %}

```python
while sub["status"] == "pending":
    time.sleep(5)
    sub = request("subscriptions/get", {"subscription_id": sub["subscription_id"]})
if sub["status"] != "active":
    raise RuntimeError(f"{sub['status']}: {sub['pause_reason']}")

print("active from block", sub["activation"][0]["from_height"])
```

{% endtab %}

{% tab title="curl" %}

```bash
while [ "$(jq -r .status <<< "$sub")" = "pending" ]; do
  sleep 5
  sub=$(request subscriptions/get "{\"subscription_id\":\"$SUB_ID\"}") || break
done
jq '{status, pause_reason, from_height: .activation[0].from_height}' <<< "$sub"
```

{% endtab %}
{% endtabs %}

### 6. Receive and verify the webhook

When a USDT transfer to the address reaches `confirmed`, its event arrives as a signed `POST` to the sink URL. Run the [complete webhook handler](https://crypto-chief.gitbook.io/chief-event-stream/guides/receiving-webhooks.md#complete-webhook-handler) from Receiving Webhooks with `WEBHOOK_SECRETS` set to the secret from step 2. The sink signs with the default profile `cc-hmac-sha256-webhook-v1` ([Verifying Signatures](https://crypto-chief.gitbook.io/chief-event-stream/webhooks/verifying-signatures.md)). Call the function below from the handler's worker for each new event. The fields are listed in [Event Payloads](https://crypto-chief.gitbook.io/chief-event-stream/webhooks/event-payloads.md). The amount is `amount.raw × 10^-amount.decimals` ([Amounts](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/networks-and-event-types.md#amounts)).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
// Called by the worker of the handler in Receiving Webhooks once per new event_id.
function onEvent(ev) {
  const { amount, from, to } = ev.payload;
  if (ev.stage === "confirmed") {
    // to: 41d1c4bb7b2f39aba5707711719b2236b5b605af2e for TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi
    console.log(`+${amount.raw} (decimals ${amount.decimals}) from ${from} to ${to}, event ${ev.event_id}`);
  } else if (ev.stage === "reorged") {
    console.log("rolled back:", ev.relation.replaces_event_ids);
  }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
// Called by the handler in Receiving Webhooks once per new event_id.
function onEvent(array $ev): void
{
    $p = $ev['payload'];
    if ($ev['stage'] === 'confirmed') {
        // to: 41d1c4bb7b2f39aba5707711719b2236b5b605af2e for TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi
        error_log("+{$p['amount']['raw']} (decimals {$p['amount']['decimals']}) from {$p['from']} to {$p['to']}, event {$ev['event_id']}");
    } elseif ($ev['stage'] === 'reorged') {
        error_log('rolled back: ' . implode(',', $ev['relation']['replaces_event_ids']));
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
// Called by the worker of the handler in Receiving Webhooks once per new event_id.
func onEvent(ev Envelope) {
	var p struct {
		Amount struct {
			Raw      string `json:"raw"`
			Decimals any    `json:"decimals"`
		} `json:"amount"`
		From string `json:"from"`
		To   string `json:"to"`
	}
	if err := json.Unmarshal(ev.Payload, &p); err != nil {
		log.Printf("event %s: %v", ev.EventID, err)
		return
	}
	switch ev.Stage {
	case "confirmed":
		// p.To: 41d1c4bb7b2f39aba5707711719b2236b5b605af2e for TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi
		log.Printf("+%s (decimals %v) from %s to %s, event %s", p.Amount.Raw, p.Amount.Decimals, p.From, p.To, ev.EventID)
	case "reorged":
		log.Printf("rolled back: %v", ev.Relation.ReplacesEventIDs)
	}
}
```

{% endtab %}

{% tab title="Python" %}

```python
# Called by the worker of the handler in Receiving Webhooks once per new event_id.
def on_event(ev: dict) -> None:
    p = ev["payload"]
    if ev["stage"] == "confirmed":
        # to: 41d1c4bb7b2f39aba5707711719b2236b5b605af2e for TV6MuMXfmLbBqPZvBHdwFsDnQeVfnmiuSi
        print(f"+{p['amount']['raw']} (decimals {p['amount']['decimals']}) "
              f"from {p['from']} to {p['to']}, event {ev['event_id']}")
    elif ev["stage"] == "reorged":
        print("rolled back:", ev["relation"]["replaces_event_ids"])
```

{% endtab %}

{% tab title="curl" %}

```bash
# body.json: a request body your handler has verified
jq -r 'if .stage == "confirmed" then
         "+\(.payload.amount.raw) (decimals \(.payload.amount.decimals)) from \(.payload.from) to \(.payload.to), event \(.event_id)"
       elif .stage == "reorged" then
         "rolled back: \(.relation.replaces_event_ids | join(","))"
       else empty end' body.json
```

{% endtab %}
{% endtabs %}

### 7. Look at events and deliveries

`events/list` returns the events the subscription captured, oldest first. `deliveries/list` returns their deliveries with `status` and `attempt_count`. The test delivery from step 3 is in neither list. Further pages: [Pagination](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/authentication.md#pagination).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const events = await request("events/list", { subscription_id: sub.subscription_id, limit: 20 });
for (const ev of events.items) {
  console.log(ev.sequence, ev.stage, ev.event_id);
}

const deliveries = await request("deliveries/list", { subscription_id: sub.subscription_id, limit: 20 });
for (const d of deliveries.items) {
  console.log(d.delivery_id, d.event_id, d.status, d.attempt_count);
}
```

{% endtab %}

{% tab title="PHP" %}

```php
$events = request('events/list', ['subscription_id' => $sub['subscription_id'], 'limit' => 20]);
foreach ($events['items'] as $ev) {
    echo "{$ev['sequence']} {$ev['stage']} {$ev['event_id']}\n";
}

$deliveries = request('deliveries/list', ['subscription_id' => $sub['subscription_id'], 'limit' => 20]);
foreach ($deliveries['items'] as $d) {
    echo "{$d['delivery_id']} {$d['event_id']} {$d['status']} {$d['attempt_count']}\n";
}
```

{% endtab %}

{% tab title="GO" %}

```go
events, err := request("events/list", map[string]any{"subscription_id": sub["subscription_id"], "limit": 20}, "")
if err != nil {
	log.Fatal(err)
}
for _, raw := range events["items"].([]any) {
	ev := raw.(map[string]any)
	fmt.Println(ev["sequence"], ev["stage"], ev["event_id"])
}

deliveries, err := request("deliveries/list", map[string]any{"subscription_id": sub["subscription_id"], "limit": 20}, "")
if err != nil {
	log.Fatal(err)
}
for _, raw := range deliveries["items"].([]any) {
	d := raw.(map[string]any)
	fmt.Println(d["delivery_id"], d["event_id"], d["status"], d["attempt_count"])
}
```

{% endtab %}

{% tab title="Python" %}

```python
events = request("events/list", {"subscription_id": sub["subscription_id"], "limit": 20})
for ev in events["items"]:
    print(ev["sequence"], ev["stage"], ev["event_id"])

deliveries = request("deliveries/list", {"subscription_id": sub["subscription_id"], "limit": 20})
for d in deliveries["items"]:
    print(d["delivery_id"], d["event_id"], d["status"], d["attempt_count"])
```

{% endtab %}

{% tab title="curl" %}

```bash
request events/list "{\"subscription_id\":\"$SUB_ID\",\"limit\":20}" \
  | jq -r '.items[] | [.sequence, .stage, .event_id] | @tsv'

request deliveries/list "{\"subscription_id\":\"$SUB_ID\",\"limit\":20}" \
  | jq -r '.items[] | [.delivery_id, .event_id, .status, .attempt_count] | @tsv'
```

{% endtab %}
{% endtabs %}
