Session Listing

The Session Listing functionality allows you to retrieve information about user sessions made through the Axitech Widget.

GET /:clientId/sessions/:userId (list sessions created by a user)
Path Parameters
nametypedata typedescription
clientIdrequiredstringYour unique client ID
userIdrequiredstringThe unique ID of the user for whom you want to retrieve session listings
Examples
Typescript
import axios, { AxiosResponse } from 'axios';

const clientId = 'YOUR_CLIENT_ID';
const apiKey = 'YOUR_API_KEY';
const userId = 'USER_ID'; // Replace with the actual user ID
const apiUrl = `https://admin.axiwidget.com/${clientId}/sessions/${userId}`;

axios
  .get(apiUrl, {
    headers: {
      'x-api-key': apiKey,
      'Content-Type': 'application/json',
    },
  })
  .then((response: AxiosResponse<{ data: Session[] }>) => {
    console.log('Session Listings:', response.data);
  })
  .catch((error) => {
    console.error('Error:', error.response?.status, '-', error.response?.data);
  });

interface Session {
  reference: string;
  date: string;
  camsReference: string;
  status: string;
  createdAt: string;
  selectedPolicy: {
    number: string;
    provider: string;
    holder: {
      firstName: string;
      lastName: string;
      id: string;
      phone: string;
      email: string;
    };
    validFrom: string;
    linkedContacts: {
      firstName: string;
      lastName: string;
      email: string;
    }[];
    validTo: string;
    vehicle: {
      sePlate: string;
    };
  };
}
PHP Laravel
use Illuminate\Support\Facades\Http;

$clientId = 'YOUR_CLIENT_ID';
$apiKey = 'YOUR_API_KEY';
$userId = 'USER_ID';  // Replace with the actual user ID
$apiUrl = "https://admin.axiwidget.com/{$clientId}/sessions/{$userId}";

$response = Http::withHeaders([
    'x-api-key' => $apiKey,
    'Content-Type' => 'application/json',
])->get($apiUrl);

if ($response->successful()) {
    $responseData = $response->json();
    echo 'Session Listings: ' . json_encode($responseData, JSON_PRETTY_PRINT);
} else {
    echo 'Error: ' . $response->status() . ' - ' . $response->body();
}

Response

The response contains an array of session details.

Session Details

  • reference (string): A unique reference ID for the session.
  • date (string, ISO 8601 format): The date and time of the session.
  • camsReference (string): Reference ID used in CAMS.
  • status (string): The status of the session (e.g., "submitted").
  • createdAt (string, ISO 8601 format): The date and time when the session was created.
  • selectedPolicy (object): Details about the selected insurance policy.
    • number (string): The policy number.
    • provider (string): The insurance provider.
    • holder (object): Details about the policyholder.
      • firstName (string): First name of the policyholder.
      • lastName (string): Last name of the policyholder.
      • id (string): ID of the policyholder.
      • phone (string): Phone number of the policyholder.
      • email (string): Email address of the policyholder.
    • validFrom (string, ISO 8601 format): The start date of the policy's validity.
    • linkedContacts (array): Contacts linked to the policy.
      • firstName (string): First name of the linked contact.
      • lastName (string): Last name of the linked contact.
      • email (string): Email address of the linked contact.
    • validTo (string, ISO 8601 format): The end date of the policy's validity.
    • vehicle (object): Details about the vehicle associated with the policy.
      • licensePlate (string): License plate number of the vehicle.

Example Response

[
  {
    "reference": "LA-PE2VZ7RJD4",
    "date": "2023-11-27T14:52",
    "camsReference": "MIS/709006",
    "status": "submitted",
    "createdAt": "2023-11-27T14:52",
    "selectedPolicy": {
      "number": "123456",
      "provider": "Alliance",
      "holder": {
        "firstName": "Test",
        "lastName": "User",
        "id": "test",
        "phone": "+4917123456789",
        "email": "test@test.com"
      },
      "validFrom": "2023-10-01",
      "linkedContacts": [
        {
          "firstName": "John",
          "lastName": "Doe",
          "email": "john.doe@test.com"
        },
        {
          "firstName": "Jane",
          "lastName": "Doe",
          "email": "jane.doe@test.com"
        }
      ],
      "validTo": "2024-02-15",
      "vehicle": {
        "licensePlate": "ABC123"
      }
    }
  }
  // ... additional sessions
]

Error Responses

  • HTTP 404 Not Found:
    • If the specified client ID is not found.
  • HTTP 401 Unauthorized:
    • If the provided API key is invalid or unauthorized.
  • HTTP 500 Internal Server Error:
    • If there is an unexpected error on the server.