TrackN Company Availability API

Use this API to check whether a company is active and available in TrackN Central, then receive the company's BaseURL.

POST https://central.tracknpro.com/check_company.php

Request

The API accepts JSON only. Send the company number in the request body.

Header Value
Content-Type application/json

Body Parameters

Name Type Required Description
company_number string Yes The company number stored in trackn_companies.CompanyNumber.

Example Request Body

{
  "company_number": "TRK001"
}

Successful Response

Returned when the company exists, is active, and is not deleted.

{
  "available": true,
  "base_url": "https://example.trackn.local/",
  "company_number": "TRK001",
  "company_id": "sample-trackn-company-001",
  "message": "Company available"
}

Error Responses

Company Not Available

{
  "available": false,
  "message": "Company not available"
}

cURL Example

curl -X POST "https://central.tracknpro.com/check_company.php" \
  -H "Content-Type: application/json" \
  -d "{\"company_number\":\"TRK001\"}"

Flutter Example

This example uses the Flutter http package to call the central company availability API.

import 'dart:convert';
import 'package:http/http.dart' as http;

Future<String?> getCompanyBaseUrl(String companyNumber) async {
  final response = await http.post(
    Uri.parse('https://central.tracknpro.com/check_company.php'),
    headers: {
      'Content-Type': 'application/json',
    },
    body: jsonEncode({
      'company_number': companyNumber,
    }),
  );

  final data = jsonDecode(response.body);

  if (response.statusCode == 200 && data['available'] == true) {
    return data['base_url'] as String;
  }

  return null;
}

Login Flow

After this API returns available: true, the mobile app should use the returned base_url to call the company login endpoint.

Login Endpoint Pattern

{base_url}/apps/trackn/login.php

Example

If the API returns this value:

{
  "base_url": "http://powerpro"
}

The mobile app should call:

http://powerpro/apps/trackn/login.php

Login Request Body

{
  "username": "user@example.com",
  "password": "password"
}

Flutter Login Example

import 'dart:convert';
import 'package:http/http.dart' as http;

Future<String?> loginToCompany({
  required String baseUrl,
  required String username,
  required String password,
}) async {
  final cleanBaseUrl = baseUrl.replaceAll(RegExp(r'/+$'), '');
  final loginUrl = Uri.parse('$cleanBaseUrl/apps/trackn/login.php');

  final response = await http.post(
    loginUrl,
    headers: {
      'Content-Type': 'application/json',
    },
    body: jsonEncode({
      'username': username,
      'password': password,
    }),
  );

  final data = jsonDecode(response.body);

  if (response.statusCode == 200 && data['user_id'] != null) {
    return data['user_id'] as String;
  }

  return null;
}

Login Success Response

{
  "user_id": "123"
}

Login Error Responses

Database Rule

The API checks trackn_central.trackn_companies and only returns a company when CompanyNumber matches, IsActive = 1, and IsDeleted = 0.