Airsoft Defence API

Documentation Version 1.2

Postman Download Postman Collection (JSON) Import the collection to test example requests in Postman.

Authentication

Request examples use synthetic identifiers and credential placeholders. Set API_TOKEN for examples that read it from the environment.

POST /api/login

Sign in with an account email and password to obtain a first-party Sanctum bearer token.

Replace the example credentials with your test account credentials. Keep passwords and tokens out of application logs.

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/login' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"email":"player@example.test","password":"REPLACE_WITH_TEST_PASSWORD"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/login", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"email":"player@example.test","password":"REPLACE_WITH_TEST_PASSWORD"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/login');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"email":"player@example.test","password":"REPLACE_WITH_TEST_PASSWORD"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/login",
    headers=headers,
    json=json.loads(r'''{"email":"player@example.test","password":"REPLACE_WITH_TEST_PASSWORD"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, no two-factor challenge)

{
  "token": "EXAMPLE_SANCTUM_TOKEN",
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player",
    "email": "player@example.test"
  }
}

Response (200, two-factor challenge required)

{
  "requires_2fa": true,
  "temp_token": "EXAMPLE_TEMP_TOKEN",
  "message": "Two-factor authentication code required."
}

The temporary token expires after five minutes. Send it to Verify two-factor code or Verify recovery code. Use the token from that response as the bearer credential.

Response (401, invalid credentials)

{"message": "Invalid credentials"}

Response (423, account on hold)

{"message": "This account is currently on hold."}

Use Session check to verify a stored bearer token. The same endpoint reports the renewed inactivity expiry when a Sanctum token is refreshed.

Two-Factor Authentication Endpoints

POST /api/two-factor/verify

Verify the 6-digit code from the user's authenticator app after initial login. On success, a new Bearer token is returned. You must use this token for all future API requests.

â„šī¸ After successful verification, a new Bearer token is returned in the token field. You must use this token for all subsequent API requests. The temporary token is no longer valid.

Request Body

Field Type Required Description
temp_token string Required Temporary token from login response
code string Required 6-digit code from authenticator app
curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/two-factor/verify' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"temp_token":"EXAMPLE_TEMP_TOKEN","code":"123456"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/two-factor/verify", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"temp_token":"EXAMPLE_TEMP_TOKEN","code":"123456"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/two-factor/verify');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"temp_token":"EXAMPLE_TEMP_TOKEN","code":"123456"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/two-factor/verify",
    headers=headers,
    json=json.loads(r'''{"temp_token":"EXAMPLE_TEMP_TOKEN","code":"123456"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, code accepted)

{
  "token": "EXAMPLE_SANCTUM_TOKEN",
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player",
    "email": "player@example.test"
  }
}

Response (401 - Token Expired)

{
  "message": "Invalid or expired temporary token. Please login again."
}

Response (400 - 2FA Not Enabled)

{
  "message": "Two-factor authentication is not enabled for this account."
}

Response (422 - Invalid Code)

{
  "message": "The provided code is invalid."
}

POST /api/two-factor/recovery

Use a recovery code instead of the 6-digit authenticator code. Recovery codes are single-use and will be removed after successful verification.

Request Body

Field Type Required Description
temp_token string Required Temporary token from login response
recovery_code string Required One of the user's recovery codes
curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/two-factor/recovery' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"temp_token":"EXAMPLE_TEMP_TOKEN","recovery_code":"EXAMPLE-CODE"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/two-factor/recovery", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"temp_token":"EXAMPLE_TEMP_TOKEN","recovery_code":"EXAMPLE-CODE"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/two-factor/recovery');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"temp_token":"EXAMPLE_TEMP_TOKEN","recovery_code":"EXAMPLE-CODE"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/two-factor/recovery",
    headers=headers,
    json=json.loads(r'''{"temp_token":"EXAMPLE_TEMP_TOKEN","recovery_code":"EXAMPLE-CODE"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200 - Success)

{
  "token": "EXAMPLE_ACCESS_TOKEN",
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "John Blake",
    "email": "user@example.test"
  }
}

Response (401 - Token Expired)

{
  "message": "Invalid or expired temporary token. Please login again."
}

Response (400 - 2FA Not Enabled)

{
  "message": "Two-factor authentication is not enabled for this account."
}

Response (422 - Invalid Recovery Code)

{
  "message": "The provided recovery code is invalid."
}

OAuth2 Authentication & External Integration

🔑 OAuth2 for Third-Party Integrations

This API supports two OAuth2 grant types. Pick the one that matches your integration - they are not interchangeable:

  • Client Credentials - server-to-server, no end user involved. Your backend exchanges a client_id/client_secret directly for a token scoped to the client-creator's permissions.
  • Authorization Code - use this when your integration needs to act as a specific logged-in user of this system (not the client creator). The user is sent to a login/consent screen in their browser and, after approving, your app receives a code at your redirect_uri which you exchange for a token.

Important: OAuth client-management endpoints (/api/oauth/clients*) require a Sanctum login token (user session context). OAuth bearer tokens are then used for ongoing unattended API calls.

New retailer installations can use Connect a Store Integration to create an installation-specific client and get retailer consent.

Getting Started with OAuth2

What is OAuth2?

OAuth2 is an industry-standard authentication protocol for secure API access. Unlike login tokens (which are tied to users), OAuth2 clients represent applications and can access resources on behalf of their creating user.

When to Use OAuth2

Use OAuth2 when:

  • Building an external application that needs API access
  • Integrating with third-party services
  • Creating automated workflows or scheduled tasks
  • Providing long-lived credentials to partners
  • Avoiding password sharing with external systems

When to Use Regular Login

Use the regular login endpoint when:

  • Building a web or mobile application for end users
  • User authentication is needed (login/logout)
  • Access is tied to a specific user's permissions
  • Short-lived sessions are preferred

Key Differences

Feature Regular Login (Sanctum) OAuth2 (Passport)
Credentials Email + Password Client ID + Client Secret
Token Duration Session-based 15 days (or refresh)
Use Case User applications External integrations
Permissions User's permissions Linked user permissions + client scopes (fixed at creation time)
Revocation Logout or password change Deactivate client or revoke all tokens

Client Credentials vs. Authorization Code

Aspect client_credentials authorization_code
Who is acting? The OAuth client itself, as the user who created it Whichever site user logs in and approves your app
Requires a browser? No - pure server-to-server HTTP call Yes - the resource owner must visit /oauth/authorize in a browser to log in and approve
Uses redirect_uri? No - stored on the client but never used Yes - the authorization code is delivered via a redirect to this exact URL
Token endpoint call grant_type=client_credentials grant_type=authorization_code with the received code

Connect a Store Integration

Each installation connects with its own Passport client. The retailer signs in on Airsoft Defence, completes any required 2FA, and approves one of their linked, approved stores. They can revoke the installation from Authorised Apps.

  1. Persist a random installation UUID and generate a fresh PKCE verifier on the integration server. Compute the challenge as the unpadded base64url SHA-256 digest of the verifier. Retain the verifier with the initiating administrator's pending attempt.
  2. Create the connection attempt and open its approval URL in the retailer's browser.
  3. After approval, Return to your integration submits attempt_id and approval_proof by form POST to the supplied HTTPS callback. Stage the proof against the existing local attempt. The browser might omit the integration's session cookie on the cross-site POST. Resume on an authenticated page and require the initiating administrator, management permission and a CSRF-protected local action before exchanging credentials.
  4. Redeem the attempt from the integration server. Call the token endpoint with grant_type=authorization_code, client_id, client_secret, code (from authorization_code), redirect_uri and your original code_verifier. Use the same token endpoint for refresh.

Store the returned store ID with the installation. Its bearer token can run an exact UUID or member ID lookup and check defence status while the retailer retains access to the approved store. Reconnect with the same UUID and callback to rotate this installation's credentials and, if needed, select a different approved store.

POST /api/integrations/store/connections

Start a ten-minute connection attempt. Send JSON with installation_id, code_challenge and redirect_uri. Use an HTTPS callback with a domain name and a fixed path. Simple query parameters such as ?handler=connect are supported. Omit URL credentials, custom ports, fragments and encoded path segments.

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/integrations/store/connections' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"installation_id":"a66f8330-848f-4eb7-879c-0820c6d37b5d","redirect_uri":"https://shop.example.com/integrations/airsoft-defence/callback","code_challenge":"E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/integrations/store/connections", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"installation_id":"a66f8330-848f-4eb7-879c-0820c6d37b5d","redirect_uri":"https://shop.example.com/integrations/airsoft-defence/callback","code_challenge":"E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/integrations/store/connections');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"installation_id":"a66f8330-848f-4eb7-879c-0820c6d37b5d","redirect_uri":"https://shop.example.com/integrations/airsoft-defence/callback","code_challenge":"E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/integrations/store/connections",
    headers=headers,
    json=json.loads(r'''{"installation_id":"a66f8330-848f-4eb7-879c-0820c6d37b5d","redirect_uri":"https://shop.example.com/integrations/airsoft-defence/callback","code_challenge":"E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (201, connection attempt)

{
  "attempt_id": "5c025a50-cf56-4d7e-9b21-ab62cd487465",
  "approval_url": "https://airsoft-defence.co.uk/integrations/store/connect/5c025a50-cf56-4d7e-9b21-ab62cd487465",
  "expires_at": "2026-11-27T14:10:00+00:00"
}

POST /api/integrations/store/connections/{attemptId}/redeem

Exchange the original verifier and the callback proof for this installation's client credentials and a Passport code. Keep credentials, codes and proofs out of browser URLs, diagnostics and logs. The example proof must be replaced with the value posted by the approval page.

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/integrations/store/connections/5c025a50-cf56-4d7e-9b21-ab62cd487465/redeem' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"code_verifier":"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk","approval_proof":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/integrations/store/connections/5c025a50-cf56-4d7e-9b21-ab62cd487465/redeem", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"code_verifier":"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk","approval_proof":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/integrations/store/connections/5c025a50-cf56-4d7e-9b21-ab62cd487465/redeem');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"code_verifier":"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk","approval_proof":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/integrations/store/connections/5c025a50-cf56-4d7e-9b21-ab62cd487465/redeem",
    headers=headers,
    json=json.loads(r'''{"code_verifier":"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk","approval_proof":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, redeemed)

{
  "client_id": "00000000-0000-4000-8000-000000000105",
  "client_secret": "EXAMPLE_INSTALLATION_SECRET",
  "authorization_code": "EXAMPLE_PASSPORT_CODE",
  "redirect_uri": "https://shop.example.com/integrations/airsoft-defence/callback",
  "scope": "user:limited",
  "store": {
    "id": "00000000-0000-4000-8000-000000000122",
    "name": "Example Airsoft Store"
  }
}

Response (409, approval pending)

{"message":"Retailer approval is pending."}

Invalid proof or lost eligibility returns 403. An expired, used or superseded attempt returns 410 and requires a new connection attempt. Invalid input returns 422. Back off on 429.

OAuth2 Quick Start (5 Steps)

Step 1: Create an OAuth Client

An OAuth client represents your external application. Only the user setting up the integration needs to do this.

Use the four create-client request examples. Keep the returned credentials from data.client_id and data.client_secret in your integration secret store.

Step 2: Store the Credentials Securely

Save the client_id and client_secret in a secure configuration file or environment variable. NEVER commit them to version control or share them publicly.

# .env file (git ignored)
      OAUTH_CLIENT_ID=00000000-0000-4000-8000-000000000105
OAUTH_CLIENT_SECRET=EXAMPLE_CLIENT_SECRET
OAUTH_API_URL=https://airsoft-defence.co.uk
// config.php (git ignored)
$config = [
    'oauth_client_id' => '00000000-0000-4000-8000-000000000105',
    'oauth_client_secret' => 'EXAMPLE_CLIENT_SECRET',
    'oauth_api_url' => 'https://airsoft-defence.co.uk',
];
# docker-compose.yml or kubernetes secrets
environment:
  - OAUTH_CLIENT_ID=00000000-0000-4000-8000-000000000105
  - OAUTH_CLIENT_SECRET=EXAMPLE_CLIENT_SECRET
  - OAUTH_API_URL=https://airsoft-defence.co.uk

Step 3: Request an Access Token

Every time your application starts or needs API access, exchange your credentials for an access token.

Use the token request examples. Request profile:read to run the profile read example below.

Step 4: Use the Token to Call API Endpoints

Include the access token in the Authorization: Bearer header for all API requests. OAuth and login tokens use the same header format, but OAuth calls are additionally constrained by the OAuth client's assigned scopes.

# Step 4: Call API with Token
      curl -X GET "https://airsoft-defence.co.uk/api/profile" \
  -H "Authorization: Bearer YOUR_OAUTH_TOKEN" \
  -H "Accept: application/json"
// Step 4: Call API with Token
const token = 'YOUR_OAUTH_TOKEN';

fetch('https://airsoft-defence.co.uk/api/profile', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Profile:', data);
});
<?php
// Step 4: Call API with Token
$token = 'YOUR_OAUTH_TOKEN';

$ch = curl_init('https://airsoft-defence.co.uk/api/profile');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

# Step 4: Call API with Token
token = 'YOUR_OAUTH_TOKEN'

response = requests.get(
  'https://airsoft-defence.co.uk/api/profile',
    headers={
        'Authorization': f'Bearer {token}',
        'Accept': 'application/json'
    }
)

data = response.json()
print(f"Profile: {data}")

Step 5: Handle Token Expiration

Use expires_in from the token response to track expiry. For client credentials, obtain a new access token when needed. The examples below run on a backend.

// Automatically refresh token on 401
class OAuthClient {
  constructor(clientId, clientSecret, apiUrl) {
    this.clientId = clientId;
    this.clientSecret = clientSecret;
    this.apiUrl = apiUrl;
    this.token = null;
  }

  async getToken() {
    const response = await fetch(`${this.apiUrl}/api/oauth/token`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        grant_type: 'client_credentials',
        scope: 'profile:read',
        client_id: this.clientId,
        client_secret: this.clientSecret
      })
    });
    const data = await response.json();
    this.token = data.access_token;
    return this.token;
  }

  async request(endpoint, options = {}) {
    if (!this.token) {
      await this.getToken();
    }

    const response = await fetch(`${this.apiUrl}${endpoint}`, {
      ...options,
      headers: {
        ...options.headers,
        'Authorization': `Bearer ${this.token}`
      }
    });

    // If 401, refresh and retry
    if (response.status === 401) {
      await this.getToken();
      return fetch(`${this.apiUrl}${endpoint}`, {
        ...options,
        headers: {
          ...options.headers,
          'Authorization': `Bearer ${this.token}`
        }
      });
    }

    return response;
  }
}

// Usage
const client = new OAuthClient('00000000-0000-4000-8000-000000000105', 'secret...', 'https://airsoft-defence.co.uk');
const response = await client.request('/api/profile');
import requests

class OAuthClient:
    def __init__(self, client_id, client_secret, api_url):
        self.client_id = client_id
        self.client_secret = client_secret
        self.api_url = api_url
        self.token = None

    def get_token(self):
        response = requests.post(
            f'{self.api_url}/api/oauth/token',
            json={
                'grant_type': 'client_credentials',
                'scope': 'profile:read',
                'client_id': self.client_id,
                'client_secret': self.client_secret
            }
        )
        self.token = response.json()['access_token']
        return self.token

    def request(self, endpoint, **kwargs):
        if not self.token:
            self.get_token()

        headers = kwargs.get('headers', {})
        headers['Authorization'] = f'Bearer {self.token}'
        kwargs['headers'] = headers

        response = requests.get(f'{self.api_url}{endpoint}', **kwargs)

        # Refresh token on 401
        if response.status_code == 401:
            self.get_token()
            headers['Authorization'] = f'Bearer {self.token}'
            response = requests.get(f'{self.api_url}{endpoint}', **kwargs)

        return response

# Usage
client = OAuthClient('00000000-0000-4000-8000-000000000105', 'secret...', 'https://airsoft-defence.co.uk')
response = client.request('/api/profile')

OAuth2 Permission Scopes

When you create an OAuth client, it automatically receives scopes based on your user permissions. Scopes determine what actions the client can perform on the API.

Available Scopes

Scope Permission Description
player:read View Players List and view player information
player:create Create Players Create new player records
player:update Edit Players Modify existing player records
player:delete Delete Players Remove player records
site:read View Sites List and view airsoft site information
site:create Create Sites Create new site records
site:update Edit Sites Modify existing site records
store:read View Stores List and view retail store information
store:create Create Stores Create new store records
store:update Edit Stores Modify existing store records
game:read View Games List and view game information
game:create Create Games Create new game records
game:update Edit Games Modify existing game records
payment:read View Payments List and view payment records
payment:create Create Payments Create new payment records
payment:update Edit Payments Modify existing payment records
audit:read View Audit Logs Access audit trail and change logs
role:read View Roles List and view role information
role:assign Assign Roles Grant roles to users
police-hold:read View Police Holds List and view police hold records
police-hold:create Create Police Holds Create new police hold records
police-hold:update Edit Police Holds Modify existing police hold records
user:read View Users List and view user information
user:update Edit Users Modify existing user records
profile:read View Profile Access your own profile
profile:update Edit Profile Modify your own profile

How Scopes Work

  • Automatic Assignment: When you create an OAuth client, it gets all the scopes corresponding to your current permissions.
  • Fixed at Creation: A client's scopes are determined when it's created and don't change if your permissions change later.
  • Token scopes. Request the specific scopes your integration needs. The API checks the signed token, the stored token, the client configuration and the acting account's current permissions.
  • Full Permission Inheritance: If you have access to an endpoint, your OAuth clients will too.

POST /api/oauth/clients

Create a new OAuth client for integration with external applications.

Requires: any of user-full, user-limited, or user-restricted.

Request Body

Field Type Required Description
name string Required Human-readable name for the client (e.g., "Third-party Integration")
redirect_uri string (URL) Required Must exactly match the URL your app expects the authorization code to be delivered to. Only used by the authorization_code flow - if you only need client_credentials, any valid URL you control still satisfies validation, but it will never receive traffic.
description string Optional Purpose and description of this client

Response (201 - Created)

{
  "data": {
    "id": "00000000-0000-4000-8000-000000000105",
    "name": "My Integration",
    "description": "Integration with external system",
    "client_id": "00000000-0000-4000-8000-000000000105",
    "client_secret": "EXAMPLE_CLIENT_SECRET",
    "scopes": ["player:read", "player:create"],
    "is_active": true,
    "created_at": "2026-02-24T10:00:00Z"
  },
  "message": "OAuth client created successfully. Store the client_secret securely!"
}
curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/oauth/clients' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"name":"Example integration","redirect_uri":"https://partner.example.test/oauth/callback"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/clients", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"name":"Example integration","redirect_uri":"https://partner.example.test/oauth/callback"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/clients');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"name":"Example integration","redirect_uri":"https://partner.example.test/oauth/callback"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/oauth/clients",
    headers=headers,
    json=json.loads(r'''{"name":"Example integration","redirect_uri":"https://partner.example.test/oauth/callback"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

GET /api/oauth/clients

List all OAuth clients created by your user account.

Response (200 - Success)

{
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000105",
      "name": "My Integration",
      "description": "Integration with external system",
      "scopes": ["player:read", "player:create"],
      "is_active": true,
      "last_used_at": "2026-02-24T14:30:00Z",
      "created_at": "2026-02-24T10:00:00Z"
    }
  ]
}
curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/oauth/clients' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/clients", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/clients');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/oauth/clients",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

