Create a new branch (sucursal) for a company.
Authentication
This endpoint requires authentication. Include your API token in the request header:
Authorization: Bearer YOUR_API_TOKEN
Request Body
ID of the parent company. The company must exist and be active.
Branch code (max 10 characters). Must be unique within the company.
Branch name (max 255 characters)
Branch address (max 255 characters)
6-digit UBIGEO code for geographic location
District name (max 100 characters)
Province name (max 100 characters)
Department/region name (max 100 characters)
Phone number (max 20 characters)
Branch email address (max 255 characters, must be valid email format)
Contact person name (max 255 characters)
Array of invoice series codes (e.g., [“F001”, “F002”])
Array of sales receipt series codes (e.g., [“B001”, “B002”])
Array of credit note series codes (e.g., [“FC01”])
Array of debit note series codes (e.g., [“FD01”])
Array of dispatch guide series codes (e.g., [“T001”])
Active status. Defaults to true.
Response
Indicates if the branch was created successfully
The created branch object with company information Unique identifier for the branch
Sales receipt series codes
Dispatch guide series codes
Parent company information
Example Request
curl -X POST https://api.yourdomain.com/api/v1/branches \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"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
}'
$client = new \GuzzleHttp\ Client ();
$response = $client -> request ( 'POST' , 'https://api.yourdomain.com/api/v1/branches' , [
'headers' => [
'Authorization' => 'Bearer YOUR_API_TOKEN' ,
'Content-Type' => 'application/json' ,
],
'json' => [
'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 ,
],
]);
echo $response -> getBody ();
const response = await fetch ( 'https://api.yourdomain.com/api/v1/branches' , {
method: 'POST' ,
headers: {
'Authorization' : 'Bearer YOUR_API_TOKEN' ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
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
})
});
const data = await response . json ();
console . log ( data );
Example Response
{
"success" : true ,
"message" : "Sucursal creada exitosamente" ,
"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-03-05T10:30:00.000000Z" ,
"updated_at" : "2024-03-05T10:30:00.000000Z"
}
}
{
"success" : false ,
"message" : "La empresa especificada no existe o está inactiva"
}
{
"success" : false ,
"message" : "Errores de validación" ,
"errors" : {
"codigo" : [
"El código de sucursal ya existe para esta empresa."
],
"email" : [
"El email debe tener un formato válido."
],
"ubigeo" : [
"El ubigeo debe tener exactamente 6 caracteres."
]
}
}
{
"success" : false ,
"message" : "Error al crear sucursal: Database error"
}
Branch Code Uniqueness : The codigo field must be unique within each company. Multiple companies can have branches with the same code, but within a single company all branch codes must be unique.
The parent company must be active (activo: true) to create a branch. Attempting to create a branch for an inactive company will result in a 404 error.