vscgames
  • Welcome
  • Getting Started
    • CreateAPIKey
    • CreateMerchantKey
  • Products
  • Mutations
    • buyVoucher
    • FreeFireTopupOrder
    • DeltaForceTopupOrder
    • FreeFireMerchantTopup
    • DeltaForceMerchantTopupOrder
  • Queries
    • getProductsByCategory
    • getProductById
    • getOrderById
    • getUserOrders
    • getTopupsProducts
    • getTopupProduct
    • getPlayerDetails
    • getTopupOrder
    • getUserTopupOrders
  • REST API
    • COMING soon
  • CONTACT
    • Support
Powered by GitBook
On this page
  1. Mutations

buyVoucher

Last Updated 11th May, 2025

PreviousProductsNextFreeFireTopupOrder

Last updated 23 days ago

The buyVoucher mutation allows users to purchase game or service vouchers in desired quantities using their account balance. The system will deduct the total amount from the user, reduce stock from the product database, log the transaction, and send a Telegram notification.


🔗 Endpoint URL: Method: POST Content-Type: application/json


📂 Mutation Structure

mutation BuyVoucher($productId: Int!, $quantity: Int!) {
  buyVoucher(productId: $productId, quantity: $quantity) {
    code
    message
    codes
    productId
    categoryId
    name
    description
    price
    quantity
    totalCost
    status
    type
    timestamp
    orderId
  }
}

📥 Headers Required

  • apikey: Your valid API key.


📦 Parameters

Name
Type
Required
Description

productId

Int

✅

ID of the product to purchase

quantity

Int

✅

Number of codes to buy


✅ Successful Response

{
  "data": {
    "buyVoucher": {
      "code": 200,
      "message": "Voucher purchase successful",
      "codes": ["XXXX-YYYY-ZZZZ"],
      "productId": 1005,
      "categoryId": 2,
      "name": "FREE FIRE 110 DIAMONDS",
      "description": "Codes are stackable...",
      "price": 2,
      "quantity": 1,
      "totalCost": 2,
      "status": "completed",
      "type": "purchase",
      "timestamp": "2025-05-10T14:00:00.000Z",
      "orderId": "10112"
    }
  }
}

â›” Error Codes

Code
Description

401

API key missing or invalid

402

Insufficient balance

403

Invalid API key

404

Product not found

409

Insufficient product stock

500

Code pool corrupted or internal


🔮 Code Examples

Python

import requests

url = "https://api.vscgames.com/graphql"
headers = {
    "Content-Type": "application/json",
    "apikey": "your-api-key"
}

query = """
mutation BuyVoucher($productId: Int!, $quantity: Int!) {
  buyVoucher(productId: $productId, quantity: $quantity) {
    code
    message
    codes
    orderId
  }
}
"""

variables = {"productId": 1005, "quantity": 1}

response = requests.post(url, json={"query": query, "variables": variables}, headers=headers)
print(response.json())

JavaScript (Node.js)

const fetch = require("node-fetch");

const query = `
mutation BuyVoucher($productId: Int!, $quantity: Int!) {
  buyVoucher(productId: $productId, quantity: $quantity) {
    code
    message
    codes
    orderId
  }
}`;

const variables = {
  productId: 1005,
  quantity: 1
};

fetch("https://api.vscgames.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "apikey": "your-api-key"
  },
  body: JSON.stringify({ query, variables })
})
.then(res => res.json())
.then(data => console.log(data));
https://api.vscgames.com/graphql