DELETE /api/oauth/clients/{clientId}

Revoke (disable) an OAuth client. All existing tokens for this client become invalid immediately.

Response (200 - Success)

{
  "message": "OAuth client revoked successfully"
}
curl --fail-with-body --request DELETE \
  --url 'https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105", {
  method: 'DELETE',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "DELETE",
    "https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

GET /api/oauth/clients/{clientId}

Get details for one OAuth client owned by the authenticated user.

Response (200 - Success)

{
  "data": {
    "id": "00000000-0000-4000-8000-000000000105",
    "name": "My Integration",
    "description": "Integration with external system",
    "scopes": ["player:read"],
    "is_active": true
  }
}
curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

PUT /api/oauth/clients/{clientId}

Update mutable fields for an OAuth client you own.

Request Body

{
  "name": "Partner Integration v2",
  "description": "Updated purpose",
  "is_active": true
}

Response (200 - Success)

{
  "data": {
    "id": "00000000-0000-4000-8000-000000000105",
    "name": "Partner Integration v2",
    "description": "Updated purpose",
    "is_active": true
  },
  "message": "OAuth client updated successfully"
}
curl --fail-with-body --request PUT \
  --url 'https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"name":"Example integration v2","is_active":true}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105", {
  method: 'PUT',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"name":"Example integration v2","is_active":true}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"name":"Example integration v2","is_active":true}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "PUT",
    "https://airsoft-defence.co.uk/api/oauth/clients/00000000-0000-4000-8000-000000000105",
    headers=headers,
    json=json.loads(r'''{"name":"Example integration v2","is_active":true}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

GET /api/oauth/available-scopes

Return OAuth scopes derived from the authenticated user's permissions.

Response (200 - Success)

{
  "data": ["player:read", "profile:read"],
  "count": 2
}
curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/oauth/available-scopes' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/available-scopes", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/available-scopes');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/oauth/available-scopes",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

POST /api/oauth/token

Exchange client credentials, an authorization code or a refresh token for an access token.

Request Body - client_credentials

{
  "grant_type": "client_credentials",
  "client_id": "00000000-0000-4000-8000-000000000105",
  "client_secret": "YOUR_CLIENT_SECRET",
  "scope": "profile:read"
}

Request Body - authorization_code

Send the original redirect_uri and the code from browser consent or store integration redemption. Include the original code_verifier if you used PKCE. Store integration connections always use PKCE.

{
  "grant_type": "authorization_code",
  "client_id": "00000000-0000-4000-8000-000000000105",
  "client_secret": "YOUR_CLIENT_SECRET",
  "redirect_uri": "https://partner.example.test/oauth/callback",
  "code": "THE_CODE_FROM_THE_REDIRECT"
}

Client credentials request examples

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/oauth/token' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"grant_type":"client_credentials","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","scope":"profile:read"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/token", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"grant_type":"client_credentials","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","scope":"profile:read"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/token');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"grant_type":"client_credentials","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","scope":"profile:read"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/oauth/token",
    headers=headers,
    json=json.loads(r'''{"grant_type":"client_credentials","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","scope":"profile:read"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Authorization code exchange examples

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/oauth/token' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"grant_type":"authorization_code","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"https://partner.example.test/oauth/callback","code":"CODE_FROM_CALLBACK"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/token", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"grant_type":"authorization_code","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"https://partner.example.test/oauth/callback","code":"CODE_FROM_CALLBACK"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/token');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"grant_type":"authorization_code","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"https://partner.example.test/oauth/callback","code":"CODE_FROM_CALLBACK"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/oauth/token",
    headers=headers,
    json=json.loads(r'''{"grant_type":"authorization_code","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"https://partner.example.test/oauth/callback","code":"CODE_FROM_CALLBACK"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Refresh token request examples

Persist the replacement access token and refresh token together. Passport rotates the refresh token after a successful exchange.

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/oauth/token' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"grant_type":"refresh_token","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","refresh_token":"CURRENT_REFRESH_TOKEN"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/oauth/token", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"grant_type":"refresh_token","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","refresh_token":"CURRENT_REFRESH_TOKEN"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/oauth/token');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"grant_type":"refresh_token","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","refresh_token":"CURRENT_REFRESH_TOKEN"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/oauth/token",
    headers=headers,
    json=json.loads(r'''{"grant_type":"refresh_token","client_id":"00000000-0000-4000-8000-000000000105","client_secret":"YOUR_CLIENT_SECRET","refresh_token":"CURRENT_REFRESH_TOKEN"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, client credentials)

{"token_type":"Bearer","expires_in":1296000,"access_token":"EXAMPLE_ACCESS_TOKEN"}

Response (200, authorization code or refresh token)

{"token_type":"Bearer","expires_in":1296000,"access_token":"EXAMPLE_ACCESS_TOKEN","refresh_token":"EXAMPLE_REFRESH_TOKEN"}

GET /oauth/authorize

Browser-based login and consent screen for the authorization_code grant. This is not an API/AJAX endpoint - it must be opened as a full browser navigation (redirect the user's browser, or open a system browser/webview), because it relies on the user's normal site login session, not a Bearer token.

For store integrations, open the approval_url returned by the connection endpoint.

How to Integrate (Authorization Code Flow)

  1. Send the user's browser to the authorize URL with your client's details as query parameters:
    https://airsoft-defence.co.uk/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=profile%3Aread&state=RANDOM_STRING
    • redirect_uri must exactly match the value stored on the client when it was created.
    • state should be a random value you generate and verify on return, to protect against CSRF.
  2. If the user isn't already logged into this site, they'll be redirected to the normal login page first, then back to the consent screen.
  3. The user reviews the requested scopes and clicks Authorize or Cancel.
  4. On approval, the browser is redirected to your redirect_uri with a code and the state you sent:
    https://partner.example.test/oauth/callback?code=AUTH_CODE&state=RANDOM_STRING
    On denial, it's redirected with an error parameter instead - no code is issued.
  5. Verify the returned state matches what you sent, then exchange the code for an access token at POST /api/oauth/token on your backend using grant_type=authorization_code. The code is single-use and short-lived. Keep the client secret on your backend.
# Inspect the initial response. Complete consent in the user's browser.
curl --get --dump-header - --output /dev/null \
  --url "https://airsoft-defence.co.uk/oauth/authorize" \
  --data-urlencode "client_id=$OAUTH_CLIENT_ID" \
  --data-urlencode "redirect_uri=https://partner.example.test/oauth/callback" \
  --data-urlencode "response_type=code" \
  --data-urlencode "scope=profile:read" \
  --data-urlencode "state=$OAUTH_STATE"
// Browser navigation. Exchange the returned code on your backend.
const state = crypto.randomUUID();
sessionStorage.setItem('oauth_state', state);
const url = new URL("https://airsoft-defence.co.uk/oauth/authorize");
url.search = new URLSearchParams({
  client_id: 'YOUR_CLIENT_ID',
  redirect_uri: 'https://partner.example.test/oauth/callback',
  response_type: 'code',
  scope: 'profile:read',
  state
});
window.location.assign(url);
<?php
session_start();
$_SESSION['oauth_state'] = bin2hex(random_bytes(32));
$query = http_build_query([
    'client_id' => getenv('OAUTH_CLIENT_ID'),
    'redirect_uri' => 'https://partner.example.test/oauth/callback',
    'response_type' => 'code',
    'scope' => 'profile:read',
    'state' => $_SESSION['oauth_state'],
], '', '&', PHP_QUERY_RFC3986);

header('Location: https://airsoft-defence.co.uk/oauth/authorize?' . $query, true, 302);
exit;
from os import environ
from secrets import token_urlsafe
from urllib.parse import urlencode
import webbrowser

state = token_urlsafe(32)
query = urlencode({
    "client_id": environ["OAUTH_CLIENT_ID"],
    "redirect_uri": "https://partner.example.test/oauth/callback",
    "response_type": "code",
    "scope": "profile:read",
    "state": state,
})
# Retain state in your application session to verify the callback.
webbrowser.open("https://airsoft-defence.co.uk/oauth/authorize?" + query)

Note: the resulting access token is scoped to the logged-in user who approved the request, not the user who originally created the OAuth client. Two different partners calling the same API endpoint through this flow, as two different site users, will get different data/permissions.

OAuth2 Troubleshooting

📋 Common Issues and Solutions

1. "Invalid client_id or client_secret"
  • Check that you're using the correct client_id (UUID string)
  • Verify the client_secret matches exactly (copy-paste from creation)
  • Ensure quotes are correct in JSON requests
2. Token requests return 401
  • The client may have been revoked - check your clients list
  • Try creating a new client with fresh credentials
  • Verify the OAuth client endpoint is correct: https://airsoft-defence.co.uk/api/oauth/token
3. "Unauthorized" when calling API with OAuth token
  • The token may have expired - request a new one
  • Check that the Authorization header format is correct: Bearer TOKEN_HERE
  • Ensure the OAuth client is still active (not revoked/deactivated)
  • Verify your user has permissions for the endpoint you're calling
4. "This action is unauthorized" on API call
  • Your user account doesn't have the required permission
  • Client credentials act for the client owner. Authorisation-code credentials act for the account that consented. Both require an applicable scope on the issued token and current account permission.
  • Ask an admin to grant you the required permission, then create a new client
6. API returns 400 for a valid token
  • 400 often means request payload/query is invalid, not auth failure
  • Example: /api/metrics requires ?metric=... query parameter
5. Cannot see client_secret after creation
  • This is expected and secure! Save the client_secret immediately after creation
  • If lost, you must create a new client
  • Store the secret in a secure config file or environment variable
7. "invalid_client" / "The redirect URI is malformed or missing" on /oauth/authorize
  • The redirect_uri query parameter must exactly match (scheme, host, path, trailing slash) the value stored on the client at creation - update the client via PUT /api/oauth/clients/{id} if it changed
  • /oauth/authorize must be opened as a real browser navigation - calling it with curl/fetch/axios will not work, it needs the logged-in session and renders an HTML consent page
8. User is redirected to login instead of the consent screen
  • Expected behavior if the user isn't already logged into this site in that browser - they'll land on the consent screen automatically after logging in
9. Token exchange with grant_type=authorization_code fails with "invalid_grant"
  • Authorization codes are single-use and short-lived - request a fresh code if the exchange didn't happen immediately
  • redirect_uri in the token request must match the one used on the original /oauth/authorize request exactly
  • Make sure you're not reusing a code that was already exchanged

🔍 Testing Your Integration

Quick test checklist:

  1. ✓ Can I create an OAuth client with a Sanctum login token?
  2. ✓ Can I get a token with my client_id and client_secret?
  3. ✓ Can I call /api/profile and /api/users/details with the token?
  4. ✓ Do the results match my user permissions?
  5. ✓ Blakes the token still work until expiry (typically 15 days unless revoked)?

💡 Best Practices

  • Keep secrets safe: Never commit client_secret to version control
  • Use environment variables: Store credentials in .env files or secrets managers
  • Handle token expiration: Implement automatic token refresh
  • Monitor usage: Check last_used_at to find inactive clients
  • Rotate credentials: Periodically create new clients and revoke old ones
  • Log API calls: Track what your integration is doing for debugging
  • Test thoroughly: Verify scopes and permissions before going live

Users

Code examples: Full cURL, JavaScript, PHP, and Python request examples for each Users endpoint are provided in the Users Extra section below.

Response Visibility By Permission

  • ID types: primary resource IDs (user/player/site/store) are UUID strings. Role/permission IDs are numeric.
  • user-restricted: `GET /api/users/{user}` and `GET /api/players/{player}` return limited fields only.
  • audit-list: adds audit relationships on user/player/site/store detail endpoints.
  • game-list: adds `games.site` on player detail endpoint.
  • police-list: exposes police hold collections on player detail responses.
  • police-private: adds `private_note` in police hold responses; otherwise omitted.
  • Role scope filtering: `/api/games` and `/api/games/count` are filtered by role (admin/staff vs site vs player).

GET /api/users/details

Returns the authenticated user's complete profile information including roles, photos, and assigned sites/stores. No fields are restricted—you always receive your full user data.

Requires: any of user-full, user-limited, user-restricted, or user-list.

curl -X GET "https://airsoft-defence.co.uk/api/users/details" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/users/details', {
      method: 'GET',
      headers: {
          'Authorization': `Bearer ${token}`,
          'Accept': 'application/json'
      }
    })
    .then(response => response.json())
    .then(data => {
        console.log('User details:', data.user);
    });
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/users/details');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
$user = $data['user'];
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/users/details'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    user = data['user']
    print(f"User: {user['name']}")

Response (200 - Success)

{
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "member_id": "EXAMPLE0001",
    "forename": "Alex",
    "surname": "Carter",
    "name": "Alex Carter",
    "address_1": "10 Example Lane",
    "address_2": null,
    "city": "Sampletown",
    "region": "Example City",
    "postcode": "ZZ1 1ZZ",
    "phone": "07700900001",
    "dob": "1984-11-07T00:00:00.000000Z",
    "email": "user@example.test",
    "police_hold": 0,
    "verified": {
      "id": true,
      "name": true,
      "email": true,
      "phone": true,
      "photo": true,
      "address": true
    },
    "terms_accept": "2026-03-28T18:09:21.000000Z",
    "two_factor_enabled_at": null,
    "created_at": "2023-05-01T10:13:54.000000Z",
    "updated_at": "2026-03-28T18:09:21.000000Z",
    "deleted_at": null,
    "roles": [
      { "id": 7, "name": "Player" }
    ],
    "photos": [],
    "stores": [],
    "sites": []
  }
}

