Get Current Batch
curl --request GET \
--url https://public.believe.app/v1/flywheel/batch/current \
--header 'x-believe-api-key: <api-key>'import requests
url = "https://public.believe.app/v1/flywheel/batch/current"
headers = {"x-believe-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-believe-api-key': '<api-key>'}};
fetch('https://public.believe.app/v1/flywheel/batch/current', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public.believe.app/v1/flywheel/batch/current",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-believe-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://public.believe.app/v1/flywheel/batch/current"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-believe-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://public.believe.app/v1/flywheel/batch/current")
.header("x-believe-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.believe.app/v1/flywheel/batch/current")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-believe-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"flywheelId": "<string>",
"tokenId": "<string>",
"mintAddress": "<string>",
"status": "AVAILABLE_TO_QUEUE",
"batchIndex": "<string>",
"vaultIndex": "<string>",
"multisig": "<string>",
"vaultAddress": "<string>",
"dateCreated": "2023-11-07T05:31:56Z",
"dateUpdated": "2023-11-07T05:31:56Z",
"initResult": {
"total": 123,
"totalSuccessful": 123,
"totalFailed": 123,
"successfulExecutions": [
{
"bundleId": "<string>",
"txHashes": [
"<string>"
]
}
],
"batchIndex": 123,
"failedTxMsg": "<string>"
},
"executeResult": {
"total": 123,
"totalSuccessful": 123,
"totalFailed": 123,
"successfulExecutions": [
{
"bundleId": "<string>",
"txHashes": [
"<string>"
]
}
],
"failedOnTransactionIndex": 123,
"failedStartTransactionIndex": 123,
"failedTxMsg": "<string>"
}
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Flywheel V1
Get Current Batch
This endpoint retrieves the currently active flywheel batch for a specific token, if one exists.
GET
/
v1
/
flywheel
/
batch
/
current
Get Current Batch
curl --request GET \
--url https://public.believe.app/v1/flywheel/batch/current \
--header 'x-believe-api-key: <api-key>'import requests
url = "https://public.believe.app/v1/flywheel/batch/current"
headers = {"x-believe-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-believe-api-key': '<api-key>'}};
fetch('https://public.believe.app/v1/flywheel/batch/current', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public.believe.app/v1/flywheel/batch/current",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-believe-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://public.believe.app/v1/flywheel/batch/current"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-believe-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://public.believe.app/v1/flywheel/batch/current")
.header("x-believe-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.believe.app/v1/flywheel/batch/current")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-believe-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"flywheelId": "<string>",
"tokenId": "<string>",
"mintAddress": "<string>",
"status": "AVAILABLE_TO_QUEUE",
"batchIndex": "<string>",
"vaultIndex": "<string>",
"multisig": "<string>",
"vaultAddress": "<string>",
"dateCreated": "2023-11-07T05:31:56Z",
"dateUpdated": "2023-11-07T05:31:56Z",
"initResult": {
"total": 123,
"totalSuccessful": 123,
"totalFailed": 123,
"successfulExecutions": [
{
"bundleId": "<string>",
"txHashes": [
"<string>"
]
}
],
"batchIndex": 123,
"failedTxMsg": "<string>"
},
"executeResult": {
"total": 123,
"totalSuccessful": 123,
"totalFailed": 123,
"successfulExecutions": [
{
"bundleId": "<string>",
"txHashes": [
"<string>"
]
}
],
"failedOnTransactionIndex": 123,
"failedStartTransactionIndex": 123,
"failedTxMsg": "<string>"
}
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Overview
The Get Current Batch endpoint retrieves the currently active flywheel batch for a specified token. This is useful for checking if there’s already an ongoing batch operation before creating a new one, or for getting the status of the current batch without needing to know the specific batch ID. Returnsnull if no current batch exists for the token.
Authentication
This endpoint requires API key authentication. The API key must have eitherburn or airdrop scopes.
To authenticate, provide your API key in the x-believe-api-key request header.
Example:
x-believe-api-key: your_actual_api_key_here
Rate Limiting
Requests to this endpoint are rate-limited to 10 requests per second per API key.Request
This endpoint requires no request body. The current batch is determined based on the authenticated API key.Example Request
GET /v1/flywheel/batch/current
x-believe-api-key: your_actual_api_key_here
Response Body
On success, the API returns either:- A JSON object containing the current batch information (same structure as
/batch/{batchId}) nullif no current batch exists for the token
Example Response (Current Batch Exists)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"flywheelId": "flywheel_abc123",
"tokenId": "token_def456",
"mintAddress": "So11111111111111111111111111111111111111112",
"status": "FINALIZED",
"batchIndex": "42",
"vaultIndex": "0",
"multisig": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"vaultAddress": "HF8dF3nXy48op4dgdNPc86vqG79JTta7wvEbAWW8NXKv",
"initResult": {
"total": 3,
"totalSuccessful": 3,
"totalFailed": 0,
"successfulExecutions": [
{
"bundleId": "a1b2c3d4e5f6789012345678901234567890abcdef",
"txHashes": ["3M9kLp8sVxT2YhF6bE4CfN7ZvB5TdP1JqJ8LoX2GbM4aC9eR", "7Q6nMjKsEgC8WfYpR2CeL5ZhB3TdN9PqJ4LoX7GbV1bF2sC"]
}
],
"batchIndex": 42
},
"dateCreated": "2025-01-27T12:00:00.000Z",
"dateUpdated": "2025-01-27T12:05:00.000Z"
}
Example Response (No Current Batch)
null
Batch Status Values
When a current batch exists, it will have one of these status values:| Status | Description |
|---|---|
AVAILABLE_TO_QUEUE | Batch has been created but not yet finalized for execution. |
FINALIZED | Batch has been finalized and is ready for execution approval. |
EXECUTED | Batch has been successfully executed (may still be “current” briefly). |
FAILED | Batch execution failed. |
Use Cases
- Pre-Creation Check: Verify no active batch exists before creating a new one.
- Status Monitoring: Get the current batch status without needing to store batch IDs.
- Workflow Management: Determine if your application should wait for current operations to complete.
- Error Recovery: Check if a batch is stuck in a particular state and needs intervention.
- Dashboard Display: Show users the current state of their token’s flywheel operations.
Integration Patterns
Before Creating New Batch
// Check for current batch before creating new one
const currentBatch = await getCurrentBatch(tokenId);
if (currentBatch) {
if (currentBatch.status === "FINALIZED") {
// Wait for execution or execute it
console.log("Batch ready for execution:", currentBatch.id);
} else if (currentBatch.status === "EXECUTED") {
// Previous batch completed, safe to create new one
await createNewBatch(pipelines);
} else {
// Batch still in progress
console.log("Batch in progress:", currentBatch.status);
}
} else {
// No current batch, safe to create new one
await createNewBatch(pipelines);
}
Status Monitoring Loop
// Monitor current batch until completion
let currentBatch;
do {
currentBatch = await getCurrentBatch(tokenId);
if (currentBatch && currentBatch.status === "FINALIZED") {
console.log("Batch ready for execution");
break;
}
await sleep(5000); // Wait 5 seconds
} while (currentBatch && currentBatch.status !== "EXECUTED");
Error Codes
The current batch endpoint can return specific error codes.| Error Code | Status | Description |
|---|---|---|
ERR_BATCH_CURRENT_FAILED | 500 | Failed to retrieve current batch information. |
Example Error Response
{
"error": "ERR_BATCH_CURRENT_FAILED",
"message": "Database connection failed"
}
Important Notes
-
Null Response: A
nullresponse is normal and indicates no current batch exists for the token. - Current Definition: A batch is considered “current” if it’s the most recent batch that hasn’t reached a final state.
-
State Transitions: Once a batch reaches
EXECUTEDorFAILEDstatus, it may no longer be considered “current” depending on your implementation. - Race Conditions: In high-frequency applications, check for current batch immediately before creating new ones to avoid conflicts.
- Token Scoping: This endpoint only returns batches for the specific token ID provided, ensuring proper isolation between different tokens.
Authorizations
Response
object | null
Current batch information or null if no current batch exists.
The unique batch identifier (UUID).
The flywheel this batch belongs to.
The token ID associated with this batch.
The Solana mint address for the token.
Current batch status.
Available options:
AVAILABLE_TO_QUEUE, FINALIZED, EXECUTED, FAILED The multisig batch index used for execution.
The vault index within the multisig.
The multisig wallet address.
The vault address for token operations.
ISO 8601 timestamp when the batch was created.
ISO 8601 timestamp when the batch was last updated.
Results from the batch initialization process (optional).
Show child attributes
Show child attributes
Results from the batch execution process (optional).
Show child attributes
Show child attributes