> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/hackle-proxy/hackle-proxy-api.md).

# Hackle Proxy API

This document provides and describes the API for calling Hackle Proxy.

> 📘 Prerequisites
>
> This can be used after installing Hackle Proxy.

## Common Headers

To call the Hackle Proxy server, you must include the SDK Key in the Header. If the SDK Key is missing or does not match the SDK\_KEYS registered at server startup, an error will occur.

```
X-HACKLE-SDK-KEY: {YOUR_SDK_KEY}
```

## API

## 1. Variation

The Variation API determines the Variation to expose to a user.

```
POST /api/v1/variation
```

### 1.1 Request

```json
{
  "experimentKey" : number,
  "userId" : string
}
```

### 1.2 Response

Response status code : **200**

**Body**

```json
{
  "variation" : string // A, B, C, D, E, F, G, H, I, J
}
```

When an error occurs, you can identify the API issue by the following response codes:

* 400 : Bad Request - Occurs when the request body is missing or in an incorrect format.
* 401 : Unauthorized - Occurs when the SDK\_KEY in the header is missing or incorrect.
* 500 : Internal Server Error

## 2. Track

The Track API is used to track user events.

```
POST /api/v1/track
```

### 2.1 Request

```json
{
  "eventKey" : string,
  "userId" : string,
  "value" : number // Optional (default=0.0)
}
```

### 2.2 Response

Response status code : **202**\
When an error occurs, you can identify the API issue by the following response codes:

* 400 : Bad Request - Occurs when the request body is missing or in an incorrect format.
* 401 : Unauthorized - Occurs when the SDK\_KEY in the header is missing or incorrect.
* 500 : Internal Server Error


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.hackle.io/en/development-guide/hackle-proxy/hackle-proxy-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