Response (401, sign-in required)

{
  "message": "Unauthenticated."
}

Response (403, access denied)

{
  "message": "Forbidden."
}

GET /api/users/ids

Retrieve user IDs using cursor pagination for efficient processing of very large user sets.

Query Parameters

Parameter Type Required Description
per_page integer Optional Number of IDs per request (default: 100, min: 1, max: 1000)
cursor string Optional Cursor token from the previous response (next_cursor or prev_cursor)
curl -X GET "https://airsoft-defence.co.uk/api/users/ids?per_page=500" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"

# Use the returned next_cursor for the next batch
curl -X GET "https://airsoft-defence.co.uk/api/users/ids?per_page=500&cursor=EXAMPLE_CURSOR" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const perPage = 500;
let cursor = null;

const fetchBatch = () => {
  const params = new URLSearchParams({ per_page: perPage });
  if (cursor) {
    params.set('cursor', cursor);
  }

  return fetch(`https://airsoft-defence.co.uk/api/users/ids?${params.toString()}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('User IDs:', data.data);
  cursor = data.next_cursor;
  console.log('Next cursor:', cursor);
});
};

fetchBatch();
<?php
$token = 'YOUR_TOKEN_HERE';
$perPage = 500;
$cursor = null; // set from previous response next_cursor

$url = "https://airsoft-defence.co.uk/api/users/ids?per_page={$perPage}";
if ($cursor) {
    $url .= '&cursor=' . urlencode($cursor);
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
$nextCursor = $data['next_cursor'] ?? null;
?>
import requests

token = 'YOUR_TOKEN_HERE'
per_page = 500
cursor = None  # set from previous response next_cursor
params = {'per_page': per_page}
if cursor:
  params['cursor'] = cursor

url = 'https://airsoft-defence.co.uk/api/users/ids'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, params=params, headers=headers)
data = response.json()

print(f"User IDs: {data['data']}")
print(f"Next cursor: {data['next_cursor']}")

Response (200, last page)

{
  "data": [
    "00000000-0000-4000-8000-000000000101"
  ],
  "path": "https://airsoft-defence.co.uk/api/users/ids",
  "per_page": 100,
  "next_cursor": null,
  "next_page_url": null,
  "prev_cursor": null,
  "prev_page_url": null
}

Notes

Required Permission

user-list

GET /api/users

Retrieve a paginated list of all users with their basic information.

Query Parameters

Parameter Type Required Description
page integer Optional Page number (default: 1)
curl -X GET "https://airsoft-defence.co.uk/api/users?page=1" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const page = 1;

fetch(`https://airsoft-defence.co.uk/api/users?page=${page}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Users:', data.data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$page = 1;

$ch = curl_init("https://airsoft-defence.co.uk/api/users?page={$page}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
page = 1
url = f'https://airsoft-defence.co.uk/api/users?page={page}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Users: {data['data']}")

Response (200, restricted list, abbreviated)

{
  "current_page": 1,
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Example Player",
      "member_id": "EXAMPLE0001",
      "postcode": "ZZ1 1ZZ"
    }
  ],
  "per_page": 20,
  "last_page": 1,
  "total": 1
}

Response (200, audit-authorised list, abbreviated)

{
  "current_page": 1,
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000101",
      "member_id": "EXAMPLE0001",
      "name": "Example Player",
      "postcode": "ZZ1 1ZZ",
      "email": "player@example.test",
      "roles": [
        {
          "id": 7,
          "name": "Player"
        }
      ]
    }
  ],
  "per_page": 20,
  "last_page": 1,
  "total": 1
}

GET /api/users/{user}

Retrieve detailed information for a specific user by their ID.

curl -X GET https://airsoft-defence.co.uk/api/users/00000000-0000-4000-8000-000000000101 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"
// Using Fetch API
const token = localStorage.getItem('api_token');
const userId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/users/${userId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => {
  console.log('User:', data.user);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$userId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/users/{$userId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
user_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/users/{user_id}'
headers = {
    'Authorization': f'Bearer {token}'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"User: {data['user']}")

Response (200, restricted user)

{
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player",
    "member_id": "EXAMPLE0001",
    "postcode": "ZZ1 1ZZ",
    "photos": []
  }
}

Response (200, broader profile, abbreviated)

{
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "member_id": "EXAMPLE0001",
    "name": "Example Player",
    "postcode": "ZZ1 1ZZ",
    "email": "player@example.test",
    "photos": []
  }
}

POST /api/users/password

Change your password by supplying the current password and a new password. Use a mobile bearer token issued by first-party login.

Request Body

Parameter Type Required Description
old_password string Required Current password
password string Required New password
password_confirmation string Required New password confirmation
curl -X POST https://airsoft-defence.co.uk/api/users/password \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -d '{"old_password":"OldPass123!","password":"NewPass456!","password_confirmation":"NewPass456!"}'
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/users/password', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    old_password: 'OldPass123!',
    password: 'NewPass456!',
    password_confirmation: 'NewPass456!'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Password changed:', data.success);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/users/password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'old_password' => 'OldPass123!',
    'password' => 'NewPass456!',
    'password_confirmation' => 'NewPass456!'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/users/password'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json'
}
payload = {
    'old_password': 'OldPass123!',
    'password': 'NewPass456!',
    'password_confirmation': 'NewPass456!'
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()

print(f"Password changed: {data['success']}")

Response (200 - Success)

{
    "success": true
}

Roles & Permissions

System Roles & Capabilities

The system has 6 user-facing roles with hierarchical permissions:

Admin

Full administrative access - Can manage all system resources including users, sites, stores, games, and player validations. Cannot modify permission/role structures.

  • Users: Create, update, list, delete, assign roles, view full details, validate players
  • Sites: Full CRUD operations, add/remove staff
  • Stores: Full CRUD operations, add/remove staff
  • Games: Full CRUD operations
  • Police Holds: List only
  • Audits: View audit logs
  • Roles: View roles only (no modification)
Staff

Staff member access - Can manage users, sites, stores, and validate players. Cannot delete sites/stores or view audit logs.

  • Users: Create, update, list, delete, assign roles, limited view, validate players
  • Sites: Create, update, list, add/remove staff (no delete)
  • Stores: Create, update, list, add/remove staff (no delete)
  • Games: Full CRUD operations
  • Police Holds: List only
Site

Site operator access - Can manage their own sites, players, and games. Limited user management.

  • Users: Update, list (limited view), validate players
  • Sites: Update own sites, list all, add/remove staff
  • Stores: List only
  • Games: Full CRUD operations
  • Players: Create player accounts
  • Police Holds: List only
Store

Retail store access - Can manage their stores and view limited player information.

  • Users: List (limited view)
  • Sites: List only
  • Stores: Create, update, list, add/remove staff
  • Games: List only
  • Police Holds: List only
Police

Police force access - Can manage police holds and view player information for law enforcement purposes.

  • Users: List (limited view)
  • Sites: List only
  • Stores: List only
  • Police Holds: Full CRUD operations including private holds
Player

Player access - Basic read-only access to view sites, stores, and own profile.

  • Users: Restricted view (ID, member ID, name, postcode, photos only)
  • Sites: List only
  • Stores: List only

Permission Naming Convention: Permissions follow a resource-action pattern (e.g., user-create, site-update, game-list). Each role is assigned specific permissions through a pivot table relationship.

Live Permission Matrix

This view shows every permission down the left and every public role across the top. A dot indicates that role currently has that permission.

Loading live role permission matrix...

GET /api/roles

Returns a list of all available roles with their associated permissions.

curl -X GET "https://airsoft-defence.co.uk/api/roles" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/roles', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Roles:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/roles');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/roles'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Roles: {data}")

Response (200 - Success)

[
  {
    "id": 1,
    "name": "Superuser",
    "guard_name": "web",
    "created_at": "2023-01-01T00:00:00.000000Z",
    "updated_at": "2023-01-01T00:00:00.000000Z",
    "permissions": [
      { "id": 1, "name": "user-create", "guard_name": "web" },
      { "id": 2, "name": "user-update", "guard_name": "web" }
    ]
  },
  {
    "id": 7,
    "name": "Player",
    "guard_name": "web",
    "created_at": "2023-01-01T00:00:00.000000Z",
    "updated_at": "2023-01-01T00:00:00.000000Z",
    "permissions": [
      { "id": 19, "name": "user-restricted", "guard_name": "web" }
    ]
  }
]

GET /api/roles/{role}

Returns detailed information about a specific role including all available permissions.

Path Parameters

Parameter Type Description
role integer The role ID (e.g. 7 for Player, 1 for Superuser)
curl -X GET "https://airsoft-defence.co.uk/api/roles/7" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const roleId = 7;

