# Sigrex API

{% hint style="info" %}
This API uses **HMAC authentication**.\
Every request must be signed using your API secret.
{% endhint %}

{% tabs %}
{% tab title="Production" %}
**Base URL**

`https://api.sigrex.io/api/v2`
{% endtab %}
{% endtabs %}

***

#### Getting Started

{% stepper %}
{% step %}

#### Create an account

Create a Sigrex account in the dashboard.
{% endstep %}

{% step %}

#### Generate an API key

Navigate to **API Management** and create a new key.
{% endstep %}

{% step %}

#### Sign your request

All requests must include the following headers:

| Header        | Description            |
| ------------- | ---------------------- |
| `api-key`     | Your public API key    |
| `timestamp`   | Current unix timestamp |
| `signature`   | HMAC SHA256 signature  |
| {% endstep %} |                        |

{% step %}

#### Make your first request

`GET strategy/llm-session`
{% endstep %}
{% endstepper %}

***

#### Signature generation examples

{% hint style="info" %}
Signatures are generated using **HMAC SHA256** and your API secret.

GET / DELETE requests use:

METHOD + PATH + TIMESTAMP

POST / PUT requests use:

METHOD + PATH + BODY + TIMESTAMP
{% endhint %}

**TypeScript example (GET request)**

```ts
import crypto from "crypto"

const API_KEY = "your_public_api_key"
const API_SECRET = "your_private_api_secret"

const method = "GET"
const path = "/api/v2/strategy/llm-session"
const timestamp = Math.floor(Date.now() / 1000).toString()

const message = method + path + timestamp

const signature = crypto
  .createHmac("sha256", API_SECRET)
  .update(message)
  .digest("hex")

```

**TypeScript example (POST request)**

```ts
import crypto from "crypto"

const API_KEY = "your_public_api_key"
const API_SECRET = "your_private_api_secret"

const method = "POST"
const path = "/api/v2/strategy/llm-session"

const body = {
  name: "My Strategy",
  cron_interval: "15m"
}

const timestamp = Math.floor(Date.now() / 1000).toString()

const payload =
   method + path + JSON.stringify(body) + timestamp

const signature = crypto
  .createHmac("sha256", API_SECRET)
  .update(payload)
  .digest("hex")
  
```

***

#### Example request

```bash
curl https://api.sigrex.io/api/v2/strategy/sessions \
  -H "api-key: YOUR_API_KEY" \
  -H "timestamp: 1700000000" \
  -H "signature: GENERATED_SIGNATURE"
```

{% hint style="warning" %}
Never expose your **API secret** in frontend code.\
Always generate HMAC signatures on your backend.
{% endhint %}


---

# 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.sigrex.io/api-reference/reference/sigrex-api.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.
