Skip to main content

Set New Game Point Request

Schema for setting new game points via POST /api/v2/game-point/.

Description

This schema defines the request payload for setting or updating a player's game points for a specific tournament round. Players can be identified by either userId or walletAddress.

Class Validator Schema

import { IsNumber, IsOptional, IsString } from "class-validator";

export class SetNewGamePointRequestPayload {
@IsString()
roundId: string;

@IsString()
@IsOptional()
userId?: string;

@IsString()
@IsOptional()
walletAddress?: string;

@IsNumber()
score: number;

@IsString()
@IsOptional()
projectId: string | null;

@IsString()
roomId: string;
}

TypeScript Type

interface SetNewGamePointRequestPayload {
roundId: string;
userId?: string;
walletAddress?: string;
score: number;
projectId?: string | null;
roomId: string;
}

Example Request

{
"roundId": "round-123",
"userId": "user-456",
"score": 1500,
"projectId": "project-789",
"roomId": "room-abc"
}

Field Descriptions

FieldTypeRequiredDescription
roundIdstringYesUnique identifier for the game round
userIdstringNoUser identifier (optional if walletAddress provided)
walletAddressstringNoWallet address (optional if userId provided)
scorenumberYesGame score/points earned
projectIdstringNoAssociated project identifier
roomIdstringYesGame room/session identifier

Usage Example

// Submit new game score
const response = await fetch("https://api.intraverse.io//v2/game-point/", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"x-game-key": "your-game-client-key",
},
body: JSON.stringify({
roundId: "round-123",
userId: "user-456",
score: 1500,
projectId: "project-789",
roomId: "room-abc",
}),
});

const result = await response.json();

if (result.message === "Done") {
console.log("Score submitted successfully");
}

API Endpoint

This schema is used by the following endpoint:

  • POST /v2/game-point/ - Submit new game points

Authentication

This endpoint requires dual authentication:

User Authentication

  • JWT Bearer Token: Authorization: Bearer <jwt_token>
  • Purpose: Identifies the authenticated user
  • Scope: User must have valid authentication

Game Authentication

  • Game Key Header: x-game-key: <client_key>
  • Purpose: Identifies the game/application making the request
  • Validation: Game key must be valid and active

Example Request Headers

headers: {
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"x-game-key": "your-game-client-key"
}

Response Format

The endpoint returns a standard message response:

interface MessageResponse {
message: string;
}

Validation Rules

  • roundId: Must be a valid string
  • score: Must be a valid number
  • roomId: Must be a valid string
  • userId or walletAddress: At least one must be provided
  • projectId: Optional string or null

Next Steps