fetch(`https://airsoft-defence.co.uk/api/roles/${roleId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Role details:', data.role);
  console.log('Available permissions:', data.permissions);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$roleId = 7;
$ch = curl_init("https://airsoft-defence.co.uk/api/roles/{$roleId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
role_id = 7
url = f'https://airsoft-defence.co.uk/api/roles/{role_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    role = data['role']
    permissions = data['permissions']

Response (200, abbreviated permission catalogue)

{
  "role": {
    "id": 7,
    "name": "Player",
    "guard_name": "web",
    "permissions": [
      {
        "id": 19,
        "name": "user-restricted",
        "guard_name": "web"
      }
    ]
  },
  "permissions": [
    {
      "id": 19,
      "name": "user-restricted",
      "guard_name": "web"
    }
  ]
}

PUT /api/roles/{role}

Update a role's name and assigned permissions.

Path Parameters

Parameter Type Description
role string (UUID) The role ID

Request Body

Field Type Required Description
name string Required The role name
permissions array Required Array of permission objects with id field
curl -X PUT "https://airsoft-defence.co.uk/api/roles/00000000-0000-4000-8000-000000000117" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{  
    "name": "Player",
    "permissions": [
      { "id": 19 }
    ]
  }'
// Using Fetch API
const token = localStorage.getItem('api_token');
const roleId = 7;

fetch(`https://airsoft-defence.co.uk/api/roles/${roleId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    name: 'Player',
    permissions: [
      { id: 19 }
    ]
  })
})
.then(response => response.json())
.then(data => {
  console.log('Role updated:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$roleId = 7;
$ch = curl_init("https://airsoft-defence.co.uk/api/roles/{$roleId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'Player',
    'permissions' => [
        ['id' => 19]
    ]
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
role_id = 7
url = f'https://airsoft-defence.co.uk/api/roles/{role_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'name': 'Player',
    'permissions': [
        {'id': 19}
    ]
}

response = requests.put(url, json=payload, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Role updated: {data['name']}")

Response (200 - Success)

{
  "id": 7,
  "name": "Player",
  "guard_name": "web",
  "created_at": "2023-01-01T00:00:00.000000Z",
  "updated_at": "2024-01-15T12:00:00.000000Z",
  "permissions": [
    { "id": 19, "name": "user-restricted", "guard_name": "web" }
  ]
}

POST /api/roles/assign/{user}/{role}

Assign a role to a user.

Path Parameters

Parameter Type Description
user string (UUID) The user ID
role integer The role ID or exact role name. Read role IDs from GET /api/roles.
curl -X POST "https://airsoft-defence.co.uk/api/roles/assign/00000000-0000-4000-8000-000000000101/7" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const userId = '00000000-0000-4000-8000-000000000101';
const roleId = 7;

fetch(`https://airsoft-defence.co.uk/api/roles/assign/${userId}/${roleId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  if (data.success) {
    console.log('Role assigned successfully');
  }
});
<?php
$token = 'YOUR_TOKEN_HERE';
$userId = '00000000-0000-4000-8000-000000000101';
$roleId = 7;
$ch = curl_init("https://airsoft-defence.co.uk/api/roles/assign/{$userId}/{$roleId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
user_id = '00000000-0000-4000-8000-000000000101'
role_id = 7
url = f'https://airsoft-defence.co.uk/api/roles/assign/{user_id}/{role_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

if response.status_code == 200 and data['success']:
    print('Role assigned successfully')

Response (200 - Success)

{
    "success": true
}

POST /api/roles/assign/{user}

Replaces the account's assigned roles. Requires user-assignrole and authority over both the target account and the requested roles.

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/roles/assign/00000000-0000-4000-8000-000000000101' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"roles":["Player"]}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/roles/assign/00000000-0000-4000-8000-000000000101", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"roles":["Player"]}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/roles/assign/00000000-0000-4000-8000-000000000101');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"roles":["Player"]}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/roles/assign/00000000-0000-4000-8000-000000000101",
    headers=headers,
    json=json.loads(r'''{"roles":["Player"]}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200)

{"success":true,"roles":["Player"]}

An unauthorised assignment returns 403, an unknown account returns 404, and a missing or invalid role list returns 422.

Sites (Airsoft Fields)

GET /api/sites

Lists airsoft sites. Pending financial action counts are visible to authorised internal staff and to site users for their own site. An applicable OAuth scope is required when using integration credentials.

Query Parameters

Parameter Type Required Description
since datetime Optional Return sites updated since this datetime (ISO 8601 format)
site_typestringOptionalFilter by a configured site type key.
statusstringOptionalFilter by active, suspended, closed or archived.
searchstringOptionalLiteral partial match on name, address or phone. Maximum 100 characters.
curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/sites?search=Example&status=active' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/sites?search=Example&status=active", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/sites?search=Example&status=active');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/sites?search=Example&status=active",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, abbreviated)

{
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000118",
      "name": "Example Airsoft Site",
      "city": "Example Town",
      "postcode": "ZZ1 1ZZ",
      "phone": "07700900003",
      "updated_at": "2026-10-01T10:30:00.000000Z",
      "star_score": 0,
      "status": "active",
      "pending_site_actions_count": 0
    }
  ],
  "queried_at": "2026-10-01T10:31:00.000000Z"
}

POST /api/sites

Create a new airsoft site.

Request Body

Field Type Required Description
name string Required Site name
address_1 string Required Address line 1
address_2 string Optional Address line 2
city string Required City
region string Required Region/County
postcode string Required Postcode
phone string Optional Phone number
email string Optional Email address
website string Optional Website URL
curl -X POST https://airsoft-defence.co.uk/api/sites \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{  
    "name": "Example Airsoft Site",
    "address_1": "Unit X",
    "address_2": "Sample Business Park",
    "city": "Metro City",
    "region": "Greater Metro City",
    "postcode": "ZZ3 1ZZ",
    "phone": "07700900003",
    "email": "info@example.test",
    "website": "https://awesomeairsoft.example.com"
  }'
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';

fetch('https://airsoft-defence.co.uk/api/sites', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    name: 'Example Airsoft Site',
    address_1: 'Unit X',
    address_2: 'Sample Business Park',
    city: 'Metro City',
    region: 'Greater Metro City',
    postcode: 'ZZ3 1ZZ',
    phone: '07700900003',
    email: 'info@example.test',
    website: 'https://awesomeairsoft.example.com'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Site created:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$ch = curl_init("https://airsoft-defence.co.uk/api/sites");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'Example Airsoft Site',
    'address_1' => 'Unit X',
    'address_2' => 'Sample Business Park',
    'city' => 'Metro City',
    'region' => 'Greater Metro City',
    'postcode' => 'ZZ3 1ZZ',
    'phone' => '07700900003',
    'email' => 'info@example.test',
    'website' => 'https://awesomeairsoft.example.com'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/sites'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'name': 'Example Airsoft Site',
    'address_1': 'Unit X',
    'address_2': 'Sample Business Park',
    'city': 'Metro City',
    'region': 'Greater Metro City',
    'postcode': 'ZZ3 1ZZ',
    'phone': '07700900003',
    'email': 'info@example.test',
    'website': 'https://awesomeairsoft.example.com'
}

response = requests.post(url, json=payload, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Site created with ID: {data['id']}")

Response (200 - Success)

{
    "id": "00000000-0000-4000-8000-000000000118",
    "name": "Example Airsoft Site",
    "address_1": "Unit X",
    "address_2": "Sample Business Park",
    "city": "Metro City",
    "region": "Greater Metro City",
    "postcode": "ZZ3 1ZZ",
    "phone": "07700900003",
    "email": "info@example.test",
    "website": "https://awesomeairsoft.example.com",
    "details": null,
    "created_at": "2025-02-21T16:00:00.000000Z",
    "updated_at": "2025-02-21T16:00:00.000000Z",
    "deleted_at": null,
    "pending_site_actions_count": 0
}

GET /api/sites/{site}

Get details of a specific airsoft site.

When the authenticated user has site-uri-view (and passes ownership checks for Site/SiteManager roles), the response includes site.uri.lookup_code.

Path Parameters

Parameter Type Description
site string (UUID) The site ID
curl -X GET https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const siteId = '00000000-0000-4000-8000-000000000104';

fetch(`https://airsoft-defence.co.uk/api/sites/${siteId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Site details:', data.site);
  console.log('Can edit:', data.canEdit);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$siteId = '00000000-0000-4000-8000-000000000104';
$ch = curl_init("https://airsoft-defence.co.uk/api/sites/{$siteId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = '00000000-0000-4000-8000-000000000104'
url = f'https://airsoft-defence.co.uk/api/sites/{site_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    site = data['site']
    print(f"Site: {site['name']}")

Response (200 - Success)

{
    "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "name": "Example Airsoft Site",
        "address_1": "Unit X",
        "address_2": "Sample Business Park",
        "city": "Metro City",
        "region": "Greater Metro City",
        "postcode": "ZZ3 1ZZ",
        "phone": "07700900003",
        "email": "info@example.test",
        "website": "https://awesomeairsoft.example.com",
        "details": null,
        "created_at": "2023-05-10T10:00:00.000000Z",
        "updated_at": "2025-02-20T15:30:00.000000Z",
        "deleted_at": null,
        "uri": {
          "id": "00000000-0000-4000-8000-000000000119",
          "lookup_code": "SI_ABC12345",
          "uriable_type": "App\\Models\\Site",
          "uriable_id": "00000000-0000-4000-8000-000000000104"
        },
        "pending_site_actions_count": 0
    },
    "canEdit": true
}

PUT /api/sites/{site}

Update an existing airsoft site.

Path Parameters

Parameter Type Description
site string (UUID) The site ID

Request Body

Field Type Required Description
name string Optional Site name
address_1 string Optional Address line 1
address_2 string Optional Address line 2
city string Optional City
region string Optional Region/County
postcode string Optional Postcode
phone string Optional Phone number
email string Optional Email address
website string Optional Website URL
curl -X PUT https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{  
    "name": "Updated Site Name",
    "address_1": "Updated Address Line 1",
    "address_2": "Updated Address Line 2",
    "city": "North City",
    "region": "Greater North City",
    "postcode": "ZZ4 1ZZ",
    "phone": "07700900004",
    "email": "updated@example.test",
    "website": "https://updatedsite.example.com"
  }'
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const siteId = '00000000-0000-4000-8000-000000000104';

fetch(`https://airsoft-defence.co.uk/api/sites/${siteId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    name: 'Updated Site Name',
    address_1: 'Updated Address Line 1',
    address_2: 'Updated Address Line 2',
    city: 'North City',
    region: 'Greater North City',
    postcode: 'ZZ4 1ZZ',
    phone: '07700900004',
    email: 'updated@example.test',
    website: 'https://updatedsite.example.com'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Site updated:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$siteId = '00000000-0000-4000-8000-000000000104';
$ch = curl_init("https://airsoft-defence.co.uk/api/sites/{$siteId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'Updated Site Name',
    'address_1' => 'Updated Address Line 1',
    'address_2' => 'Updated Address Line 2',
    'city' => 'North City',
    'region' => 'Greater North City',
    'postcode' => 'ZZ4 1ZZ',
    'phone' => '07700900004',
    'email' => 'updated@example.test',
    'website' => 'https://updatedsite.example.com'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = 1
url = f'https://airsoft-defence.co.uk/api/sites/{site_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}
payload = {
    'name': 'Updated Site Name',
    'address_1': 'Updated Address Line 1',
    'address_2': 'Updated Address Line 2',
    'city': 'North City',
    'region': 'Greater North City',
    'postcode': 'ZZ4 1ZZ',
    'phone': '07700900004',
    'email': 'updated@example.test',
    'website': 'https://updatedsite.example.com'
}

response = requests.put(url, json=payload, headers=headers)
data = response.json()

if response.status_code == 200 and data['success']:
    print(f"Site updated: {data['site']['name']}")

Response (200 - Success)

{
    "success": true,
    "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "name": "Updated Site Name",
        "address_1": "Updated Address Line 1",
        "address_2": "Updated Address Line 2",
        "city": "North City",
        "region": "Greater North City",
        "postcode": "ZZ4 1ZZ",
        "phone": "07700900004",
        "email": "updated@example.test",
        "website": "https://updatedsite.example.com",
        "details": null,
        "created_at": "2023-05-10T10:00:00.000000Z",
        "updated_at": "2025-02-21T16:00:00.000000Z",
        "deleted_at": null,
        "pending_site_actions_count": 0
    }
}

POST /api/sites/{site}/photo

Upload a JPEG, PNG or WebP up to 10 MiB. The caller must manage this site or be uploading its first photo as the authorised creator.

Path Parameters

Parameter Type Description
site integer The site ID

Request Body

Field Type Required Description
photo file Required Image file (multipart/form-data)
curl -X POST https://airsoft-defence.co.uk/api/sites/1/photo \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json" \
  -F "photo=@/path/to/image.jpg"
// Using Fetch API with FormData
const token = 'YOUR_TOKEN_HERE';
const siteId = 1;
const fileInput = document.querySelector('input[type="file"]');
const formData = new FormData();
formData.append('photo', fileInput.files[0]);

fetch(`https://airsoft-defence.co.uk/api/sites/${siteId}/photo`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  },
  body: formData
})
.then(response => response.json())
.then(data => {
  console.log('Photo uploaded:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$siteId = 1;
$photoPath = '/path/to/image.jpg';

$ch = curl_init("https://airsoft-defence.co.uk/api/sites/{$siteId}/photo");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'photo' => new CURLFile($photoPath)
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = 1
url = f'https://airsoft-defence.co.uk/api/sites/{site_id}/photo'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}
files = {
    'photo': open('/path/to/image.jpg', 'rb')
}

response = requests.post(url, headers=headers, files=files)
data = response.json()

if response.status_code == 200:
    print(f"Photo uploaded: {data['site']['photos']}")

Response (200 - Success)

{
    "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "photos": [
            { "filename": "abc123.jpg", "path": "/storage/images/abc123.jpg" }
        ]
    }
}

POST /api/sites/{site}/attach-user/{user}

Add a staff member to a site the caller is authorised to manage.

Path Parameters

Parameter Type Description
site integer The site ID
user string (UUID) The user ID
curl -X POST https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/attach-user/00000000-0000-4000-8000-000000000101 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const siteId = 1;
const userId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/sites/${siteId}/attach-user/${userId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('User attached to site:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$siteId = 1;
$userId = '00000000-0000-4000-8000-000000000101';
$ch = curl_init("https://airsoft-defence.co.uk/api/sites/{$siteId}/attach-user/{$userId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = 1
user_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/sites/{site_id}/attach-user/{user_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"User attached. Staff count: {len(data['site']['staff'])}")

Response (200 - Success)

{
    "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "staff": [
            { "id": "00000000-0000-4000-8000-000000000101", "name": "John Blake" }
        ]
    }
}

POST /api/sites/{site}/remove-user/{user}

Remove a staff member from a site the caller is authorised to manage.

Path Parameters

Parameter Type Description
site integer The site ID
user string (UUID) The user ID
curl -X POST https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/remove-user/00000000-0000-4000-8000-000000000101 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const siteId = 1;
const userId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/sites/${siteId}/remove-user/${userId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('User removed from site:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$siteId = 1;
$userId = '00000000-0000-4000-8000-000000000101';
$ch = curl_init("https://airsoft-defence.co.uk/api/sites/{$siteId}/remove-user/{$userId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = 1
user_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/sites/{site_id}/remove-user/{user_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"User removed. Staff count: {len(data['site']['staff'])}")

Response (200 - Success)

{
    "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "staff": []
    }
}

GET /api/sites/count

Get the total count of sites in the system.

curl -X GET https://airsoft-defence.co.uk/api/sites/count \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';

fetch('https://airsoft-defence.co.uk/api/sites/count', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log(`Total sites: ${data.sites}`);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$ch = curl_init("https://airsoft-defence.co.uk/api/sites/count");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/sites/count'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Total sites: {data['sites']}")

Response (200 - Success)

{
    "sites": 12
}

GET /api/sites/{site}/history

Returns paginated game history. The requesting account must be linked to this site or be an authorised internal user. The endpoint also checks the site permission and, for OAuth, its scope.

Embedded player penalty totals require the penalty history permission and, for OAuth, an applicable scope.

Path Parameters

Parameter Type Description
site integer The site ID

Query Parameters

Parameter Type Description
page integer Page number (default: 1)
per_page integer Items per page (default: 25, maximum: 100).
from, toYYYY-MM-DDInclusive play dates. No date filters means all-time history. When either date is supplied, omitted dates use the web report defaults and the window is limited to 366 days.
searchstringLiteral partial match on player name or member ID. Maximum 100 characters.
curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/history?from=2026-11-01&to=2026-11-24&search=EXAMPLE0001&per_page=25' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/history?from=2026-11-01&to=2026-11-24&search=EXAMPLE0001&per_page=25", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/history?from=2026-11-01&to=2026-11-24&search=EXAMPLE0001&per_page=25');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/history?from=2026-11-01&to=2026-11-24&search=EXAMPLE0001&per_page=25",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200 - Success)

{
  "games": [
    {
      "id": "00000000-0000-4000-8000-000000000102",
      "site_id": "00000000-0000-4000-8000-000000000104",
      "player_id": "00000000-0000-4000-8000-000000000101",
      "play_date": "2024-06-10T14:30:00.000000Z",
      "created_at": "2024-06-10T14:35:00.000000Z",
      "player": {
        "id": "00000000-0000-4000-8000-000000000101",
        "member_id": "EXAMPLE0001",
        "forename": "John",
        "surname": "Quinn",
        "name": "Taylor Quinn"
      },
      "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "name": "Sample Airsoft Site",
        "postcode": "ZZ1 1ZZ"
      }
    }
  ],
  "games_count": 247,
  "pagination": {
    "current_page": 1,
    "per_page": 25,
    "total": 247,
    "last_page": 10,
    "has_more_pages": true,
    "next_page_url": "https://airsoft-defence.co.uk/api/sites/00000000-0000-4000-8000-000000000104/history?page=2",
    "prev_page_url": null
  }
}

Stores (Retail Shops)

GET /api/stores

Lists approved airsoft retail stores. Internal staff can also see pending records. OAuth clients need store update scope for that expanded view.

Query Parameters

Parameter Type Required Description
since datetime Optional Return stores updated since this datetime (ISO 8601 format).
searchstringOptionalLiteral partial match on name, address or phone. Maximum 100 characters.
curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/stores?search=Example' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/stores?search=Example", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/stores?search=Example');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/stores?search=Example",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, abbreviated)

{
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000122",
      "name": "Example Airsoft Store",
      "city": "Example Town",
      "postcode": "ZZ1 1ZZ",
      "phone": "07700900003",
      "updated_at": "2026-10-01T10:30:00.000000Z",
      "star_score": 0
    }
  ],
  "queried_at": "2026-10-01T10:31:00.000000Z"
}

POST /api/stores

Create a new store in the system.

Request Body

Field Type Required Description
name string Required Store name
address_1 string Required Primary address line
address_2 string Optional Secondary address line
city string Required City
region string Optional County/Region
postcode string Required Postal code
phone string Optional Phone number
curl -X POST "https://airsoft-defence.co.uk/api/stores" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"name": "Example Retail Store", "address_1": "100 Demo Plaza", "address_2": null, "city": "Metro City", "region": "Greater Metro City", "postcode": "ZZ3 1ZZ", "phone": "07700900003"}'
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const storeData = {
  name: 'Example Retail Store',
  address_1: '100 Demo Plaza',
  address_2: null,
  city: 'Metro City',
  region: 'Greater Metro City',
  postcode: 'ZZ3 1ZZ',
  phone: '07700900003'
};

fetch('https://airsoft-defence.co.uk/api/stores', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify(storeData)
})
.then(response => response.json())
.then(data => {
  console.log('Store created:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$storeData = [
    'name' => 'Example Retail Store',
    'address_1' => '100 Demo Plaza',
    'address_2' => null,
    'city' => 'Metro City',
    'region' => 'Greater Metro City',
    'postcode' => 'ZZ3 1ZZ',
    'phone' => '07700900003'
];

$ch = curl_init("https://airsoft-defence.co.uk/api/stores");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($storeData));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Content-Type: application/json',
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/stores'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
store_data = {
    'name': 'Example Retail Store',
    'address_1': '100 Demo Plaza',
    'address_2': None,
    'city': 'Metro City',
    'region': 'Greater Metro City',
    'postcode': 'ZZ3 1ZZ',
    'phone': '07700900003'
}

response = requests.post(url, headers=headers, json=store_data)
data = response.json()

if response.status_code == 201:
    print(f"Store created: {data['name']}")

Response (200, abbreviated)

{
  "id": "00000000-0000-4000-8000-000000000122",
  "name": "Example Airsoft Store",
  "address_1": "10 Example Lane",
  "postcode": "ZZ1 1ZZ"
}

GET /api/stores/{store}

Get details for a store. Pending records are visible to authorised staff and to the account that created the store. Other callers receive 404.

When the authenticated user has store-uri-view (and passes ownership checks for Store/StoreManager roles), the response includes store.uri.lookup_code.

curl -X GET "https://airsoft-defence.co.uk/api/stores/00000000-0000-4000-8000-000000000122" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const storeId = '00000000-0000-4000-8000-000000000122';

fetch(`https://airsoft-defence.co.uk/api/stores/${storeId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Store:', data.store);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$storeId = '00000000-0000-4000-8000-000000000122';
$ch = curl_init("https://airsoft-defence.co.uk/api/stores/{$storeId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
store_id = '00000000-0000-4000-8000-000000000122'
url = f'https://airsoft-defence.co.uk/api/stores/{store_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Store: {data['store']['name']}")

Response (200, abbreviated)

{
  "store": {
    "id": "00000000-0000-4000-8000-000000000122",
    "name": "Example Airsoft Store",
    "postcode": "ZZ1 1ZZ",
    "photos": [],
    "staff": []
  },
  "canEdit": true
}

POST /api/stores/{store}/photo

Upload a JPEG, PNG or WebP up to 10 MiB. The caller must manage this store or be uploading its first photo as the authorised creator.

curl -X POST "https://airsoft-defence.co.uk/api/stores/00000000-0000-4000-8000-000000000122/photo" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json" \
  -F "photo=@/path/to/store-photo.jpg"
// Using Fetch API with FormData
const token = 'YOUR_TOKEN_HERE';
const storeId = '00000000-0000-4000-8000-000000000122';
const formData = new FormData();
formData.append('photo', fileInput.files[0]);

fetch(`https://airsoft-defence.co.uk/api/stores/${storeId}/photo`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  },
  body: formData
})
.then(response => response.json())
.then(data => {
  console.log('Photo uploaded', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$storeId = '00000000-0000-4000-8000-000000000122';
$photoPath = '/path/to/store-photo.jpg';

$ch = curl_init("https://airsoft-defence.co.uk/api/stores/{$storeId}/photo");
$cfile = new CURLFile($photoPath, 'image/jpeg', 'photo.jpg');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['photo' => $cfile]);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
store_id = '00000000-0000-4000-8000-000000000122'
url = f'https://airsoft-defence.co.uk/api/stores/{store_id}/photo'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

with open('/path/to/store-photo.jpg', 'rb') as photo:
    files = {'photo': photo}
    response = requests.post(url, headers=headers, files=files)
    data = response.json()

if response.status_code == 200:
    print('Photo uploaded successfully')

Response (200, abbreviated)

{
  "store": {
    "id": "00000000-0000-4000-8000-000000000122",
    "name": "Example Airsoft Store",
    "postcode": "ZZ1 1ZZ",
    "photos": [
      {
        "id": "00000000-0000-4000-8000-000000000124",
        "path": "/storage/photos/stores/example-store.webp",
        "filename": "example-store.webp"
      }
    ],
    "staff": []
  }
}

POST /api/stores/{store}/attach-user/{user}

Assign a staff member to a store the caller is authorised to manage.

curl -X POST "https://airsoft-defence.co.uk/api/stores/00000000-0000-4000-8000-000000000122/attach-user/00000000-0000-4000-8000-000000000125" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const storeId = '00000000-0000-4000-8000-000000000122';
const userId = '00000000-0000-4000-8000-000000000125';

fetch(`https://airsoft-defence.co.uk/api/stores/${storeId}/attach-user/${userId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Staff assigned', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$storeId = '00000000-0000-4000-8000-000000000122';
$userId = '00000000-0000-4000-8000-000000000125';
$ch = curl_init("https://airsoft-defence.co.uk/api/stores/{$storeId}/attach-user/{$userId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
store_id = '00000000-0000-4000-8000-000000000122'
user_id = '00000000-0000-4000-8000-000000000125'
url = f'https://airsoft-defence.co.uk/api/stores/{store_id}/attach-user/{user_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print('Staff assigned successfully')

Response (200, abbreviated)

{
  "store": {
    "id": "00000000-0000-4000-8000-000000000122",
    "name": "Example Airsoft Store",
    "postcode": "ZZ1 1ZZ",
    "photos": [],
    "staff": [
      {
        "id": "00000000-0000-4000-8000-000000000125",
        "name": "Example Store Staff"
      }
    ]
  }
}

POST /api/stores/{store}/remove-user/{user}

Remove a staff member from a store the caller is authorised to manage.

curl -X POST "https://airsoft-defence.co.uk/api/stores/00000000-0000-4000-8000-000000000122/remove-user/00000000-0000-4000-8000-000000000125" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';
const storeId = '00000000-0000-4000-8000-000000000122';
const userId = '00000000-0000-4000-8000-000000000125';

fetch(`https://airsoft-defence.co.uk/api/stores/${storeId}/remove-user/${userId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Staff removed', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$storeId = '00000000-0000-4000-8000-000000000122';
$userId = '00000000-0000-4000-8000-000000000125';
$ch = curl_init("https://airsoft-defence.co.uk/api/stores/{$storeId}/remove-user/{$userId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
store_id = '00000000-0000-4000-8000-000000000122'
user_id = '00000000-0000-4000-8000-000000000125'
url = f'https://airsoft-defence.co.uk/api/stores/{store_id}/remove-user/{user_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print('Staff removed successfully')

Response (200, abbreviated)

{
  "store": {
    "id": "00000000-0000-4000-8000-000000000122",
    "name": "Example Airsoft Store",
    "postcode": "ZZ1 1ZZ",
    "photos": [],
    "staff": []
  }
}

GET /api/stores/count

Returns the total number of stores in the system.

curl -X GET "https://airsoft-defence.co.uk/api/stores/count" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = 'YOUR_TOKEN_HERE';

fetch('https://airsoft-defence.co.uk/api/stores/count', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Store count:', data.stores);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$ch = curl_init("https://airsoft-defence.co.uk/api/stores/count");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$token}",
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/stores/count'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Total stores: {data['stores']}")

Response (200 - Success)

{
    "stores": 8
}

URI Lookup

GET /api/games

Retrieve a paginated list of games. Results are automatically scoped by role:

Requires: game-list.

When caller also has penalty-point-history-view, each game includes penalty_points and active_penalty_points_count.

curl -X GET "https://airsoft-defence.co.uk/api/games" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/games', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Games:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/games');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/games'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Games: {data}")

Response (200 - Success)

{
  "current_page": 1,
  "per_page": 25,
  "total": 1854,
  "last_page": 75,
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000102",
      "user_id": "00000000-0000-4000-8000-000000000103",
      "site_id": "00000000-0000-4000-8000-000000000104",
      "play_date": "2023-05-01T00:00:00.000000Z",
      "deleted_at": null,
      "created_at": "2023-05-01T10:13:54.000000Z",
      "updated_at": "2023-05-01T10:13:54.000000Z",
      "site": {
        "id": "00000000-0000-4000-8000-000000000104",
        "name": "Sample Airsoft Site",
        "postcode": "ZZ2 1ZZ"
      },
      "player": {
        "id": "00000000-0000-4000-8000-000000000103",
        "name": "Casey Harper",
        "member_id": "EXAMPLE0002"
      }
    }
  ]
}

GET /api/games/{game}

Returns a record in the caller's attendance scope. Embedded site and player objects contain summary fields. Penalty fields require the history permission and an applicable scope when using OAuth.

Retrieve details of a specific game.

Requires: game-list.

When caller also has penalty-point-history-view, response includes penalty_points and active_penalty_points_count.

curl -X GET https://airsoft-defence.co.uk/api/games/00000000-0000-4000-8000-000000000102 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const gameId = '00000000-0000-4000-8000-000000000102';

fetch(`https://airsoft-defence.co.uk/api/games/${gameId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Game details:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$gameId = '00000000-0000-4000-8000-000000000102';

$ch = curl_init('https://airsoft-defence.co.uk/api/games/' . $gameId);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
game_id = '00000000-0000-4000-8000-000000000102'
url = f'https://airsoft-defence.co.uk/api/games/{game_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Game details: {data}")

Response (200 - Success)

{
  "id": "00000000-0000-4000-8000-000000000102",
  "user_id": "00000000-0000-4000-8000-000000000103",
  "site_id": "00000000-0000-4000-8000-000000000104",
  "play_date": "2023-05-01T00:00:00.000000Z",
  "deleted_at": null,
  "created_at": "2023-05-01T10:13:54.000000Z",
  "updated_at": "2023-05-01T10:13:54.000000Z",
  "site": {
    "id": "00000000-0000-4000-8000-000000000104",
    "name": "Sample Airsoft Site",
    "postcode": "ZZ2 1ZZ"
  },
  "player": {
    "id": "00000000-0000-4000-8000-000000000103",
    "name": "Casey Harper",
    "member_id": "EXAMPLE0002"
  }
}

GET /api/games/count

Get game counts for various time periods.

curl -X GET https://airsoft-defence.co.uk/api/games/count \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/games/count', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('All time:', data.all_time);
  console.log('Today:', data.today);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/games/count');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/games/count'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"All time: {data['all_time']}")
print(f"Today: {data['today']}")

Response (200 - Success)

{
  "all_time": 100,
  "this_month": 10,
  "this_week": 2,
  "today": 1
}

POST /api/games/checkin/{site}/{user}

Submit a player check-in for this game site. 201 Created acknowledges submission for processing. The game history shows the record after it is saved.

curl -X POST https://airsoft-defence.co.uk/api/games/checkin/00000000-0000-4000-8000-000000000104/00000000-0000-4000-8000-000000000101 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
      const token = localStorage.getItem('api_token');
      const siteId = '00000000-0000-4000-8000-000000000104';
      const userId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/games/checkin/${siteId}/${userId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => {
  if (response.status === 201) {
    console.log('Player check-in submitted');
  }
});
<?php
      $token = 'YOUR_TOKEN_HERE';
      $siteId = '00000000-0000-4000-8000-000000000104';
      $userId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/games/checkin/{$siteId}/{$userId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = '00000000-0000-4000-8000-000000000104'
user_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/games/checkin/{site_id}/{user_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)

if response.status_code == 201:
    print("Player check-in submitted")

Response (201 - Created)

{
        "message": "Check-in submitted for processing.",
        "site": {
            "id": "00000000-0000-4000-8000-000000000104",
            "name": "Sample Airsoft Site"
        },
        "player": {
            "id": "00000000-0000-4000-8000-000000000101",
            "name": "Sample Player"
        }
    }

Response (409 - Already Checked In)

{
  "message": "Sample Player has already checked in at Sample Airsoft Site today. Each site allows one self check-in per day."
}

POST /api/games/self-checkin/{site}

Submit a self check-in for the authenticated user. 201 Created acknowledges submission for processing. The game history shows the record after it is saved.

If the player is already checked in at the same site for today, returns 409 Conflict.

location is optional. Clients that support GPS should include a reading whenever one is available and the player has granted location access. The examples use sample coordinates. Send latitude and longitude in decimal degrees and accuracy in metres.

If the player declines location access, send {"location":{"status":"permission_denied"}} (20 points). If the device cannot obtain a fix, send {"location":{"status":"unavailable"}} (15 points). A supplied null, empty object or invalid fix also scores 15 unless it explicitly reports permission denial. Submit without waiting for a fix. The assessment is advisory and does not change the check-in response.

During the native app transition, clients without GPS support can omit the location field entirely to submit a check-in without a location assessment. The server applies system, site and player-specific exemptions before assessing any supplied location and uses a wider player-specific radius where configured.

curl -X POST https://airsoft-defence.co.uk/api/games/self-checkin/00000000-0000-4000-8000-000000000104 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  --data '{"location":{"latitude":51.5,"longitude":-0.12,"accuracy":18}}'
// Using Fetch API
const token = localStorage.getItem('api_token');
const siteId = '00000000-0000-4000-8000-000000000104';
const location = { latitude: 51.5, longitude: -0.12, accuracy: 18 };

fetch(`https://airsoft-defence.co.uk/api/games/self-checkin/${siteId}`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ location })
})
.then(response => response.json())
.then(data => {
  console.log('Self check-in response:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$siteId = '00000000-0000-4000-8000-000000000104';
$location = ['latitude' => 51.5, 'longitude' => -0.12, 'accuracy' => 18];

$ch = curl_init("https://airsoft-defence.co.uk/api/games/self-checkin/{$siteId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['location' => $location]));

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
site_id = '00000000-0000-4000-8000-000000000104'
url = f'https://airsoft-defence.co.uk/api/games/self-checkin/{site_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

location = {"latitude": 51.5, "longitude": -0.12, "accuracy": 18}
response = requests.post(url, headers=headers, json={"location": location})
data = response.json()

print(f"Status: {response.status_code}")
print(data)

Response (201 - Created)

{
  "message": "Check-in submitted for processing.",
  "site": {
    "id": "00000000-0000-4000-8000-000000000104",
    "name": "Sample Airsoft Site"
  }
}

Response (409 - Already Checked In)

{
  "message": "You have already checked in at Sample Airsoft Site today. Each site allows one self check-in per day."
}

Penalty Points

GET /api/penalty-point-types

Return all configured penalty point types used for issuing or editing penalty points.

Requires: any of penalty-point-edit, penalty-point-issue, or penalty-point-history-view.

curl -X GET https://airsoft-defence.co.uk/api/penalty-point-types \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/penalty-point-types', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
}).then(r => r.json()).then(console.log);
<?php
$ch = curl_init('https://airsoft-defence.co.uk/api/penalty-point-types');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer YOUR_TOKEN_HERE',
  'Accept: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
?>
import requests

response = requests.get(
    'https://airsoft-defence.co.uk/api/penalty-point-types',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN_HERE',
        'Accept': 'application/json'
    }
)
print(response.json())

Response (200 - Success)

{
  "penalty_point_types": [
    {
      "id": "00000000-0000-4000-8000-000000000106",
      "name": "Unsafe Eye Protection",
      "points": 3
    }
  ]
}

Response (401 Unauthenticated)

{
  "message": "Unauthenticated."
}

Response (403 Forbidden)

{
  "message": "Forbidden."
}

POST /api/penalty-points

Issue a new penalty point for a game.

Requires: penalty-point-issue.

Site/SiteManager rule: can only issue against games at linked site(s).

curl -X POST https://airsoft-defence.co.uk/api/penalty-points \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "game_id": "00000000-0000-4000-8000-000000000102",
    "penalty_point_type_id": "00000000-0000-4000-8000-000000000106",
    "note": "Chrono fail during spot check"
  }'
fetch('https://airsoft-defence.co.uk/api/penalty-points', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    game_id: '00000000-0000-4000-8000-000000000102',
    penalty_point_type_id: '00000000-0000-4000-8000-000000000106',
    note: 'Chrono fail during spot check'
  })
});
<?php
$payload = [
  'game_id' => '00000000-0000-4000-8000-000000000102',
  'penalty_point_type_id' => '00000000-0000-4000-8000-000000000106',
  'note' => 'Chrono fail during spot check',
];

