curl -X GET "https://gachabe-staging.fly.dev/api/v1/chests/550e8400-e29b-41d4-a716-446655440000/buy" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/vnd.api+json"
{
  "data": {
    "transaction_id": "txn_550e8400-e29b-41d4-a716-446655440000",
    "chest": {
      "type": "chest",
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "attributes": {
        "name": "Legendary Dragon Chest",
        "description": "A mystical chest containing rare dragon collectibles"
      }
    },
    "cost": {
      "currency": "gems",
      "amount": 500
    },
    "player_balance": {
      "gems": 1500,
      "coins": 10000
    },
    "purchased_at": "2024-01-15T14:30:00Z"
  },
  "meta": {
    "success": true,
    "message": "Chest purchased successfully"
  }
}
Purchase a chest using the associated currencies. This endpoint deducts the required currency from the player’s account and adds the chest to their inventory.
This operation is irreversible. Ensure the player has sufficient currency before calling this endpoint.

Path Parameters

id
string
required
Unique identifier of the chest to purchase. Must be a valid UUID format.
curl -X GET "https://gachabe-staging.fly.dev/api/v1/chests/550e8400-e29b-41d4-a716-446655440000/buy" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/vnd.api+json"
{
  "data": {
    "transaction_id": "txn_550e8400-e29b-41d4-a716-446655440000",
    "chest": {
      "type": "chest",
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "attributes": {
        "name": "Legendary Dragon Chest",
        "description": "A mystical chest containing rare dragon collectibles"
      }
    },
    "cost": {
      "currency": "gems",
      "amount": 500
    },
    "player_balance": {
      "gems": 1500,
      "coins": 10000
    },
    "purchased_at": "2024-01-15T14:30:00Z"
  },
  "meta": {
    "success": true,
    "message": "Chest purchased successfully"
  }
}

Response Fields

data
object
required
Purchase transaction details

Purchase Flow

1

Check chest availability

First, verify the chest exists and is available for purchase using the Get Chest Details endpoint.
Confirm the chest ID is valid and the chest is purchasable.
2

Verify player currency

Ensure the authenticated player has sufficient currency to purchase the chest.
You can check the player’s balance using the Get Player Profile endpoint.
3

Execute purchase

Call this endpoint to complete the purchase transaction.
This action immediately deducts currency from the player’s account.
4

Handle the response

Process the response to update your UI with the transaction results and new balance.
The chest is now available in the player’s inventory for opening.

Error Handling

After successful purchase, the chest will appear in the player’s inventory and can be opened using the Open Chest endpoint.