Skip to main content
GET
/
api
/
v1
/
branches
List Branches
curl --request GET \
  --url https://api.example.com/api/v1/branches
{
  "success": true,
  "data": [
    {
      "id": 123,
      "company_id": 123,
      "codigo": "<string>",
      "nombre": "<string>",
      "direccion": "<string>",
      "ubigeo": "<string>",
      "distrito": "<string>",
      "provincia": "<string>",
      "departamento": "<string>",
      "telefono": "<string>",
      "email": "<string>",
      "series_factura": [
        {}
      ],
      "series_boleta": [
        {}
      ],
      "series_nota_credito": [
        {}
      ],
      "series_nota_debito": [
        {}
      ],
      "series_guia_remision": [
        {}
      ],
      "activo": true,
      "company": {
        "id": 123,
        "ruc": "<string>",
        "razon_social": "<string>"
      },
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ],
  "meta": {
    "total": 123,
    "companies_count": 123
  }
}
Retrieve a list of all branches in the system, optionally filtered by company.

Authentication

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

Query Parameters

company_id
integer
Filter branches by company ID. If not provided, returns all branches.

Response

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

Example Request

cURL (All Branches)
curl -X GET https://api.yourdomain.com/api/v1/branches \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json"
cURL (Filtered by Company)
curl -X GET "https://api.yourdomain.com/api/v1/branches?company_id=1" \
  -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/branches', [
  'headers' => [
    'Authorization' => 'Bearer YOUR_API_TOKEN',
    'Accept' => 'application/json',
  ],
  'query' => [
    'company_id' => 1,
  ],
]);

echo $response->getBody();
JavaScript
const response = await fetch(
  'https://api.yourdomain.com/api/v1/branches?company_id=1',
  {
    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,
      "company_id": 1,
      "codigo": "0001",
      "nombre": "Sucursal Principal",
      "direccion": "Av. Los Olivos 123",
      "ubigeo": "150101",
      "distrito": "San Isidro",
      "provincia": "Lima",
      "departamento": "Lima",
      "telefono": "01-1234567",
      "email": "[email protected]",
      "series_factura": ["F001", "F002"],
      "series_boleta": ["B001"],
      "series_nota_credito": ["FC01"],
      "series_nota_debito": ["FD01"],
      "series_guia_remision": ["T001"],
      "activo": true,
      "company": {
        "id": 1,
        "ruc": "20123456789",
        "razon_social": "EMPRESA DEMO S.A.C."
      },
      "created_at": "2024-01-15T10:30:00.000000Z",
      "updated_at": "2024-03-01T15:45:00.000000Z"
    },
    {
      "id": 2,
      "company_id": 1,
      "codigo": "0002",
      "nombre": "Sucursal Norte",
      "direccion": "Av. Túpac Amaru 456",
      "ubigeo": "150102",
      "distrito": "Independencia",
      "provincia": "Lima",
      "departamento": "Lima",
      "telefono": "01-9876543",
      "email": "[email protected]",
      "series_factura": ["F003"],
      "series_boleta": ["B002"],
      "series_nota_credito": ["FC02"],
      "series_nota_debito": ["FD02"],
      "series_guia_remision": ["T002"],
      "activo": true,
      "company": {
        "id": 1,
        "ruc": "20123456789",
        "razon_social": "EMPRESA DEMO S.A.C."
      },
      "created_at": "2024-02-10T11:20:00.000000Z",
      "updated_at": "2024-02-10T11:20:00.000000Z"
    }
  ],
  "meta": {
    "total": 2,
    "companies_count": 1
  }
}
500 Error
{
  "success": false,
  "message": "Error al obtener sucursales: Database connection failed"
}

Alternative Endpoint

You can also retrieve branches for a specific company using:
GET /api/v1/companies/{company_id}/branches
This endpoint returns the same branch structure but is scoped to a single company.
Branches are automatically loaded with their parent company’s basic information (id, ruc, razon_social) for reference.

Build docs developers (and LLMs) love