> For the complete documentation index, see [llms.txt](https://docs.microart.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.microart.app/apps/cookie/creating-apps-for-cookie.md).

# Creating Apps for Cookie

Apps do not need any reprovisioning to be added to the Cookie store. However, there are optional *convenience* API's that give extra functionality to apps, like the subscriptions API.

### Adding your app to the Cookie DB

Currently, there is not easy way to add apps to the Cookie DB. Because Cookie is still under development, we are personally reaching out to developers to get apps on Cookie. If you still feel like your app should be on Cookie, you can send us an email at <cookie-submissions@microart.cf>.

### The Subscriptions API

Import `CookieApi.dll` into your project. Because the DLL is managed, it may require you to use a special loader if you are using a non-managed language. For C# you can directly import the DLL as is.

```csharp
using Cookie.Api;
```

Next we need to authorize our app with the Cookie servers before we can continue with requesting data.

```csharp
try
{
    var CookieService = await CookieApp.Provision(
        new CookieAppAuthentication(
            "my-app",
            "SECRET TOKEN",
            new string[]
            {
                "cookie.subscriptions.verify",
                "cookie.subscriptions.purchase",
            }
        )
    );
}
// Error handle
catch (Exception e) { }
```

Because Cookie needs to be synchronized with the users of your service and users in the Cookie DB, it uses a user-specific id. It is the apps responsibility of storing the id safely and passing it on to each Cookie request on behalf of the user.

```csharp
var UserId = MyAppSystem.GetUser().CookieId;
CookieService.SetUserId(UserId);
```

Now we can request the current subscription state from the Cookie servers.

```csharp
var Subscription = await CookieService.GetSubscriptionByName("myapp.premium");
if (Subscription.isActive)
{
    // Allow user to use app
}
else
{
    Subscription.ShowPaywall();
    // The showpaywall method asks the user to either close the app or renew
    // their subscription in cookie. Essentially locking the app from use.
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.microart.app/apps/cookie/creating-apps-for-cookie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
