Skip to main content
POST
/
api
/
v1
/
companies
Create Company
curl --request POST \
  --url https://api.example.com/api/v1/companies
{
  "success": true,
  "message": "<string>",
  "data": {
    "id": 123,
    "ruc": "<string>",
    "razon_social": "<string>",
    "nombre_comercial": "<string>",
    "direccion": "<string>",
    "email": "<string>",
    "modo_produccion": true,
    "activo": true,
    "configurations": [
      {}
    ],
    "created_at": "<string>",
    "updated_at": "<string>"
  }
}
Create a new company in the system with SUNAT credentials and configuration.

Authentication

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

Request Body

ruc
string
required
11-digit tax identification number (RUC). Must be unique in the system.
razon_social
string
required
Legal business name (max 255 characters)
nombre_comercial
string
Commercial or trading name (max 255 characters)
direccion
string
required
Business address (max 255 characters)
ubigeo
string
required
6-digit UBIGEO code for geographic location
distrito
string
required
District name (max 100 characters)
provincia
string
required
Province name (max 100 characters)
departamento
string
required
Department/region name (max 100 characters)
telefono
string
Phone number (max 20 characters)
email
string
required
Company email address (max 255 characters, must be valid email format)
web
string
Company website URL (max 255 characters, must be valid URL)
usuario_sol
string
required
SUNAT SOL username (max 50 characters)
clave_sol
string
required
SUNAT SOL password (max 100 characters)
certificado_pem
file
Digital certificate file (.pem, .crt, .cer, .txt, max 2MB)
certificado_password
string
Password for the digital certificate (max 100 characters)
endpoint_beta
string
Custom SUNAT beta endpoint URL. If not provided, defaults to SUNAT’s standard beta endpoint.
endpoint_produccion
string
Custom SUNAT production endpoint URL. If not provided, defaults to SUNAT’s standard production endpoint.
modo_produccion
string
Environment mode: true, false, 1, or 0. Defaults to false (beta mode).
logo_path
file
Company logo image (.png, .jpg, .jpeg, max 2MB)
activo
boolean
Active status. Defaults to true.

Response

success
boolean
required
Indicates if the company was created successfully
message
string
required
Success message
data
object
required
The created company object with configurations

Example Request

cURL
curl -X POST https://api.yourdomain.com/api/v1/companies \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ruc": "20123456789",
    "razon_social": "EMPRESA DEMO S.A.C.",
    "nombre_comercial": "Demo Corp",
    "direccion": "Av. Los Olivos 123",
    "ubigeo": "150101",
    "distrito": "San Isidro",
    "provincia": "Lima",
    "departamento": "Lima",
    "telefono": "01-1234567",
    "email": "[email protected]",
    "usuario_sol": "MODDATOS",
    "clave_sol": "MODDATOS",
    "modo_produccion": false,
    "activo": true
  }'
PHP
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.yourdomain.com/api/v1/companies', [
  'headers' => [
    'Authorization' => 'Bearer YOUR_API_TOKEN',
    'Content-Type' => 'application/json',
  ],
  'json' => [
    'ruc' => '20123456789',
    'razon_social' => 'EMPRESA DEMO S.A.C.',
    'nombre_comercial' => 'Demo Corp',
    'direccion' => 'Av. Los Olivos 123',
    'ubigeo' => '150101',
    'distrito' => 'San Isidro',
    'provincia' => 'Lima',
    'departamento' => 'Lima',
    'telefono' => '01-1234567',
    'email' => '[email protected]',
    'usuario_sol' => 'MODDATOS',
    'clave_sol' => 'MODDATOS',
    'modo_produccion' => false,
    'activo' => true,
  ],
]);

echo $response->getBody();
JavaScript
const response = await fetch('https://api.yourdomain.com/api/v1/companies', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    ruc: '20123456789',
    razon_social: 'EMPRESA DEMO S.A.C.',
    nombre_comercial: 'Demo Corp',
    direccion: 'Av. Los Olivos 123',
    ubigeo: '150101',
    distrito: 'San Isidro',
    provincia: 'Lima',
    departamento: 'Lima',
    telefono: '01-1234567',
    email: '[email protected]',
    usuario_sol: 'MODDATOS',
    clave_sol: 'MODDATOS',
    modo_produccion: false,
    activo: true
  })
});

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

Example Response

201 Created
{
  "success": true,
  "message": "Empresa creada exitosamente",
  "data": {
    "id": 1,
    "ruc": "20123456789",
    "razon_social": "EMPRESA DEMO S.A.C.",
    "nombre_comercial": "Demo Corp",
    "direccion": "Av. Los Olivos 123",
    "ubigeo": "150101",
    "distrito": "San Isidro",
    "provincia": "Lima",
    "departamento": "Lima",
    "telefono": "01-1234567",
    "email": "[email protected]",
    "usuario_sol": "MODDATOS",
    "modo_produccion": false,
    "activo": true,
    "endpoint_beta": "https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService",
    "endpoint_produccion": "https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService",
    "configurations": [],
    "created_at": "2024-03-05T10:30:00.000000Z",
    "updated_at": "2024-03-05T10:30:00.000000Z"
  }
}
422 Validation Error
{
  "success": false,
  "message": "Errores de validación",
  "errors": {
    "ruc": [
      "El RUC ya está registrado"
    ],
    "email": [
      "El correo debe tener un formato válido"
    ]
  }
}
500 Error
{
  "success": false,
  "message": "Error al crear empresa: Database error"
}
Default Endpoints: If not specified, the system automatically assigns SUNAT’s standard endpoints:
  • Beta: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService
  • Production: https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService
Security: The clave_sol, certificado_pem, certificado_password, and GRE credentials are hidden in API responses for security.

Build docs developers (and LLMs) love