# Decision Mode

### What is the Decision Mode?

When using Flagship, you will integrate either our APIs or our SDK in order to get some decisions for your visitor.

What we call a decision is selecting the correct set of flag keys & values that matches your visitor information (ID & context) with the use cases you set up inside the Flagship platform.

![1858](/files/4dQZQvm6k8rxPHgpEB3u)

### Different modes of Decision

You can get a decision from Flagship in 3 different ways:

#### Decision API - Cloud

When calling our Cloud Decision API directly or using one of our SDKs, you rely on the API to do the whole decision-making.

You send it your visitor information & your environment ID, and the API does the heavy lifting of computing the use cases for which the targeting matches the visitor context, and sending back the use case information such as flag keys & values to you. You can then directly use those values to customize or experiment your visitor experience.

The Decision API also does the following additional work:

* Tracking of the visitor context for report filtering purpose
* Persisting visitor/variation assignment to make sure the visitor always sees the same variation in the case of experimentation

#### Decision API - Self Hosted

You can self-host the Decision API in your own infrastructure. The self-hosted version uses the same core decision engine than the cloud version, in order to guarantee decision consistency between the hosting modes.

You can use our docker image or the generated binary to host the API. Once you run it on your infrastructure, the API will regularly poll your environment configuration (use cases, panic mode, etc...).\
When you call the API, it does the decision logic such as targeting and variation assignment.

The Decision API - Self Hosted still calls the Flagship data collection API to track visitor context for report filtering and to send hit tracking. But those calls are asynchronous, and will not block the main call for the Decision.

Thus, depending on your infrastructure, the API call could be nearly instantaneous.

You can see more information in the [Github page of the project](https://github.com/flagship-io/decision-api)

#### Bucketing

The bucketing mode is offered with our SDKs. Contrary to the Decision API mode, when using Bucketing mode, the SDK actually does the heavy lifting.

The SDK will regularly poll what we call the Bucketing file (a JSON file containing your environment configurations such as use cases, panic mode, ...) and will compute the Decision logic such as targeting match with the visitor context, variation assignment, etc...

The SDK will also call the Flagship data collection API in order to track the visitor context for report filtering and sending the hits.

{% hint style="info" %}
Only SDKs can use the Bucketing mode because the Decision logic (targeting, variation assignments, caching, ...) is coded inside.

[Learn more](/server-side/concepts/bucketing.md)
{% endhint %}

### Summary

| Mode            | Decision execution                                                   | Frequency of HTTP calls                         | Location HTTP calls                                                     |
| --------------- | -------------------------------------------------------------------- | ----------------------------------------------- | ----------------------------------------------------------------------- |
| Decision API    | On the API                                                           | 1 call/visitor and context change               | Flagship serverless API                                                 |
| Self Hosted API | On the API                                                           | 1 call/visitor and context change               | <p>- Your infrastructure<br>- Flagship data collection for tracking</p> |
| Bucketing       | SDK (visitor's device for client SDK or your server for server SDKs) | <p>Long polling<br>(1 call every 2 minutes)</p> | <p>- Flagship CDN<br>- Flagship data collection for tracking</p>        |


---

# Agent Instructions: 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.abtasty.com/server-side/concepts/decision-mode.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.
