---
title: "Send query to stats service"
method: POST
path: "/api/v1/services/stats/query"
tags: ["stats_service"]
---

# Send query to stats service

`POST /api/v1/services/stats/query`

## Query parameters

- `chain` 'mainnet' | 'testnet'

## Request body

- object
  - `project_id` integer, required
  - `name` string
  - `query` string
  - `gpt_message` string
  - `repeat_interval` integer — cyclic execution of requests

## Response `201`

Query result

- StatsQueryResult
  - `id` string, required
  - `name` string
  - `status` 'executing' | 'success' | 'error', required
  - `query` StatsQuery
    - `name` string
    - `addresses` string[]
    - `only_between` boolean
    - `sql` string
    - `gpt_message` string
    - `repeat_interval` integer — cyclic execution of requests
  - `type` 'graph' | 'base_query' | 'chat_gpt_query'
  - `estimate` StatsEstimateQuery
    - `approximate_time` integer, required
    - `approximate_usd_cost` number, required
    - `explain` string
  - `url` string
  - `meta_url` string
  - `spent_time` integer
  - `last_repeat_date` integer
  - `total_repetitions` integer
  - `total_usd_cost` number
  - `usd_cost` number
  - `error` string
  - `all_data_in_preview` boolean
  - `preview` array[]
    - string[]
  - `testnet` boolean, required
  - `is_gpt` boolean
  - `date_create` integer, required

## Other responses

- `400` — Something went wrong on client side
- `402` — Not enough funds
- `403` — Access token is missing or invalid
- `404` — The specified resource was not found
- `409` — Insufficient funds
- `500` — Something went wrong on server side

## Changes

- **2025-11-03** `2bdf8d394d1a` — 1 info
  - added the non-success response with the status `402`
- **2025-10-21** `356252841f50` — 1 breaking, 2 warning, 3 info
  - removed the required property `estimate/approximate_cost` from the response with the `201` status
  - removed the optional property `cost` from the response with the `201` status
  - removed the optional property `total_cost` from the response with the `201` status
  - added the optional property `total_usd_cost` to the response with the `201` status
  - …2 more
- **2025-03-14** `8f2ab3ccc15b` — 1 info
  - added the non-success response with the status `409`
- **2024-11-06** `dc03bb6c514d` — 3 info
  - added the new optional request property `name`
  - added the optional property `name` to the response with the `201` status
  - added the optional property `query/name` to the response with the `201` status
- **2024-03-22** `dbd561304b3b` — 2 info
  - added the new optional `query` request parameter `chain`
  - added the required property `testnet` to the response with the `201` status

[Full history](https://skmtc.dev/tonkeeper/apis/rest-api-to-ton-console/changes/api/v1/services/stats/query/post.md)

---

[API](https://skmtc.dev/tonkeeper/apis/rest-api-to-ton-console.md) · [All operations](https://skmtc.dev/tonkeeper/apis/rest-api-to-ton-console/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/tonkeeper/rest-api-to-ton-console/revisions/bffcc11719d3/schema)