$ch = curl_init('https://airsoft-defence.co.uk/api/penalty-points');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer YOUR_TOKEN_HERE',
  'Content-Type: application/json',
  'Accept: application/json'
]);
import requests

payload = {
  'game_id': '00000000-0000-4000-8000-000000000102',
  'penalty_point_type_id': '00000000-0000-4000-8000-000000000106',
  'note': 'Chrono fail during spot check',
}

response = requests.post(
  'https://airsoft-defence.co.uk/api/penalty-points',
  headers={
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Accept': 'application/json'
  },
  json=payload
)

Response (201, abbreviated)

{
  "success": true,
  "message": "Penalty point issued successfully.",
  "penalty_point": {
    "id": "00000000-0000-4000-8000-000000000110",
    "game_id": "00000000-0000-4000-8000-000000000102",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "issuer_id": "00000000-0000-4000-8000-000000000125",
    "penalty_point_type_id": "00000000-0000-4000-8000-000000000106",
    "note": "Example incident note",
    "recalled": false,
    "player": {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Example Player"
    },
    "issuer": {
      "id": "00000000-0000-4000-8000-000000000125",
      "name": "Example Staff"
    }
  }
}

Response (403 Forbidden (site scope))

{
  "message": "You can only manage penalty points for games at your own site(s)."
}

