Contract API Guide

This document covers these APIs from ContractApiController in a quick-to-follow order.

Base URL and Headers

https://chronextechnologies.com/demo/pos/api/

All endpoints below are relative to this base URL.

Recommended headers

Accept: application/json
Content-Type: application/json
Important: request field name is exactly imei_number in backend code (spelling must match).

Quick Endpoint Index

API Use Case Required Input
GET /contracts/{id} Get full contract details including payload/store/customer. id (path)
POST /contracts/device-lock Lock or unlock a contract device from app/backend. contract_id, devices_lock (0 or 1)
GET /registration Lookup device registration and contact details. imei_number (query)
GET /status/{device_id} Get app-ready lock and due/payment status. device_id (path)
POST /tempered Store tempered/tamper event log for a device. imei_number, event

1) GET /contracts/{id}

Fetch full contract detail by contract ID.

GET https://chronextechnologies.com/demo/pos/api/contracts/123

Path Parameters

Field Type Required Description
id integer Yes Contract ID.

cURL Example

curl "https://chronextechnologies.com/demo/pos/api/contracts/123" \
  -H "Accept: application/json"

Success Response (200)

{
  "status": true,
  "message": "Contract details fetched successfully.",
  "data": {
    "contract_id": 123,
    "store_id": 4,
    "customer_id": 88,
    "contract_status": "active",
    "devices_lock": 1,
    "devices_lock_label": "lock",
    "payload": {},
    "store": {},
    "customer": {},
    "created_at": "2026-04-08 13:10:10",
    "updated_at": "2026-04-08 13:20:20"
  }
}

Error Responses

404 {
  "status": false,
  "message": "Contract not found."
}

2) POST /contracts/device-lock

Update contract device lock state.

POST https://chronextechnologies.com/demo/pos/api/contracts/device-lock

Request Body

Field Type Required Description
contract_id integer Yes Existing contract ID.
devices_lock integer Yes 1 = lock, 0 = unlock.

JSON Example

{
  "contract_id": 123,
  "devices_lock": 1
}

cURL Example

curl -X POST "https://chronextechnologies.com/demo/pos/api/contracts/device-lock" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "contract_id": 123,
    "devices_lock": 1
  }'

Success Response (200)

{
  "status": true,
  "message": "Contract device lock set to locked.",
  "data": {
    "contract_id": 123,
    "devices_lock": 1,
    "devices_lock_label": "lock",
    "updated_at": "2026-04-16 18:20:00"
  }
}

Error Responses

422 Validation error (missing/invalid contract_id or devices_lock)
404 {
  "status": false,
  "message": "Contract not found."
}

3) GET /registration

Fetch device registration and contact details by serial/IMEI/phone identifier.

GET https://chronextechnologies.com/demo/pos/api/registration?imei_number=356938035643809

Query Parameters

Field Type Required Description
imei_number string Yes Device identifier. Backend matches against contract payload fields contract.device_serial and contract.device_phone (case-insensitive).

cURL Example

curl -G "https://chronextechnologies.com/demo/pos/api/registration" \
  -H "Accept: application/json" \
  --data-urlencode "imei_number=356938035643809"

Success Response (200)

{
  "status": true,
  "message": "Registration details fetched successfully.",
  "data": {
    "contract_id": 123,
    "contract_status": "active",
    "serial_number": "356938035643809",
    "device": {
      "serial_number": "356938035643809",
      "model": "Samsung A14",
      "protocol": "mdm",
      "devices_lock": 0,
      "devices_lock_label": "unlock"
    },
    "contact": {
      "customer_name": "John Doe",
      "customer_phone": "9876543210",
      "customer_email": "john@example.com",
      "store_name": "Demo Store",
      "store_phone": "9000000000",
      "store_email": "store@example.com"
    },
    "created_at": "2026-04-08 13:10:10",
    "updated_at": "2026-04-08 13:20:20"
  }
}

Error Responses

422 Validation error (missing or invalid imei_number)
404 {
  "status": false,
  "message": "No device registration found for this serial number."
}

4) GET /status/{device_id}

Fetch lock/payment status for a device. This response includes exactly the app parsing fields: isLocked, amountDue, and paymentUrl.

GET https://chronextechnologies.com/demo/pos/api/status/356938035643809

Path Parameters

Field Type Required Description
device_id string Yes Device IMEI/serial/identifier. Backend matches against contract payload fields contract.device_serial and contract.device_phone.

cURL Example

curl "https://chronextechnologies.com/demo/pos/api/status/356938035643809" \
  -H "Accept: application/json"

Success Response (200)

{
  "status": true,
  "message": "Device status fetched successfully.",
  "data": {
    "deviceId": "356938035643809",
    "isLocked": true,
    "amountDue": 145.75,
    "paymentUrl": "https://pay.example.com/invoice/123",
    "contractId": 123
  }
}

Error Responses

404 {
  "status": false,
  "message": "No contract found for this device.",
  "data": {
    "deviceId": "356938035643809",
    "isLocked": false,
    "amountDue": 0,
    "paymentUrl": ""
  }
}

5) POST /tempered

Save a tempered event against matched device and contract, and return event snapshot data.

POST https://chronextechnologies.com/demo/pos/api/tempered

Request Body

Field Type Required Description
imei_number string Yes Device identifier. Backend normalizes value (trim/lowercase, removes serial: prefix if present).
event string Yes Event details/message (max 1000 chars).

JSON Example

{
  "imei_number": "356938035643809",
  "event": "Tamper alert received from device"
}

cURL Example

curl -X POST "https://chronextechnologies.com/demo/pos/api/tempered" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "imei_number": "356938035643809",
    "event": "Tamper alert received from device"
  }'

Success Response (201)

{
  "status": true,
  "message": "Tempered event saved successfully.",
  "data": {
    "tempered_event_id": 55,
    "imei_number": "356938035643809",
    "event": "Tamper alert received from device",
    "device_id": 18,
    "contract_id": 123,
    "customer_id": 88,
    "store_id": 4,
    "device": {
      "id": 18,
      "serial_number": "356938035643809"
    },
    "contract": {
      "id": 123,
      "status": "active"
    },
    "customer": {
      "id": 88,
      "name": "John Doe"
    },
    "store": {
      "id": 4,
      "business_name": "Demo Store"
    },
    "created_at": "2026-04-08 13:30:30"
  }
}

Error Responses

422 Validation error (missing imei_number/event)
404 {
  "status": false,
  "message": "Device not found for the provided imei_number."
}
404 {
  "status": false,
  "message": "Contract not found for the provided device."
}

Implementation Notes