Skip to main content

BuyBack Endpoints

This section documents the available endpoints for the BuyBack module.

Sync Buy Backs​

Synchronizes buyback transactions from the blockchain and updates the system records.

Endpoint​

POST /buy-back-jobs/sync-buy-backs

Authentication​

  • Requires API Key authentication
  • Restricted to CLOUD_SCHEDULES role

Description​

This endpoint triggers the synchronization of buyback transactions from the blockchain. It:

  1. Fetches the latest buyback transaction
  2. Retrieves current token price
  3. Processes new transactions
  4. Records buyback events
  5. Broadcasts updates via WebSocket

Response​

Success Response​

{
"status": "success"
}

Error Response​

{
"status": "failed"
}

Possible Error Cases​

  • Invalid API key
  • Insufficient permissions
  • Blockchain connection issues
  • Database operation failures
  • Missing token price data

WebSocket Events​

When new buybacks are processed, the following event is broadcast:

{
event: "TOKEN_BUYBACK",
message: {
id: string;
tokenAmount: number;
usdAmount: number;
date: Date;
txLink: string;
}[]
}