Skip to main content
GET
/
api
/
v1
/
companies
List Companies
curl --request GET \
  --url https://api.example.com/api/v1/companies
{
  "success": true,
  "data": [
    {
      "id": 123,
      "ruc": "<string>",
      "razon_social": "<string>",
      "nombre_comercial": "<string>",
      "direccion": "<string>",
      "distrito": "<string>",
      "provincia": "<string>",
      "departamento": "<string>",
      "email": "<string>",
      "telefono": "<string>",
      "modo_produccion": true,
      "activo": true,
      "branches": [
        {}
      ],
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ],
  "meta": {
    "total": 123,
    "active_count": 123,
    "production_count": 123
  }
}
Retrieve a list of all active companies in the system with their associated branches.

Authentication

This endpoint requires authentication. Include your API token in the request header:
Authorization: Bearer YOUR_API_TOKEN

Response

Returns an array of company objects with metadata including counts and statistics.

Response Fields

success
boolean
required
Indicates if the request was successful
data
array
required
Array of company objects
meta
object
required
Metadata about the companies

Example Request

cURL
curl -X GET https://api.yourdomain.com/api/v1/companies \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json"
PHP
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.yourdomain.com/api/v1/companies', [
  'headers' => [
    'Authorization' => 'Bearer YOUR_API_TOKEN',
    'Accept' => 'application/json',
  ],
]);

echo $response->getBody();
JavaScript
const response = await fetch('https://api.yourdomain.com/api/v1/companies', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Accept': 'application/json'
  }
});

const data = await response.json();
console.log(data);

Example Response

200 OK
{
  "success": true,
  "data": [
    {
      "id": 1,
      "ruc": "20123456789",
      "razon_social": "EMPRESA DEMO S.A.C.",
      "nombre_comercial": "Demo Corp",
      "direccion": "Av. Los Olivos 123",
      "distrito": "San Isidro",
      "provincia": "Lima",
      "departamento": "Lima",
      "email": "[email protected]",
      "telefono": "01-1234567",
      "modo_produccion": false,
      "activo": true,
      "branches": [
        {
          "id": 1,
          "company_id": 1,
          "codigo": "0001",
          "nombre": "Sucursal Principal",
          "activo": true
        }
      ],
      "created_at": "2024-01-15T10:30:00.000000Z",
      "updated_at": "2024-03-01T15:45:00.000000Z"
    }
  ],
  "meta": {
    "total": 1,
    "active_count": 1,
    "production_count": 0
  }
}
500 Error
{
  "success": false,
  "message": "Error al obtener empresas: Database connection failed"
}
Only active companies are returned by this endpoint. The response includes eager-loaded branch relationships for each company.

Build docs developers (and LLMs) love