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

# Subscriptions

> Managing Stratus Subscription

<head>
  <script type="application/ld+json">
    {JSON.stringify({
            "@context": "https://schema.org",
            "@graph": [
              {
                "@type": "TechArticle",
                "headline": "Subscriptions",
                "description": "Managing Stratus Subscription",
                "author": {"@type": "Organization", "name": "Snag Solutions", "url": "https://www.snagsolutions.io/"},
                "publisher": {"@type": "Organization", "name": "Snag Solutions", "url": "https://www.snagsolutions.io/", "logo": {"@type": "ImageObject", "url": "https://assets.snagsolutions.io/public/docs/snag-logo-dark-no-bg.svg"}},
                "mainEntityOfPage": "https://docs.snagsolutions.io/stratus/subscriptions"
              },
              {
                "@type": "BreadcrumbList",
                "itemListElement": [
                  {"@type": "ListItem", "position": 1, "name": "Home", "item": "https://docs.snagsolutions.io/welcome"},
                  {"@type": "ListItem", "position": 2, "name": "Stratus", "item": "https://docs.snagsolutions.io/stratus/stratus-overview"},
                  {"@type": "ListItem", "position": 3, "name": "Subscriptions"}
                ]
              }
            ]
          })}
  </script>
</head>

## Overview

Subscriptions empower developers to receive real-time updates triggered by smart contract events or internal loyalty actions. These notifications can either be sent to a webhook endpoint or used to automatically invoke functions.

## Event Types

### Blockchain Events

Blockchain events notify you whenever a smart contract emits an event or a function is called. These events track on-chain state with minimal latency (typically one block), making them ideal for real-time applications.

<Steps>
  <Step title="Add Contract to Admin Account">
    Start by adding the desired smart contract to your admin panel.
  </Step>

  <Step title="Select Event">
    Choose "EVENT" from the subscription options. All available events for the
    contract will be populated automatically.
  </Step>
</Steps>

### Blockchain Function Events

The process mirrors blockchain events with a slight variation:

<Steps>
  <Step title="Add Contract to Admin Panel">
    Ensure the contract is registered in your admin panel.
  </Step>

  <Step title="Select Function">
    Choose "FUNCTION" after adding the contract. All smart contract functions
    will be listed automatically.
  </Step>
</Steps>

### Snag Events

<Note>
  Snag events allow subscriptions to internal platform actions. These events
  relate to loyalty account activities and may have a slight delay (up to 30
  seconds) after the action is recorded.
</Note>

## Event Types Reference

<CardGroup cols={2}>
  <Card title="LoyaltyTransactionEntry" icon="coins">
    Triggered when a user's account balance is updated
  </Card>

  <Card title="UserMetadata" icon="user">
    Emitted when a user's profile is created or updated
  </Card>

  <Card title="LoyaltyRuleStatus" icon="check-circle">
    Triggered when a user's loyalty rule progress is set to 100
  </Card>
</CardGroup>

### LoyaltyTransactionEntry

<CodeGroup>
  ```json Sample Payload theme={null}
  {
    "id": "uuid-123e4567-e89b-12d3-a456-426614174000",
    "loyaltyAccountId": "uuid-account-001",
    "loyaltyTransactionId": "uuid-transaction-001",
    "loyaltyCurrencyId": "uuid-currency-001",
    "amount": "100.00",
    "direction": "credit",
    "metadata": {},
    "loyaltyAccountStartAmount": "500.00",
    "loyaltyAccountEndAmount": "600.00",
    "loyaltyAccountLockVersion": 1,
    "hideInUi": false,
    "idempotencyKey": "unique-key-001",
    "idempotencyKeyExpiresAt": "2025-03-05T00:00:00Z",
    "dismissedInUi": false,
    "organizationId": "uuid-org-001",
    "websiteId": "uuid-website-001",
    "createdAt": "2025-03-04T12:00:00Z",
    "updatedAt": "2025-03-04T12:00:00Z",
    "loyaltyAccount": {
      "user": {
        "id": "uuid-user-001",
        "walletAddress": "0x1234567890abcdef1234567890abcdef12345678"
      }
    },
    "loyaltyTransaction": {
      "loyaltyRule": {
        "id": "uuid-rule-001"
      }
    }
  }
  ```
</CodeGroup>

### UserMetadata

<CodeGroup>
  ```json Sample Payload theme={null}
  {
    "id": "uuid-234e4567-e89b-12d3-a456-426614174001",
    "userId": "uuid-user-001",
    "isBlocked": false,
    "websiteId": "uuid-website-001",
    "organizationId": "uuid-org-001",
    "emailAddress": "user@example.com",
    "twitterUser": "userTwitter",
    "twitterUserId": "twitter-001",
    "twitterUserFollowersCount": 150,
    "twitterVerifiedAt": "2025-03-04T10:00:00Z",
    "discordUser": "userDiscord",
    "discordUserId": "discord-001",
    "discordVerifiedAt": "2025-03-04T10:05:00Z",
    "instagramUser": "userInstagram",
    "instagramUserId": "insta-001",
    "instagramVerifiedAt": "2025-03-04T10:10:00Z",
    "logoUrl": "https://example.com/logo.png",
    "displayName": "User Display Name",
    "location": "New York, USA",
    "bio": "Sample bio text.",
    "portfolioUrl": "https://example.com/portfolio",
    "createdAt": "2025-03-04T09:00:00Z",
    "updatedAt": "2025-03-04T11:00:00Z",
    "user": {
      "walletAddress": "0x1234567890abcdef1234567890abcdef1234568"
    },
    "meta": {}
  }
  ```
</CodeGroup>

### LoyaltyRuleStatus

<CodeGroup>
  ```json Sample Payload theme={null}
  {
    "id": "uuid-456e4567-e89b-12d3-a456-426614174003",
    "websiteId": "uuid-website-001",
    "organizationId": "uuid-org-001",
    "userId": "uuid-user-001",
    "loyaltyRuleId": "uuid-rule-001",
    "progress": 100,
    "fulfilledAt": "2025-08-01T15:58:15.753Z",
    "createdAt": "2025-08-01T15:58:15.741Z",
    "updatedAt": "2025-08-01T15:58:15.754Z",
    "loyaltyRule": {
      "id": "uuid-rule-001",
      "name": "Sample Loyalty Rule Name"
    },
    "user": {
      "id": "uuid-user-001",
      "walletAddress": "0x1234567890abcdef1234567890abcdef12345678"
    }
  }
  ```
</CodeGroup>