Response (404 Not Found)

{
  "message": "Game not found."
}

Response (422 Validation)

{
  "message": "The given data was invalid.",
  "errors": {
    "penalty_point_type_id": [
      "The selected penalty point type id is invalid."
    ]
  }
}

Response (422 Business Rule)

{
  "message": "This game already has an active penalty point applied."
}

PUT /api/penalty-points/{penaltyPoint}

Update type/note, optionally reinstate when recalled.

Requires: penalty-point-edit.

curl -X PUT https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "penalty_point_type_id": "00000000-0000-4000-8000-000000000106",
    "note": "Updated review note",
    "reinstate_on_update": false
  }'
fetch('https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    penalty_point_type_id: '00000000-0000-4000-8000-000000000106',
    note: 'Updated review note',
    reinstate_on_update: false
  })
});
<?php
$payload = [
  'penalty_point_type_id' => '00000000-0000-4000-8000-000000000106',
  'note' => 'Updated review note',
  'reinstate_on_update' => false,
];

$ch = curl_init('https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
import requests

response = requests.put(
  'https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107',
  headers={
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Accept': 'application/json'
  },
  json={
    'penalty_point_type_id': '00000000-0000-4000-8000-000000000106',
    'note': 'Updated review note',
    'reinstate_on_update': False
  }
)

Response (200, abbreviated)

{
  "success": true,
  "message": "Penalty point updated successfully.",
  "penalty_point": {
    "id": "00000000-0000-4000-8000-000000000110",
    "game_id": "00000000-0000-4000-8000-000000000102",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "issuer_id": "00000000-0000-4000-8000-000000000125",
    "penalty_point_type_id": "00000000-0000-4000-8000-000000000106",
    "note": "Example incident note",
    "recalled": false,
    "player": {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Example Player"
    },
    "issuer": {
      "id": "00000000-0000-4000-8000-000000000125",
      "name": "Example Staff"
    },
    "recalled_by": null
  }
}

Response (403 Forbidden)

{
  "message": "You do not have permission to reinstate a recalled penalty point."
}

Response (404 Not Found)

{
  "message": "Player not found."
}

Response (422 Validation)

{
  "message": "The given data was invalid.",
  "errors": {
    "penalty_point_type_id": [
      "The selected penalty point type id is invalid."
    ]
  }
}

POST /api/penalty-points/{penaltyPoint}/revoke

Revoke an active penalty point and remove it from active totals.

Requires: penalty-point-revoke.

Pseudocode Flow

if point already recalled -> return 422
if actor owns point player_id -> return 403
if actor not allowed for game site -> return 403
mark recalled=true and recalled_by=actor
audit change and return updated record
curl -X POST https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/revoke \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
fetch('https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/revoke', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Accept': 'application/json'
  }
});
<?php
$ch = curl_init('https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/revoke');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer YOUR_TOKEN_HERE',
  'Accept: application/json'
]);
import requests

response = requests.post(
  'https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/revoke',
  headers={
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Accept': 'application/json'
  }
)

Response (200, abbreviated)

{
  "success": true,
  "message": "Penalty point recalled successfully.",
  "penalty_point": {
    "id": "00000000-0000-4000-8000-000000000110",
    "game_id": "00000000-0000-4000-8000-000000000102",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "issuer_id": "00000000-0000-4000-8000-000000000125",
    "penalty_point_type_id": "00000000-0000-4000-8000-000000000106",
    "note": "Example incident note",
    "recalled": true,
    "player": {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Example Player"
    },
    "issuer": {
      "id": "00000000-0000-4000-8000-000000000125",
      "name": "Example Staff"
    },
    "recalled_by": {
      "id": "00000000-0000-4000-8000-000000000126",
      "name": "Example Reviewer"
    }
  }
}

Response (422 Already Recalled)

{
  "message": "This penalty point has already been recalled."
}

Response (403 Self-Revoke Block)

{
  "message": "You cannot recall a penalty point that belongs to your own game record."
}

Response (403 Site Scope)

{
  "message": "You can only manage penalty points for games at your own site(s)."
}

POST /api/penalty-points/{penaltyPoint}/reinstate

Reinstate a previously revoked penalty point.

Requires: penalty-point-revoke.

curl -X POST https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/reinstate \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
fetch('https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/reinstate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Accept': 'application/json'
  }
});
<?php
$ch = curl_init('https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/reinstate');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer YOUR_TOKEN_HERE',
  'Accept: application/json'
]);
import requests

response = requests.post(
  'https://airsoft-defence.co.uk/api/penalty-points/00000000-0000-4000-8000-000000000107/reinstate',
  headers={
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Accept': 'application/json'
  }
)

Response (200, abbreviated)

{
  "success": true,
  "message": "Penalty point reinstated successfully.",
  "penalty_point": {
    "id": "00000000-0000-4000-8000-000000000110",
    "game_id": "00000000-0000-4000-8000-000000000102",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "issuer_id": "00000000-0000-4000-8000-000000000125",
    "penalty_point_type_id": "00000000-0000-4000-8000-000000000106",
    "note": "Example incident note",
    "recalled": false,
    "player": {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Example Player"
    },
    "issuer": {
      "id": "00000000-0000-4000-8000-000000000125",
      "name": "Example Staff"
    },
    "recalled_by": null
  }
}

Response (422 Already Active)

{
  "message": "This penalty point is already active."
}

Response (403 Site Scope)

{
  "message": "You can only manage penalty points for games at your own site(s)."
}

GET /api/players

Retrieve a paginated list of players.

Requires: player-list. Response fields vary by permission:

curl -X GET "https://airsoft-defence.co.uk/api/players" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/players', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Players:', data.data);
  console.log('Total:', data.total);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/players');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/players'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Players: {data['data']}")
print(f"Total: {data['total']}")

Response (200, restricted list, abbreviated)

{
  "current_page": 1,
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Example Player",
      "member_id": "EXAMPLE0001",
      "postcode": "ZZ1 1ZZ",
      "status": {
        "valid": true
      }
    }
  ],
  "per_page": 20,
  "last_page": 1,
  "total": 1
}

Response (200, audit-authorised list, abbreviated)

{
  "current_page": 1,
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000101",
      "member_id": "EXAMPLE0001",
      "name": "Example Player",
      "postcode": "ZZ1 1ZZ",
      "dob": "1984-11-07T00:00:00.000000Z",
      "open_police_holds_count": 0,
      "games_count": 14,
      "first_game_date": "2024-04-01",
      "last_game_date": "2026-09-12",
      "status": {
        "valid": true
      }
    }
  ],
  "per_page": 20,
  "total": 1,
  "last_page": 1
}

POST /api/players

Create a new player account.

Requires: any of user-create or player-create.

Request body

Provide forename, surname, dob, email, address_1, address_2, city, region, postcode and phone. The server derives the display name.

curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/players' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"forename":"Morgan","surname":"Example","dob":"1990-02-14","email":"morgan@example.test","address_1":"10 Example Lane","address_2":"Unit X","city":"Example Town","region":"Example Region","postcode":"ZZ1 1ZZ","phone":"07700900001"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/players", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"forename":"Morgan","surname":"Example","dob":"1990-02-14","email":"morgan@example.test","address_1":"10 Example Lane","address_2":"Unit X","city":"Example Town","region":"Example Region","postcode":"ZZ1 1ZZ","phone":"07700900001"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/players');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"forename":"Morgan","surname":"Example","dob":"1990-02-14","email":"morgan@example.test","address_1":"10 Example Lane","address_2":"Unit X","city":"Example Town","region":"Example Region","postcode":"ZZ1 1ZZ","phone":"07700900001"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/players",
    headers=headers,
    json=json.loads(r'''{"forename":"Morgan","surname":"Example","dob":"1990-02-14","email":"morgan@example.test","address_1":"10 Example Lane","address_2":"Unit X","city":"Example Town","region":"Example Region","postcode":"ZZ1 1ZZ","phone":"07700900001"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (201 - Created)

{ "success": true }

GET /api/players/{player}

Retrieve details of a specific player.

Requires: any of user-full, user-limited, or user-restricted.

Player-to-player lookup rule: for cross-player lookups, pass a valid one-time lookup grant from POST /api/players/search in X-Lookup-Grant (or lookup_grant input). Grants are single-use and expire quickly.

curl -X GET https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const playerId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/players/${playerId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Player details:', data.player);
  console.log('Status:', data.status);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$playerId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/players/{$playerId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
player_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/players/{player_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Player: {data['player']}")
print(f"Status: {data['status']}")

Note: this endpoint returns HTTP 200 and includes membership status/renewal metadata.

Response (200, restricted player)

{
  "player": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player",
    "member_id": "EXAMPLE0001",
    "postcode": "ZZ1 1ZZ",
    "level": "Player",
    "photos": []
  },
  "status": {
    "valid": true
  },
  "renewal_eligibility": {
    "eligible": true,
    "active_expires_at": null,
    "renewable_from": null,
    "message": null
  },
  "site_renewal_amount": 2500
}

Response (403 - Cross-player lookup grant missing/used)

{
  "message": "Lookup access has already been used. Please search again to request fresh access."
}

PUT /api/players/{player}

Update a player's information.

Requires: user-update.

Request Body

Field Type Required Description
name string Optional Updated player name
curl -X PUT https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{"name": "Morgan Updated"}'
// Using Fetch API
const token = localStorage.getItem('api_token');
const playerId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/players/${playerId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    name: 'Morgan Updated'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Updated player:', data.player);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$playerId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/players/{$playerId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'Morgan Updated'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
player_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/players/{player_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'name': 'Morgan Updated'
}

response = requests.put(url, headers=headers, json=payload)
data = response.json()

print(f"Updated player: {data['player']}")

Response (200, abbreviated)

{
  "player": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player Updated",
    "member_id": "EXAMPLE0001",
    "postcode": "ZZ1 1ZZ"
  },
  "status": {
    "valid": true
  }
}

POST /api/players/{player}/validate

Validate a player's information by marking fields as verified.

Requires: any of user-update or user-validate.

Request Body

Field Type Required Description
verified object Required Object containing boolean fields for each verification type
curl -X POST https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/validate \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{"verified": {"name": true, "photo": true, "address": true, "email": true, "phone": true, "id": true}}'
// Using Fetch API
const token = localStorage.getItem('api_token');
const playerId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/players/${playerId}/validate`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    verified: {
      name: true,
      photo: true,
      address: true,
      email: true,
      phone: true,
      id: true
    }
  })
})
.then(response => response.json())
.then(data => {
  console.log('Player validated:', data.player);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$playerId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/players/{$playerId}/validate");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'verified' => [
        'name' => true,
        'photo' => true,
        'address' => true,
        'email' => true,
        'phone' => true,
        'id' => true
    ]
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
player_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/players/{player_id}/validate'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'verified': {
        'name': True,
        'photo': True,
        'address': True,
        'email': True,
        'phone': True,
        'id': True
    }
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()

print(f"Player validated: {data['player']}")

Response (200, validation queued, abbreviated)

{
  "player": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player",
    "member_id": "EXAMPLE0001",
    "postcode": "ZZ1 1ZZ",
    "verified": {
      "id": true,
      "name": true,
      "email": true,
      "photo": true,
      "address": true,
      "phone": true
    }
  },
  "status": {
    "valid": true
  }
}

POST /api/players/{player}/site-sponsored-renewal

Renew a player's annual membership using site-sponsored (site user) or complimentary (privileged internal user) flow.

Requires: any of user-update or user-validate, and caller must be a Site user or another privileged internal user level.

Request Body

Field Type Required Description
site_id string (UUID) Optional For Site users with multiple linked sites. Ignored for privileged internal users.
curl --fail-with-body --request POST \
  --url 'https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/site-sponsored-renewal' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"site_id":"00000000-0000-4000-8000-000000000111"}'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/site-sponsored-renewal", {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"site_id":"00000000-0000-4000-8000-000000000111"}),
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('API_TOKEN');
$headers[] = 'Content-Type: application/json';
$request = curl_init('https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/site-sponsored-renewal');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_POSTFIELDS => '{"site_id":"00000000-0000-4000-8000-000000000111"}',
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["API_TOKEN"]
response = requests.request(
    "POST",
    "https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/site-sponsored-renewal",
    headers=headers,
    json=json.loads(r'''{"site_id":"00000000-0000-4000-8000-000000000111"}'''),
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200 - Success)

{
  "success": true,
  "renewed_by": {
    "type": "site",
    "name": "North Test Site",
    "id": "00000000-0000-4000-8000-000000000111"
  },
  "payment": {
    "status": "site-sponsored",
    "expires_at": "2027-09-16T00:00:00.000000Z"
  },
  "player": { "id": "00000000-0000-4000-8000-000000000101" },
  "status": { "valid": true }
}

Response (422 - Not eligible yet)

{
  "message": "Renewal is available from 16/07/2026.",
  "renewal_eligibility": {
    "eligible": false,
    "active_expires_at": "2026-09-16T00:00:00.000000Z",
    "renewable_from": "2026-07-16T00:00:00.000000Z",
    "message": "Renewal is available from 16/07/2026."
  }
}

POST /api/players/search-list

Find up to 50 matching players. Player accounts use the individual lookup and approval flow. Supported filters are id, member_id, forename, surname, name, postcode and email.

Requires: any of user-full, user-limited, or user-restricted.

Request Body

Field Type Required Description
name string Required Player's name to search for
curl -X POST https://airsoft-defence.co.uk/api/players/search-list \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{"name": "Morgan Player"}'
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/players/search-list', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    name: 'Morgan Player'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Members found:', data.members);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/players/search-list');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'Morgan Player'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/players/search-list'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'name': 'Morgan Player'
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()

print(f"Members found: {data['members']}")

Response (200 - Success)

{
  "members": [
    {
      "id": "00000000-0000-4000-8000-000000000101",
      "member_id": "EXAMPLE0001",
      "name": "Morgan Player",
      "forename": "Morgan",
      "surname": "Player",
      "postcode": "ZZ1 1ZZ",
      "level": "Player",
      "photos": [
        { "filename": "abc123.jpg", "path": "/storage/images/abc123.jpg" }
      ]
    }
  ]
}

POST /api/players/{player}/photo

Upload a photo for a player or for yourself. Users can always upload their own photo using their own user ID; staff/admin can upload photos for any player.

Requires: any of user-update or player-create. (Authenticated users can always upload their own photo.)

How to use: Replace {player} with the player's user ID. To upload your own photo, use your own user ID. Send this request as multipart/form-data with raw binary file content in the photo field (not a URL/string). Any existing photo will be replaced.

Request Body

Field Type Required Description
photo file Required Image file to upload
curl -X POST https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/photo \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json" \
  -F "photo=@/path/to/photo.jpg"
// Using Fetch API with FormData
const token = localStorage.getItem('api_token');
const playerId = '00000000-0000-4000-8000-000000000101';
const fileInput = document.querySelector('input[type="file"]');
const formData = new FormData();
formData.append('photo', fileInput.files[0]);

fetch(`https://airsoft-defence.co.uk/api/players/${playerId}/photo`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`
  },
  body: formData
})
.then(response => response.json())
.then(data => {
  console.log('Photo uploaded:', data.player.photos);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$playerId = '00000000-0000-4000-8000-000000000101';
$photoPath = '/path/to/photo.jpg';

$ch = curl_init("https://airsoft-defence.co.uk/api/players/{$playerId}/photo");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'photo' => new CURLFile($photoPath)
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
player_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/players/{player_id}/photo'
headers = {
    'Authorization': f'Bearer {token}'
}

with open('/path/to/photo.jpg', 'rb') as photo:
    files = {'photo': photo}
    response = requests.post(url, headers=headers, files=files)
    data = response.json()

print(f"Photo uploaded: {data['player']['photos']}")

Response (200 - Success)

{
  "player": {
    "id": "00000000-0000-4000-8000-000000000101",
    "member_id": "EXAMPLE0001",
    "name": "Morgan Player",
    "forename": "Morgan",
    "surname": "Player",
    "postcode": "ZZ1 1ZZ",
    "level": "Player",
    "photos": [
      { "filename": "abc123.jpg", "path": "/storage/images/abc123.jpg" }
    ]
  }
}

GET /api/players/{player}/status

Get the status of a player. Player accounts can use this endpoint for their own status. For another player's status, use the individual lookup and approval flow.

Requires: any of user-full, user-limited, or user-restricted.

curl -X GET https://airsoft-defence.co.uk/api/players/00000000-0000-4000-8000-000000000101/status \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const playerId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/players/${playerId}/status`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Player status:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$playerId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/players/{$playerId}/status");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
player_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/players/{player_id}/status'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Player status: {data}")

Response (200, valid defence)

{
  "valid": true
}

Response (200, membership payment required)

{
  "valid": false,
  "code": "pay",
  "message": "Account disabled, membership payment required"
}
Status codes: anv (account not verified), u18 (under 18), ph (police hold — also includes "police": true), neg (not enough games played), ngy (no games in last 12 months), pay (account disabled).

Player Lookup Access

Controls how one player can request and gain permission to view another player's defence profile. The full lookup flow spans these endpoints and POST /api/players/search plus GET /api/players/{player} from the Players section.

Permission required for all endpoints: any of user-full, user-limited, or user-restricted.

How the flows work

Flow A — Request & Approve (requester stays online)
// 1. Requester sends access request
POST /api/player-lookup/request  → { status: "pending", lookup_access_id }

// 2. Requester polls until approved
GET  /api/player-lookup/{id}/status  → { status: "approved-live", member_id }

// 3. Exchange for a short-lived lookup grant (5 min, single-use)
POST /api/players/search  { member_id: "APD12345" }  → { memberId, lookup_grant }

// 4. Fetch the profile using the grant
GET  /api/players/{uuid}  X-Lookup-Grant: {token}  → { player, status }
Flow B — Request & Approve (requester goes offline)
// 1. Requester sends request, then signals they are leaving
POST /api/player-lookup/request         → { status: "pending", lookup_access_id }
POST /api/player-lookup/{id}/signal-away  → { status: "ok" }

// 2. Owner approves — OTP is emailed to requester instead of live grant
POST /api/player-lookup/{id}/decision  { decision: "approve" }

// 3. Requester uses the emailed OTP in the search call
POST /api/players/search  { member_id: "APD12345", otp: "847291" }  → { memberId, lookup_grant }

// 4. Fetch the profile using the grant
GET  /api/players/{uuid}  X-Lookup-Grant: {token}  → { player, status }
Flow C — Self-Service OTP (owner generates and shares)
// 1. Owner generates their own OTP to share in person
POST /api/player-lookup/otp  → { otp: "847291", member_id, expires_at }

// 2. Operator/site terminal submits OTP on behalf of the owner
POST /api/players/search  { member_id: "APD12345", otp: "847291" }  → { memberId, lookup_grant }

// 3. Fetch the profile using the grant
GET  /api/players/{uuid}  X-Lookup-Grant: {token}  → { player, status }

POST /api/player-lookup/otp

Generate a self-service one-time passcode for the authenticated player's own membership ID. The OTP is valid for 24 hours and is single-use. Share it verbally or on-screen so another party can enter it into POST /api/players/search.

Requires: any of user-full, user-limited, or user-restricted. Caller must be a player-level account.

curl -X POST "https://airsoft-defence.co.uk/api/player-lookup/otp" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/player-lookup/otp', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(r => r.json())
.then(data => {
  console.log('Your OTP:', data.otp);
  console.log('Share member ID:', data.member_id);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/player-lookup/otp');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
// $data['otp']       → the 6-digit passcode
// $data['member_id'] → share this alongside the OTP
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/player-lookup/otp'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

print(f"OTP: {data['otp']} — share with member {data['member_id']}")

Response (200 - Success)

{
  "success": true,
  "member_id": "APD12345",
  "otp": "847291",
  "expires_at": "2026-04-14T10:30:00+00:00"
}

Response (403 - Non-player account)

{
  "message": "Only player-level accounts can generate a lookup passcode."
}

POST /api/player-lookup/request

Request access to view another player's defence profile. An approval notification is emailed to the target player. Rate-limited to one request per target per 5 minutes.

Requires: any of user-full, user-limited, or user-restricted.

Request Body

FieldTypeRequiredDescription
member_idstringRequiredThe target player's membership ID
curl -X POST "https://airsoft-defence.co.uk/api/player-lookup/request" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{"member_id": "APD12345"}'
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/player-lookup/request', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({ member_id: 'APD12345' })
})
.then(r => r.json())
.then(data => {
  if (data.status === 'pending') {
    // Store lookup_access_id and begin polling /status
    console.log('Request sent, access ID:', data.lookup_access_id);
  }
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/player-lookup/request');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'member_id' => 'APD12345'
]));

$data = json_decode(curl_exec($ch), true);
curl_close($ch);

// $data['lookup_access_id'] → use to poll status
?>
import requests

token = 'YOUR_TOKEN_HERE'
response = requests.post(
    'https://airsoft-defence.co.uk/api/player-lookup/request',
    headers={
        'Authorization': f'Bearer {token}',
        'Accept': 'application/json'
    },
    json={'member_id': 'APD12345'}
)
data = response.json()

# Store data['lookup_access_id'] and poll /status

Response (200 - Pending, request sent)

{
  "status": "pending",
  "lookup_access_id": "00000000-0000-4000-8000-000000000108",
  "message": "Approval request sent to the player email address."
}

Response (200 - Self, requesting own profile)

{
  "status": "self",
  "message": "You can access your own player profile directly.",
  "member_id": "APD12345"
}

Response (404 - Player not found)

{ "message": "Player not found." }

Response (429 - Rate limited)

Also sets the Retry-After response header.

{
  "status": "cooldown",
  "message": "Request already sent recently. Please wait before requesting access again.",
  "retry_after_seconds": 240,
  "retry_after_at": "2026-04-13T10:34:00+00:00"
}

GET /api/player-lookup/pending

Returns all unexpired, pending lookup access requests where the authenticated user is the owner (the player being looked up). Use this to discover incoming requests and then action them via the decision endpoint.

Requires: any of user-full, user-limited, or user-restricted.

curl -X GET "https://airsoft-defence.co.uk/api/player-lookup/pending" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/player-lookup/pending', {
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(r => r.json())
.then(data => {
  // data.pending_requests[] — action each with POST .../decision
  console.log(data.pending_requests);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/player-lookup/pending');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$data = json_decode(curl_exec($ch), true);
curl_close($ch);

foreach ($data['pending_requests'] as $req) {
    // use $req['id'] to approve or deny
}
?>
import requests

token = 'YOUR_TOKEN_HERE'
response = requests.get(
    'https://airsoft-defence.co.uk/api/player-lookup/pending',
    headers={'Authorization': f'Bearer {token}', 'Accept': 'application/json'}
)
for req in response.json()['pending_requests']:
    print(req['id'], req['requester']['name'])

Response (200 - Success)

{
  "pending_requests": [
    {
      "id": "00000000-0000-4000-8000-000000000108",
      "owner_user_id": "00000000-0000-4000-8000-000000000109",
      "requester_user_id": "00000000-0000-4000-8000-000000000110",
      "requester_email": "jane@example.test",
      "access_member_id": "APD12345",
      "decision_status": "pending",
      "request_expires_at": "2026-04-14T10:00:00+00:00",
      "created_at": "2026-04-13T10:00:00+00:00",
      "requester": {
        "id": "00000000-0000-4000-8000-000000000110",
        "name": "Jane Smith",
        "member_id": "APD67890"
      }
    }
  ]
}

GET /api/player-lookup/{lookupAccess}/status

Poll the status of a lookup access request. Only the requester may call this endpoint. Poll at a reasonable interval (e.g. every 3–5 seconds) until the status moves away from pending.

Requires: any of user-full, user-limited, or user-restricted.

curl -X GET "https://airsoft-defence.co.uk/api/player-lookup/00000000-0000-4000-8000-000000000108/status" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
const token = localStorage.getItem('api_token');
const accessId = '00000000-0000-4000-8000-000000000108';

async function pollStatus() {
  const res = await fetch(`https://airsoft-defence.co.uk/api/player-lookup/${accessId}/status`, {
    headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' }
  });
  const data = await res.json();

  if (data.status === 'pending') {
    setTimeout(pollStatus, 4000); // wait 4 s and try again
  } else if (data.status === 'approved-live') {
    // proceed to POST /api/players/search with data.member_id
    console.log('Approved! Search for:', data.member_id);
  } else if (data.status === 'approved-otp-emailed') {
    // prompt user to enter the OTP received by email
    console.log('Check email for OTP, then POST /api/players/search with {member_id, otp}');
  } else {
    console.log('Final status:', data.status);
  }
}

pollStatus();
<?php
$token    = 'YOUR_TOKEN_HERE';
$accessId = '00000000-0000-4000-8000-000000000108';

$ch = curl_init("https://airsoft-defence.co.uk/api/player-lookup/{$accessId}/status");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$data = json_decode(curl_exec($ch), true);
curl_close($ch);

// $data['status'] → 'pending' | 'approved-live' | 'approved-otp-emailed' | 'denied' | 'used'
?>
import requests, time

token     = 'YOUR_TOKEN_HERE'
access_id = '00000000-0000-4000-8000-000000000108'
url       = f'https://airsoft-defence.co.uk/api/player-lookup/{access_id}/status'
headers   = {'Authorization': f'Bearer {token}', 'Accept': 'application/json'}

while True:
    data = requests.get(url, headers=headers).json()
    if data['status'] != 'pending':
        break
    time.sleep(4)

print(f"Final status: {data['status']}")

Response (200 - pending)

{ "status": "pending", "message": "Waiting for player approval." }

Response (200 - approved-live)

Proceed immediately to POST /api/players/search with { "member_id": "APD12345" } to receive the lookup grant.

{
  "status": "approved-live",
  "member_id": "APD12345",
  "message": "Access approved. Call POST /api/players/search with the member_id to receive a lookup_grant for the profile fetch."
}

Response (200 - approved-otp-emailed)

Use the OTP from the email in POST /api/players/search as { "member_id": "APD12345", "otp": "847291" }.

{
  "status": "approved-otp-emailed",
  "message": "Access approved. A one-time passcode has been emailed to you. Use it in POST /api/players/search."
}

Response (200 - denied)

{ "status": "denied", "message": "Your access request was denied." }

Response (200 - used)

{ "status": "used", "message": "This approval has already been used." }

POST /api/player-lookup/{lookupAccess}/decision

Approve or deny a pending lookup access request. The authenticated user must be the owner of the record. Only unexpired, pending records can be acted on.

Requires: any of user-full, user-limited, or user-restricted.

Online detection: if the owner approves while the requester is detected as offline (or they called signal-away), an OTP is automatically generated and emailed instead of returning live access.

Request Body

FieldTypeRequiredDescription
decisionstringRequiredapprove or deny
curl -X POST "https://airsoft-defence.co.uk/api/player-lookup/00000000-0000-4000-8000-000000000108/decision" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{"decision": "approve"}'
const token    = localStorage.getItem('api_token');
const accessId = '00000000-0000-4000-8000-000000000108';

fetch(`https://airsoft-defence.co.uk/api/player-lookup/${accessId}/decision`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({ decision: 'approve' })
})
.then(r => r.json())
.then(data => console.log(data.message));
<?php
$token    = 'YOUR_TOKEN_HERE';
$accessId = '00000000-0000-4000-8000-000000000108';

$ch = curl_init("https://airsoft-defence.co.uk/api/player-lookup/{$accessId}/decision");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'decision' => 'approve'
]));

$data = json_decode(curl_exec($ch), true);
curl_close($ch);
?>
import requests

token     = 'YOUR_TOKEN_HERE'
access_id = '00000000-0000-4000-8000-000000000108'
response = requests.post(
    f'https://airsoft-defence.co.uk/api/player-lookup/{access_id}/decision',
    headers={'Authorization': f'Bearer {token}', 'Accept': 'application/json'},
    json={'decision': 'approve'}
)
print(response.json()['message'])

Response (200 - Approved, requester online)

{
  "success": true,
  "message": "Request approved. If the requester is still polling the status endpoint, access will open automatically."
}

Response (200 - Approved, requester offline or signalled away)

{
  "success": true,
  "message": "Request approved. The requester was offline, so a one-time passcode was emailed to them."
}

Response (200 - Denied)

{
  "success": true,
  "message": "Request denied. The requester cannot view your defence details."
}

Response (422 - Already processed or expired)

{ "message": "This request has already been processed." }
{ "message": "This request has expired. No action can be taken." }

POST /api/player-lookup/{lookupAccess}/signal-away

Signal that the requester has left the waiting screen. When the owner subsequently approves, they will receive an OTP email instead of the system expecting an active poll. Only affects pending, unused records. Only the requester may call this endpoint.

Requires: any of user-full, user-limited, or user-restricted.

curl -X POST "https://airsoft-defence.co.uk/api/player-lookup/00000000-0000-4000-8000-000000000108/signal-away" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
const token    = localStorage.getItem('api_token');
const accessId = '00000000-0000-4000-8000-000000000108';

// Call this when the user navigates away from the waiting screen
fetch(`https://airsoft-defence.co.uk/api/player-lookup/${accessId}/signal-away`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(r => r.json())
.then(data => console.log(data.status)); // "ok" or "ignored"
<?php
$token    = 'YOUR_TOKEN_HERE';
$accessId = '00000000-0000-4000-8000-000000000108';

$ch = curl_init("https://airsoft-defence.co.uk/api/player-lookup/{$accessId}/signal-away");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$data = json_decode(curl_exec($ch), true);
curl_close($ch);
// $data['status'] → 'ok' | 'ignored'
?>
import requests

token     = 'YOUR_TOKEN_HERE'
access_id = '00000000-0000-4000-8000-000000000108'
response = requests.post(
    f'https://airsoft-defence.co.uk/api/player-lookup/{access_id}/signal-away',
    headers={'Authorization': f'Bearer {token}', 'Accept': 'application/json'}
)
print(response.json())  # {'status': 'ok'} or {'status': 'ignored'}

Response (200 - Signalled)

{ "status": "ok" }

Response (200 - Ignored, request already decided or used)

{ "status": "ignored" }

Reading or writing a private note requires police-private. OAuth calls also need scope police:private. Hold-management permissions continue to govern the individual actions. Without private access, the field is omitted from responses and non-empty private-note input is rejected with 403.

GET /api/police-holds/{playerId}

Requires: police-list permission (Admin, Staff, Site, Store, Police roles)

Retrieve all police holds for a specific player.

curl -X GET "https://airsoft-defence.co.uk/api/police-holds/00000000-0000-4000-8000-000000000101" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const playerId = '00000000-0000-4000-8000-000000000101';

fetch(`https://airsoft-defence.co.uk/api/police-holds/${playerId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Police Holds:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$playerId = '00000000-0000-4000-8000-000000000101';

$ch = curl_init("https://airsoft-defence.co.uk/api/police-holds/{$playerId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
player_id = '00000000-0000-4000-8000-000000000101'
url = f'https://airsoft-defence.co.uk/api/police-holds/{player_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Police Holds: {data}")

Response (200 - Success)

[
  {
    "id": "00000000-0000-4000-8000-000000000112",
    "officer": {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Officer Example"
    },
    "public_note": "Hold placed pending investigation",
    "lifted": null
  }
]
Note: Returns an array of hold objects for the specified player. If the caller has private-note access, each object also includes a "private_note" field. The lifted field contains a datetime string when lifted, or null if still active.

POST /api/police-holds

Requires: police-create permission (Police role only)

Create a new police hold on a player.

Request Body

Field Type Required Description
player_id string Required Player's unique identifier
public_note string Optional Public note about the hold
curl -X POST https://airsoft-defence.co.uk/api/police-holds \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"player_id": "00000000-0000-4000-8000-000000000101", "public_note": "Hold for investigation"}'
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/police-holds', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    player_id: '00000000-0000-4000-8000-000000000101',
    public_note: 'Hold for investigation'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Hold created:', data.hold);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/police-holds');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'player_id' => '00000000-0000-4000-8000-000000000101',
    'public_note' => 'Hold for investigation'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/police-holds'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'player_id': '00000000-0000-4000-8000-000000000101',
    'public_note': 'Hold for investigation'
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()

print(f"Hold created: {data['hold']}")

Response (200 - Success)

{
  "success": true,
  "hold": {
    "id": "00000000-0000-4000-8000-000000000112",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "officer_id": "00000000-0000-4000-8000-000000000113",
    "public_note": "Hold placed pending investigation",
    "lifted": null,
    "created_at": "2026-04-10T14:30:00.000000Z",
    "updated_at": "2026-04-10T14:30:00.000000Z"
  }
}

PUT /api/police-holds/{policeHold}

Requires: police-update permission (Police role only)

Update the public note of an existing police hold.

Request Body

Parameter Type Required Description
public_note string Required Updated public note for the hold
curl -X PUT https://airsoft-defence.co.uk/api/police-holds/2 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"public_note":"Updated note"}'
// Using Fetch API
const token = localStorage.getItem('api_token');
const holdId = 2;

fetch(`https://airsoft-defence.co.uk/api/police-holds/${holdId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    public_note: 'Updated note'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Hold updated:', data.hold);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$holdId = 2;

$ch = curl_init("https://airsoft-defence.co.uk/api/police-holds/{$holdId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'public_note' => 'Updated note'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
hold_id = 2
url = f'https://airsoft-defence.co.uk/api/police-holds/{hold_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}
payload = {
    'public_note': 'Updated note'
}

response = requests.put(url, headers=headers, json=payload)
data = response.json()

print(f"Hold updated: {data['hold']}")

Response (200 - Success)

{
  "success": true,
  "hold": {
    "id": "00000000-0000-4000-8000-000000000112",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "officer_id": "00000000-0000-4000-8000-000000000113",
    "public_note": "Updated hold reason",
    "lifted": null,
    "created_at": "2026-04-10T14:30:00.000000Z",
    "updated_at": "2026-04-10T15:00:00.000000Z"
  }
}

DELETE /api/police-holds/{policeHold}

Requires: police-delete permission (Police role only)

Delete a police hold record.

curl -X DELETE https://airsoft-defence.co.uk/api/police-holds/2 \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const holdId = 2;

fetch(`https://airsoft-defence.co.uk/api/police-holds/${holdId}`, {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Hold deleted', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$holdId = 2;

$ch = curl_init("https://airsoft-defence.co.uk/api/police-holds/{$holdId}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
hold_id = 2
url = f'https://airsoft-defence.co.uk/api/police-holds/{hold_id}'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.delete(url, headers=headers)
data = response.json()

print(f"Hold deleted: {data}")

Response (200 - Success)

{
  "success": true
}

POST /api/police-holds/{policeHold}/lift

Requires: police-update permission (Police role only)

Lift (release) a police hold by marking it as lifted with a timestamp.

curl -X POST https://airsoft-defence.co.uk/api/police-holds/2/lift \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');
const holdId = 2;

fetch(`https://airsoft-defence.co.uk/api/police-holds/${holdId}/lift`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Hold lifted:', data.hold);
});
<?php
$token = 'YOUR_TOKEN_HERE';
$holdId = 2;

$ch = curl_init("https://airsoft-defence.co.uk/api/police-holds/{$holdId}/lift");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
hold_id = 2
url = f'https://airsoft-defence.co.uk/api/police-holds/{hold_id}/lift'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.post(url, headers=headers)
data = response.json()

print(f"Hold lifted: {data['hold']}")

Response (200 - Success)

{
  "success": true,
  "hold": {
    "id": "00000000-0000-4000-8000-000000000112",
    "player_id": "00000000-0000-4000-8000-000000000101",
    "officer_id": "00000000-0000-4000-8000-000000000113",
    "public_note": "Hold placed pending investigation",
    "lifted": "2026-04-11T09:00:00.000000Z",
    "created_at": "2026-04-10T14:30:00.000000Z",
    "updated_at": "2026-04-11T09:00:00.000000Z"
  }
}

Audit Logs

GET /api/audits

Returns a list of audit logs. Optional user_id query parameter to filter by specific user.

Query Parameters

Parameter Type Required Description
user_id string (UUID) Optional Filter audits by user ID
curl -X GET "https://airsoft-defence.co.uk/api/audits" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/audits', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Audits:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/audits');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/audits'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Audits: {data}")

Response (200 - Success)

{
  "audits": [
    {
      "id": 1,
      "user_id": "00000000-0000-4000-8000-000000000101",
      "audit_id": "00000000-0000-4000-8000-000000000101",
      "audit_type": "App\\Models\\User",
      "action": "update",
      "data": "{\"name\":\"Alex Carter\"}",
      "ip_address": "192.0.2.10",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
      "source": "web",
      "created_at": "2026-03-28T18:09:21.000000Z",
      "updated_at": "2026-03-28T18:09:21.000000Z"
    }
  ],
  "users": [
    {
      "id": "00000000-0000-4000-8000-000000000101",
      "name": "Alex Carter",
      "email": "u**r@example.test"
    }
  ]
}
Notes:
  • Requires audit-list permission.
  • The audit_id is the UUID of the record that was changed; audit_type is the fully-qualified model class name.
  • The data field is a JSON-encoded string or null. User updates mask email addresses and show only the birth year.
  • Without user_id filter, returns the 50 most recent audits. With ?user_id=UUID returns all audits for that user.
  • The users array provides account IDs, names and masked email addresses for filtering.

GET /api/ping

Public connectivity check. It requires no credentials and returns only a fixed response.

curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/ping' \
  --header 'Accept: application/json'
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/ping", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$request = curl_init('https://airsoft-defence.co.uk/api/ping');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/ping",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200)

{"message":"pong"}

GET /api/user

Returns the authenticated account using the legacy API guard. Use GET /api/profile for new Sanctum and OAuth integrations.

curl --fail-with-body --request GET \
  --url 'https://airsoft-defence.co.uk/api/user' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $LEGACY_API_TOKEN"
// Node.js 18+, ES module (.mjs)
const response = await fetch("https://airsoft-defence.co.uk/api/user", {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + process.env.LEGACY_API_TOKEN,
  },
});
const content = await response.text();
const body = content ? JSON.parse(content) : null;
if (!response.ok) {
  throw new Error(body?.message ?? body?.error_description ?? body?.error ?? String(response.status));
}
console.log(response.status);
<?php
$headers = ['Accept: application/json'];
$headers[] = 'Authorization: Bearer ' . getenv('LEGACY_API_TOKEN');
$request = curl_init('https://airsoft-defence.co.uk/api/user');
curl_setopt_array($request, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$result = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($result === false) throw new RuntimeException(curl_error($request));
curl_close($request);
$body = $result === '' ? null : json_decode($result, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400) {
    throw new RuntimeException($body['message'] ?? $body['error_description'] ?? $body['error'] ?? (string) $status);
}
echo 'HTTP ' . $status;
import json
import os
import requests

headers = {"Accept": "application/json"}
headers["Authorization"] = "Bearer " + os.environ["LEGACY_API_TOKEN"]
response = requests.request(
    "GET",
    "https://airsoft-defence.co.uk/api/user",
    headers=headers,
    timeout=15,
)
response.raise_for_status()
body = response.json() if response.content else None
print(response.status_code)

Response (200, abbreviated)

{"id":"00000000-0000-4000-8000-000000000001","name":"Morgan Example","email":"morgan@example.test"}

Send the credential in the bearer header. Invalid or missing credentials return 401. Accounts with two-factor authentication should use the mobile login flow and GET /api/profile.

GET /api/session-check

Validate the current API token and, for Sanctum personal access tokens, refresh the inactivity clock by updating the token's last_used_at timestamp.

Authentication required: A valid Bearer token is required.

Sanctum behavior: If the token is a Sanctum personal access token, this endpoint refreshes the inactivity window used by token pruning.

OAuth behavior: If the token is an OAuth token, the request can still validate authentication, but it does not refresh OAuth expiry.

Headers

HeaderRequiredDescription
Authorization: Bearer YOUR_TOKEN_HERE Required The API token returned by /api/login or the verified 2FA flow.
Accept: application/json Required Request a JSON response.
curl -X GET "https://airsoft-defence.co.uk/api/session-check" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/session-check', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Session check:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/session-check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/session-check'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Session check: {data}")

Response (200 - Valid Sanctum Token)

{
  "authenticated": true,
  "sanctum_token_refreshed": true,
  "inactive_expiry_at": "2026-10-01T12:34:56+00:00"
}

Meaning:

Response (200 - Valid OAuth Token)

{
  "authenticated": true,
  "sanctum_token_refreshed": false,
  "inactive_expiry_at": null
}

This means the token was accepted for authentication, but there was no Sanctum personal access token to refresh.

Response (401 - Invalid / Missing Token)

{
  "message": "Unauthenticated."
}

Developer Notes

  • Use this endpoint as a lightweight keepalive for mobile or SPA clients authenticated with Sanctum.
  • It is safe to call periodically if the client needs to keep an otherwise idle Sanctum token active.
  • This endpoint does not issue a new token and does not extend OAuth token expiry.
  • If the client receives 401, clear the stored token and send the user back through login.

GET /api/metrics

Get system metrics by specifying a metric query parameter. Returns a nested date tree of recorded counts.

Permission required: audit-list — only Admin and Superuser roles have this permission.

Valid metric values:
  • user_count — total registered users over time
  • player_count — active player count over time
  • player_total_count — all-time cumulative player count
  • store_count — store count over time
  • site_count — site count over time
  • game_count — game check-in count over time

Query Parameters

ParameterTypeRequiredDescription
metric string Required One of: user_count, player_count, player_total_count, store_count, site_count, game_count
curl -X GET "https://airsoft-defence.co.uk/api/metrics?metric=user_count" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/metrics?metric=user_count', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  // data is a nested date tree: {year: {month: {day: count}}}
  console.log('Metric data:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/metrics?metric=user_count');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/metrics?metric=user_count'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

# data is a nested date tree: {year: {month: {day: count}}}
print(f"Metric data: {data}")

Response (200 - Success)

{
  "2024": {
    "1": {
      "1": 850,
      "15": 862
    },
    "2": {
      "1": 875
    }
  },
  "2025": {
    "4": {
      "7": 1234
    }
  }
}

Response (400, invalid metric)

{
  "error": "Invalid metric key"
}

Response (401, sign-in required)

{
  "message": "Unauthenticated."
}

Response (403, access denied)

{
  "message": "Forbidden."
}

GET /api/profile

Retrieve the authenticated account's profile. OAuth requires profile:read.

curl -X GET "https://airsoft-defence.co.uk/api/profile" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Accept: application/json"
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/profile', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Profile:', data);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/profile');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/profile'
headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

print(f"Profile: {data}")

Response (200 - Success)

{
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "member_id": "EXAMPLE0001",
    "forename": "Morgan",
    "surname": "Quinn",
    "name": "Morgan Quinn",
    "address_1": "20 Sample Road",
    "address_2": null,
    "city": "Example City",
    "region": "Example Cityshire",
    "postcode": "ZZ1 2ZZ",
    "phone": "07700900002",
    "dob": "1990-05-15T00:00:00.000000Z",
    "email": "user@example.test",
    "police_hold": 0,
    "verified": {
      "id": true,
      "name": true,
      "email": true,
      "phone": false,
      "photo": true,
      "address": true
    },
    "two_factor_enabled_at": null,
    "created_at": "2025-01-10T09:00:00.000000Z",
    "updated_at": "2026-04-07T10:30:00.000000Z",
    "games": [
      {
        "id": "00000000-0000-4000-8000-000000000114",
        "site_id": "00000000-0000-4000-8000-000000000115",
        "play_date": "2024-09-08T00:00:00.000000Z"
      }
    ],
    "photos": [
      {
        "id": "00000000-0000-4000-8000-000000000116",
        "path": "/storage/photos/users/b1/69c9023ff3d7a4.35107503.jpg",
        "filename": "69c9023ff3d7a4.35107503.jpg"
      }
    ]
  }
}

PUT /api/profile

Update your name, address, postcode, phone or date of birth. Supply forename or surname to derive the display name, or use name on its own to update just the display name. OAuth requires profile:update. Email changes require first-party authentication and trigger re-verification.

Request Body

Parameter Type Required Description
forename, surname string Optional Name components. The server derives the display name.
address_1, address_2, city, region, postcode, phone string or null Optional Contact information. Only submitted fields are updated.
dob date or null Optional Date of birth in ISO date format.
email string Optional First-party authentication only. The new address must be verified.
curl -X PUT https://airsoft-defence.co.uk/api/profile \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -d '{"forename":"Morgan"}'
// Using Fetch API
const token = localStorage.getItem('api_token');

fetch('https://airsoft-defence.co.uk/api/profile', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    forename: 'Morgan'
  })
})
.then(response => response.json())
.then(data => {
  console.log('Profile updated:', data.user);
});
<?php
$token = 'YOUR_TOKEN_HERE';

$ch = curl_init('https://airsoft-defence.co.uk/api/profile');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'forename' => 'Morgan'
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
import requests

token = 'YOUR_TOKEN_HERE'
url = 'https://airsoft-defence.co.uk/api/profile'
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json'
}
payload = {
    'forename': 'Morgan'
}

response = requests.put(url, headers=headers, json=payload)
data = response.json()

print(f"Profile updated: {data['user']}")

Response (200, abbreviated)

{
  "user": {
    "id": "00000000-0000-4000-8000-000000000101",
    "name": "Example Player Updated",
    "member_id": "EXAMPLE0001",
    "postcode": "ZZ1 1ZZ",
    "email": "player@example.test",
    "forename": "Example",
    "surname": "Player Updated",
    "updated_at": "2026-10-01T10:30:00.000000Z"
  }
}
Note: Only fields explicitly sent in the request body are updated. The response always returns the full updated user object wrapped in "user".

Failure State Reference

Use this as the default error contract for all endpoints unless an endpoint section says otherwise.

Most protected endpoints share auth/permission behavior from the API base controller, then add endpoint-specific validation or business-rule responses.

401 - Unauthenticated

{
    "message": "Unauthenticated."
}

403 - Forbidden

{
    "message": "Forbidden."
}

404 - Not Found

{
    "message": "Resource not found."
}

422 - Validation / Domain Rule Failure

{
    "message": "The given data was invalid.",
    "errors": {
        "field": ["Validation message"]
    }
}

429 - Too Many Requests

{
    "status": "cooldown",
    "message": "Request already sent recently. Please wait before requesting access again.",
    "retry_after_seconds": 145
}

500 - Server Error

{
    "error": "Internal server error."
}