Skip to main content

Overview

The Companies API allows you to manage company information, modules, and associated configurations. Each company can have multiple modules that define available functionality.

Company Object

The Company type represents an organization within the SIGEAC system.
id
number
required
Unique identifier for the company
name
string
required
Company name
description
string
required
Description of the company
slug
string
required
URL-friendly version of the company name
rif
string
required
RIF (Registro de Información Fiscal) - Tax identification number
cod_inac
string
required
INAC code (Instituto Nacional de Aviación Civil)
fiscal_address
string
required
Company’s fiscal address
phone_number
number
required
Primary phone number
alt_phone_number
number
required
Alternative phone number
cod_iata
string
required
IATA code (International Air Transport Association)
cod_oaci
string
required
ICAO code (International Civil Aviation Organization)
modules
Module[]
required
Array of modules enabled for this company
created_at
string
required
ISO 8601 timestamp of creation
updated_at
string
required
ISO 8601 timestamp of last update

List Companies

Retrieve a list of all companies in the system.
import axiosInstance from '@/lib/axios';
import { Company } from '@/types';

const fetchCompanies = async (): Promise<Company[]> => {
  const { data } = await axiosInstance.get('/company');
  return data;
};

Response

[
  {
    "id": 1,
    "name": "SIGEAC Airlines",
    "description": "Main aviation company",
    "slug": "sigeac-airlines",
    "rif": "J-12345678-9",
    "cod_inac": "INAC-001",
    "fiscal_address": "Av. Principal, Caracas, Venezuela",
    "phone_number": 582121234567,
    "alt_phone_number": 582129876543,
    "cod_iata": "SGC",
    "cod_oaci": "SGAC",
    "modules": [
      {
        "id": 1,
        "label": "Maintenance",
        "value": "maintenance",
        "registered_by": "admin"
      },
      {
        "id": 2,
        "label": "Warehouse",
        "value": "warehouse",
        "registered_by": "admin"
      }
    ],
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-03-10T14:20:00Z"
  }
]

Get Company by ID

Retrieve a specific company by its ID.
const fetchCompanyById = async (companyId: number): Promise<Company> => {
  const { data } = await axiosInstance.get(`/company/${companyId}`);
  return data;
};

Parameters

companyId
number
required
The unique identifier of the company

Company Modules

Modules define the functionality available to a company.

Module Object

id
number
Module identifier
label
string
Human-readable module name (e.g., “Maintenance”, “SMS”, “Warehouse”)
value
string
Module key used in code (e.g., “maintenance”, “sms”, “warehouse”)
registered_by
string
Username of the user who registered this module

Get Modules

Retrieve all available modules.
const fetchModules = async (): Promise<Module[]> => {
  const { data } = await axiosInstance.get('/modules');
  return data;
};

Get Modules by Company

Retrieve modules enabled for a specific company.
const fetchModulesByCompany = async (companyId: number): Promise<Module[]> => {
  const { data } = await axiosInstance.get(`/companies/${companyId}/modules`);
  return data;
};

Parameters

companyId
number
required
The company ID to fetch modules for

Companies with Warehouses

Get companies that have warehouses configured.
const fetchCompaniesWithWarehouses = async (): Promise<Company[]> => {
  const { data } = await axiosInstance.get('/companies/with-warehouses');
  return data;
};

Response

Returns an array of Company objects that have at least one warehouse associated.

Get Company Locations

Retrieve locations belonging to a specific company.
const fetchLocationsByCompany = async (companyId: number): Promise<Location[]> => {
  const { data } = await axiosInstance.get(`/companies/${companyId}/locations`);
  return data;
};

Parameters

companyId
number
required
The company ID to fetch locations for

Get Multiple Companies’ Locations

Retrieve locations for multiple companies.
const fetchLocationsByCompanies = async (
  companyIds: number[]
): Promise<Location[]> => {
  const { data } = await axiosInstance.post('/companies/locations', {
    company_ids: companyIds
  });
  return data;
};

Request Body

company_ids
number[]
required
Array of company IDs to fetch locations for

Examples

Check if Module is Enabled

const hasModule = (company: Company, moduleValue: string): boolean => {
  return company.modules.some((module) => module.value === moduleValue);
};

// Usage
if (hasModule(company, 'maintenance')) {
  console.log('Maintenance module is enabled');
}

Get Company Display Info

const getCompanyInfo = (company: Company) => {
  return {
    displayName: company.name,
    codes: {
      iata: company.cod_iata,
      icao: company.cod_oaci,
      inac: company.cod_inac,
    },
    contact: {
      phone: company.phone_number,
      altPhone: company.alt_phone_number,
      address: company.fiscal_address,
    },
  };
};

Filter Companies by Module

const getCompaniesWithModule = (
  companies: Company[],
  moduleValue: string
): Company[] => {
  return companies.filter((company) =>
    company.modules.some((module) => module.value === moduleValue)
  );
};

// Get all companies with SMS module
const smsCompanies = getCompaniesWithModule(companies, 'sms');

Format Company Code

const formatCompanyCode = (company: Company, type: 'iata' | 'icao'): string => {
  if (type === 'iata') {
    return company.cod_iata.toUpperCase();
  }
  return company.cod_oaci.toUpperCase();
};

Common Use Cases

Multi-tenancy

Companies are used to separate data between different organizations:
const getUserCompanies = (user: User): Company[] => {
  return user.companies || [];
};

// Filter data by user's companies
const filterByUserCompanies = <T extends { company: Company }>(
  items: T[],
  user: User
): T[] => {
  const userCompanyIds = getUserCompanies(user).map((c) => c.id);
  return items.filter((item) => userCompanyIds.includes(item.company.id));
};

Module-based UI Rendering

const shouldShowFeature = (company: Company, feature: string): boolean => {
  const moduleMap: Record<string, string> = {
    'maintenance-planning': 'maintenance',
    'warehouse-management': 'warehouse',
    'safety-reports': 'sms',
  };
  
  const requiredModule = moduleMap[feature];
  return requiredModule ? hasModule(company, requiredModule) : false;
};

Error Handling

Common Errors

  • 401 Unauthorized: Authentication token is missing or invalid
  • 403 Forbidden: User doesn’t have access to this company
  • 404 Not Found: Company with the specified ID doesn’t exist
  • 422 Unprocessable Entity: Invalid data provided

Error Response

message
string
Error message describing the issue
error
string
Error type or code
{
  "message": "Company not found",
  "error": "NOT_FOUND"
}

Build docs developers (and LLMs) love