# GraphQL Explorer

Browse the complete GraphQL schema and run operations against the interactive explorer.

<!-- docs-source -->
Source: https://learning.monetizekit.app/docs/graphql
<!-- /docs-source -->

## GraphQL endpoint

`https://app.monetizekit.app/api/graphql`

> [!NOTE] Authentication and execution
>
> You can browse the schema and examples without signing in. Sign in and provide your own API token to execute live operations.

## Schema

### OBJECT Query

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `plan` | Plan | key: String! (required) | 4 | Get one plan with entitlements | No |
| `customers` | [Customer] | first: Int, after: String | 6 | List customers | No |
| `entitlementCheck` | EntitlementDecision | customerId: ID! (required), featureKey: String! (required) | 3 | Check one entitlement decision | No |
| `usageCounter` | UsageCounter | customerId: ID! (required), meterKey: String! (required) | 3 | Fetch usage counter | No |
| `creditBalance` | CreditBalance | customerId: ID! (required) | 3 | Fetch customer credits | No |

### OBJECT Mutation

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `createCustomer` | Customer | input: CreateCustomerInput! (required) | 5 | Create a customer | No |
| `submitUsage` | UsageEventResult | input: UsageEventInput! (required) | 5 | Submit usage event | No |

### OBJECT Subscription

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `usageUpdated` | UsageCounter | customerId: ID! (required) | 2 | Usage stream updates | No |

### OBJECT Customer

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |
| `externalId` | String! | None | 1 | — | No |
| `status` | String! | None | 1 | — | No |
| `subscriptions` | [SubscriptionPlan] | None | 2 | — | No |

### OBJECT Plan

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |
| `key` | String! | None | 1 | — | No |
| `name` | String! | None | 1 | — | No |
| `entitlements` | [Entitlement] | None | 3 | — | No |
| `legacyFlags` | [String] | None | 2 | — | Use entitlements instead of legacyFlags; removal v2.4 |

### OBJECT Entitlement

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `featureKey` | String! | None | 1 | — | No |
| `value` | String! | None | 1 | — | No |

### OBJECT EntitlementDecision

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `allowed` | Boolean! | None | 1 | — | No |
| `reason` | String! | None | 1 | — | No |

### OBJECT UsageCounter

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `meterKey` | String! | None | 1 | — | No |
| `current` | Int! | None | 1 | — | No |
| `limit` | Int | None | 1 | — | No |

### OBJECT CreditBalance

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `available` | Int! | None | 1 | — | No |
| `pending` | Int! | None | 1 | — | No |

### OBJECT SubscriptionPlan

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |
| `planKey` | String! | None | 1 | — | No |

### OBJECT UsageEventResult

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `accepted` | Boolean! | None | 1 | — | No |
| `eventId` | ID! | None | 1 | — | No |

### INPUT_OBJECT CreateCustomerInput

| Input field | Type | Required | Description |
| --- | --- | --- | --- |
| `externalId` | String! | yes | — |
| `name` | String | no | — |

### INPUT_OBJECT UsageEventInput

| Input field | Type | Required | Description |
| --- | --- | --- | --- |
| `customerId` | ID! | yes | — |
| `meterKey` | String! | yes | — |
| `value` | Int! | yes | — |

### OBJECT Webhook

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |
| `url` | String! | None | 1 | — | No |

### OBJECT Meter

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |
| `key` | String! | None | 1 | — | No |

### OBJECT Feature

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |
| `key` | String! | None | 1 | — | No |

### OBJECT LegacyPlan

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |

### INTERFACE Node

| Field | Type | Arguments | Complexity | Description | Deprecated |
| --- | --- | --- | --- | --- | --- |
| `id` | ID! | None | 1 | — | No |

## Curated examples

### Plan with entitlements

```graphql
query PlanWithEntitlements($key: String!) {
  plan(key: $key) {
    id
    key
    entitlements {
      featureKey
      value
    }
  }
}
```

Variables

```json
{
  "key": "starter_monthly"
}
```

### Customers with subscriptions

```graphql
query CustomersWithSubscriptions($first: Int) {
  customers(first: $first) {
    id
    externalId
    subscriptions {
      id
      planKey
    }
  }
}
```

Variables

```json
{
  "first": 20
}
```

### Single entitlement check

```graphql
query SingleEntitlement($customerId: ID!, $featureKey: String!) {
  entitlementCheck(customerId: $customerId, featureKey: $featureKey) {
    allowed
    reason
  }
}
```

Variables

```json
{
  "customerId": "cust_dev_1001",
  "featureKey": "analytics_export"
}
```

### Usage data

```graphql
query UsageData($customerId: ID!, $meterKey: String!) {
  usageCounter(customerId: $customerId, meterKey: $meterKey) {
    meterKey
    current
    limit
  }
}
```

Variables

```json
{
  "customerId": "cust_dev_1001",
  "meterKey": "api_requests"
}
```

### Credit balances

```graphql
query CreditBalances($customerId: ID!) {
  creditBalance(customerId: $customerId) {
    available
    pending
  }
}
```

Variables

```json
{
  "customerId": "cust_dev_1001"
}
```

## Shared query seed

### Shared: Plan Health

```graphql
query SharedPlanHealth($key: String!) {
  plan(key: $key) {
    id
    key
    name
  }
}
```

### Shared: Usage Check

```graphql
query SharedUsageCheck($customerId: ID!, $meterKey: String!) {
  usageCounter(customerId: $customerId, meterKey: $meterKey) {
    current
    limit
  }
}
```