> For the complete documentation index, see [llms.txt](https://docs.hypertune.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hypertune.com/entitlements/guide.md).

# Guide

This guide builds on the [SDK quickstart](/getting-started/set-up-hypertune.md) and shows you how to model and manage your entitlements using Hypertune.

You'll learn how to:

* Create a custom input type to model the user's organization
* Create custom object types to model your entitlements
* Create flags that use those custom object types
* Access those flags to get entitlements in your code
* Update entitlements

## Prerequisites

[Set up Hypertune](/getting-started/set-up-hypertune.md)

## Create a custom input type to model the user's organization

Go to the **Schema** view in the dashboard and select the **Context** input type. Click the **+ Add** button to add a new field, enter a name, and select **New input type** from the Type dropdown.

<figure><img src="/files/cltg3gsDQpZ3GGv9HzVC" alt=""><figcaption></figcaption></figure>

Enter a name for the new input type and click **Create**.

<figure><img src="/files/KC1lrV5LXbzOgQzZjBI7" alt=""><figcaption></figcaption></figure>

By default the new input type has no fields.

Click **+ Add** to add a new field. Enter a name, set its type, and click **Create**.

<figure><img src="/files/lmLew9AZqs0w1BADfWeP" alt=""><figcaption></figcaption></figure>

Repeat for each field you want to add. You can switch to the code view to make this easier. Then click **Save**.

<figure><img src="/files/9CJ3Qcz78rzZNobzcUFS" alt=""><figcaption></figcaption></figure>

```graphql
input Organization {
  id: String!
  plan: Plan!
}

enum Plan { free, pro, enterprise }
```

## Create custom object types to model your entitlements

Go to the **Schema** view in the dashboard. Click the **+** button in the top-right of the sidebar. Select **Object**, enter a name, and click **Create**.

<figure><img src="/files/OlXl0n8H9qIZuj60de3o" alt=""><figcaption></figcaption></figure>

By default, the new object type has no fields.

Click **+ Add** to add a new field. Enter a name, set its type, and click **Create**.

<figure><img src="/files/niy548hGJlwj06ErT6D7" alt=""><figcaption></figcaption></figure>

Repeat for each field you want to add. You can switch to the code view to make this easier. Then click **Save**.

<figure><img src="/files/2XmZBbLNnYYEI2jxkLxB" alt=""><figcaption></figcaption></figure>

```graphql
type Entitlements {
  teamRolesEnabled: Boolean!
  maxTeamSize: Int!
  maxApiRequestsPerDay: Int!
  versionHistoryEnabled: Boolean!
}
```

## Create flags for your entitlements

Go to the **Flags** view in the dashboard. Click the **+** button in the top-right of the sidebar and select **Flag**.

<figure><img src="/files/hQjkuUCYIVpzae1gnrHD" alt=""><figcaption></figcaption></figure>

Enter a name, set its type to the one you created earlier, and click **Create**.

<figure><img src="/files/fEoTzZkjpXNHrNMfcP21" alt=""><figcaption></figcaption></figure>

Enter the initial values, then click **Save**.

<figure><img src="/files/36bNf0vK9JZa68LhPVgY" alt=""><figcaption></figcaption></figure>

## Access flags to get entitlements

Regenerate the client:

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

```bash
npx hypertune
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn hypertune
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm hypertune
```

{% endtab %}
{% endtabs %}

Then use the generated methods to access your flags:

{% code title="app/api/add-team-member/route.ts" %}

```typescript
import { waitUntil } from '@vercel/functions'
import { NextResponse } from 'next/server'
import addUserToTeam from '@/lib/addUserToTeam'
import getHypertune from '@/lib/getHypertune'
import getTeamSize from '@/lib/getTeamSize'

export const runtime = 'edge'

export async function POST(request: Request) {
  const hypertune = await getHypertune({ isRouteHandler: true })

  const { userId, teamId } = await request.json()

  const teamSize = getTeamSize()

  const maxTeamSize = hypertune.entitlements().maxTeamSize({
    args: {},
    fallback: 5,
  })

  waitUntil(hypertune.flushLogs())

  if (teamSize >= maxTeamSize) {
    return NextResponse.json(
      {
        error: 'Team size limit reached',
        teamSize,
        maxTeamSize,
        message: `Your team has reached the maximum size of ${maxTeamSize} members. Please upgrade your plan to add more members.`,
      },
      { status: 403 }
    )
  }

  const result = await addUserToTeam(userId, teamId)

  return NextResponse.json({
    success: true,
    currentTeamSize: teamSize + 1,
    maxTeamSize,
    result,
  })
}

```

{% endcode %}

## Update entitlements

Go to the **Flags** view in the dashboard, and select the nested flag for the entitlements you want to update from the left sidebar.

<figure><img src="/files/oNRD0xOiDtTtQKrxIyV3" alt=""><figcaption></figcaption></figure>

Make your changes, then open the **Diff** view to review them. Click **Save**.

<figure><img src="/files/6OOiEdpy4Jm0cCTBZlQz" alt=""><figcaption></figcaption></figure>

## Next steps

* Use Hypertune to manage your [pricing](/pricing/overview.md) too, and centralize all the configuration logic for your pricing and entitlements in a single system.
