Mobile Betting · 09 / 26

Tool and API (Application Programming Interface) Contracts

The tool catalogue and contracts of the mobile betting platform: OpenAPI and MCP (Model Context Protocol) definitions, error model, idempotency and contract tests.

Why contracts come first

The tools are the only way the platform can change an account, a message or a restriction. Their contracts are the stable layer: the Microsoft Foundry build and the LangGraph build both call the same operations, and the evaluation set checks the same arguments. A strict contract makes the system testable, lets the tool gateway enforce policy and limits what a manipulated model can do.

The tool catalogue

ToolPurposeChanges dataSafe to retryScopeNeeds approval
get_player_summaryRead status, limits and exclusions, with identity maskedNoYesplayer.readNo
get_account_activitySummarise deposits, stakes, sessions and limit changesNoYesactivity.readNo
check_eligibilityRead the result of the age, location and exclusion rulesNoYeseligibility.readNo
search_termsRetrieve terms and house rules with citation and effective dateNoYesknowledge.readNo
get_dispute_evidenceBet, result source and settlement for a disputed betNoYesevidence.readNo
propose_interventionRecord a proposed intervention with reasonsYes, a proposal onlyYes, by keyintervention.proposeNo
apply_protectionSuppress marketing, pause bonuses, reality check, limit prompt, enforce exclusionYes, reduces risk onlyYes, by keyprotection.applyRule threshold or request: no. Otherwise a specialist
send_player_messageSend an approved intervention or service messageYesYes, by keymessage.sendApproved template and consent or service basis
restrict_accountRestrict play, pause withdrawals or hold funds beyond the rulesYesYes, by keyaccount.restrictAlways a named specialist or analyst
create_goodwillCredit goodwillYesYes, by keygoodwill.createAbove the limit: supervisor
draft_reportAssemble an evidence draft for a regulator or sports bodyYes, a draft onlyYes, by keyreport.draftFiling is a person's act

An operation, in OpenAPI

Applying a protection is the most sensitive automatic write. The operation accepts only actions that reduce risk, requires an idempotency key and a stated basis, and refuses any restrictive action.

player-protection-tools.openapi.yaml · excerpt
openapi: 3.1.0
info: { title: Player protection tools, version: 1.5.0 }
paths:
  /players/{player_id}/protections:
    post:
      operationId: apply_protection
      summary: Apply a protective action that only reduces risk. Reversible by a specialist.
      parameters:
        - { name: player_id, in: path, required: true, schema: { type: string } }
        - { name: Idempotency-Key, in: header, required: true, schema: { type: string, minLength: 16 } }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [action, basis]
              properties:
                action: { type: string, enum: [suppress_marketing, pause_bonuses, reality_check, limit_prompt, enforce_exclusion] }
                basis:  { type: string, enum: [rule_threshold, specialist_approved, player_request],
                          description: Why this action is allowed; specialist_approved needs specialist_id }
                specialist_id: { type: string }
                expires_at: { type: string, format: date-time }
      responses:
        "201": { description: Applied }
        "200": { description: Same Idempotency-Key replayed; returns the original action }
        "409": { description: Already in force }
        "422": { description: Action not permitted for this basis, or a restrictive action was requested }
        "403": { description: Caller scope failed }

A read tool, as an MCP definition

The platform sees tools through the Model Context Protocol. The definition repeats the constraints that matter: a bounded period, an enumerated list of what to include, no identity fields and read-only hints.

get_account_activity · MCP tool definition
{
  "name": "get_account_activity",
  "description": "Summarise a player's recent activity for a specialist: deposits, stakes, session length and limit changes over a period. Read only. No identity fields.",
  "inputSchema": {
    "type": "object",
    "required": ["player_id", "period_days"],
    "properties": {
      "player_id": { "type": "string" },
      "period_days": { "type": "integer", "minimum": 1, "maximum": 90 },
      "include": { "type": "array", "maxItems": 4,
                   "items": { "enum": ["deposits", "stakes", "sessions", "limit_changes"] } }
    }
  },
  "annotations": { "readOnlyHint": true, "idempotentHint": true }
}

Error model

CodeMeaningWhat the platform does
invalid_argumentA field failed validationRoute to a person with the reason; never retry unchanged
not_foundPlayer, bet or case unknownCheck the identifier; do not guess
conflictProtection already in force, or a case already closedRe-read state and reconsider; never force
forbiddenScope or approval check failedDo not retry; route to a person; raise a security event
rate_limitedToo many callsBack off, then queue
unavailableBackend down or timed outRetry once with the same key, then queue for a person

Rules every tool follows

  1. Idempotency

    Every write takes an idempotency key. A replay returns the original result and never creates a second one.

  2. Basis and approval

    A write states why it is allowed. The tool gateway checks the basis against the action and the caller's authority.

  3. Risk-reducing only

    Automatic tools can only reduce risk. A request for a restrictive action through an automatic tool is refused.

  4. Versioning

    Contracts are versioned. A breaking change is a new major version, run side by side until the evaluation set passes on it.

  5. Audit

    Each call writes an audit record with the arguments hash, the caller, the basis, the outcome and the trace identifier.

A lost response, a safe retry and a refused restriction A protection is applied but the response is lost. The platform retries once with the same idempotency key and receives the original action. A separate attempt to restrict an account through the automatic protection tool is refused and audited. Harm rules Tool gateway Account platform Audit log apply_protection suppress_marketing, key K1 check basis, action, scope apply, key K1 action P-6044 applied response lost: timeout unavailable retry once, same key K1 apply_protection, key K1 apply, key K1 key seen: return original P-6044, 200 P-6044 apply_protection restrict_play restrictive action not allowed here audit: refused unprocessable
A lost response, a safe retry and a refused restriction

Contract tests

Build this for your business

This example is a player protection and operations platform for a licensed betting operator, but the same pattern, deterministic rules for every hard duty, a governed gateway, runtime security, protect-first automation and measured quality, fits any regulated, customer-facing service. We can scope a pilot on your own systems.

Book a discovery call