Business Partners (BusinessPartner) represent all legal and natural persons interacting with the enterprise in GOAL: Customers (customer), Suppliers (supplier), and Employees (employee).
remote_id)Each business partner may store remote_id, mapped from SAP Business One OCRD.DocEntry. This stable identifier preserves the same GOAL record even when CardCode changes in the ERP.
Match order during SAP sync:
business_partners.code = SAP CardCodebusiness_partners.remote_id = SAP DocEntryIf both lookups resolve to different GOAL rows, sync fails with a conflict error (manual reconciliation required).
/v1/base/business-partners
| Header | Type | Description |
|---|---|---|
Authorization |
string |
Bearer <token> OAuth2 access token. |
x-app-stage |
string |
Current tenant stage (dev, staging, prod). |
x-app-uid |
string |
Authenticated user UUID. |
| Parameter | Type | Default | Description |
|---|---|---|---|
companyId |
integer |
Required | Current operational company ID. |
view |
string |
A |
State filter: A (Active), I (Inactive), D (Trashed), ALL (All records). |
search |
string |
- | Case-insensitive search on card_code, card_name, tax_id. |
limit |
integer |
15 |
Number of records to return. |
skip |
integer |
0 |
Offset count for pagination. |
sort_field |
string |
id |
Valid sort field name. |
sort_order |
string |
asc |
asc or desc. |
Retrieve a paginated collection of business partners.
GET /v1/base/business-partners?companyId=1&view=A&search=BODEGA&limit=15&skip=0
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 1045,
"company_id": 1,
"code": "C20485918231",
"card_type": "C",
"roles": ["customer"],
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"full_name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"comercial_name": "COMERCIAL SAN JUAN",
"short_name": "SAN JUAN",
"person_type": "J",
"tax_id": "20485918231",
"tax_id_type_id": 1,
"email": "contacto@sanjuan.pe",
"is_customer": "Y",
"customer_status": "A",
"is_vendor": "N",
"is_employee": "N",
"status": "A",
"has_credit_line": "Y",
"credit_limit": 50000.00,
"balance": 14200.50,
"total_address_reserved_credit": 20000.00,
"unallocated_credit": 30000.00,
"available_credit": 35799.50
}
]
}
Register a new business partner entity. By default, every new partner is created with default customer role (is_customer: "Y", customer_status: "A", is_vendor: "N", is_employee: "N").
POST /v1/base/business-partners?companyId=1
Content-Type: application/json
{
"name": "COMERCIAL EL INCA S.A.C.",
"comercial_name": "BODEGA EL INCA",
"short_name": "EL INCA",
"tax_id": "20556677889",
"tax_id_type_id": 1,
"person_type": "J",
"email": "contacto@elinca.pe",
"business_partner_group_id": 100,
"business_type_id": 2,
"customer_channel_id": 4,
"sell_payment_term_id": 3
}
200 OK (201 Created){
"success": true,
"message": "Socio de negocio creado exitosamente",
"data": {
"id": 1046,
"company_id": 1,
"code": "C20556677889",
"name": "COMERCIAL EL INCA S.A.C.",
"tax_id": "20556677889",
"is_customer": "Y",
"customer_status": "A",
"status": "A"
}
}
Get full master data profile by numeric ID, code, or UUID.
GET /v1/base/business-partners/1045?companyId=1
200 OK{
"success": true,
"message": "Detalle obtenido correctamente",
"data": {
"id": 1045,
"company_id": 1,
"code": "C20485918231",
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"tax_id": "20485918231",
"is_customer": "Y",
"customer_status": "A",
"is_vendor": "N",
"is_employee": "N",
"has_credit_line": "Y",
"credit_limit": 50000.00,
"balance": 14200.50,
"status": "A"
}
}
Update master data details, addresses, contacts, or tax identifiers.
PUT /v1/base/business-partners/1045?companyId=1
Content-Type: application/json
{
"name": "DISTRIBUIDORA SAN JUAN & ASOCIADOS S.A.C.",
"comercial_name": "SAN JUAN DISTRIBUCIONES",
"email": "facturacion@sanjuan.pe"
}
PUT /v1/base/business-partners/{id} verifies changed fields against granular BUSINESS_PARTNER action groups:
| Changed field group | Required permission code |
|---|---|
| Core / customer profile (name, tax, customer flags, credit, etc.) | GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_UPDATE |
Supplier / vendor (is_vendor, vendor_*, buy_payment_term_id) |
GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_SUPPLIER_UPDATE |
Employee (is_employee, employee_*, branch_id, departament_id, …) |
GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_EMPLOYEE_UPDATE |
If the authenticated user lacks permission for any modified field group, a 403 Forbidden response is returned.
Soft delete a business partner. Sets deleted_by = auth()->user()->id.
DELETE /v1/base/business-partners/1045?companyId=1
200 OK{
"success": true,
"message": "Registro eliminado correctamente",
"data": null
}
Restore a previously soft-deleted business partner. Sets restored_by = auth()->user()->id.
PUT /v1/base/business-partners/1045/restore?companyId=1
200 OK{
"success": true,
"message": "Registro restaurado correctamente",
"data": {
"id": 1045,
"status": "A",
"name": "DISTRIBUIDORA SAN JUAN S.A.C."
}
}
Retrieve only soft-deleted records for audit and recovery.
GET /v1/base/business-partners/trasheds?companyId=1&limit=15&skip=0
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 1045,
"code": "C20485918231",
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"status": "D"
}
]
}
Retrieve lightweight summary data (card code, name, type) for header banners and navigation cards.
GET /v1/base/business-partners/1045/summary?companyId=1
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": {
"id": 1045,
"company_id": 1,
"uuid": "7a3b4c5d-6e7f-8a9b-0c1d-2e3f4a5b6c7d",
"code": "C20485918231",
"cardCode": "C20485918231",
"cardName": "DISTRIBUIDORA SAN JUAN S.A.C.",
"cardType": "C",
"type": "cliente"
}
}
Optimized autocomplete endpoint returning up to 300 active partners formatted with BusinessPartnerSimpleResource. Supports exclusion lists and multi-attribute search.
GET /v1/base/business-partners/autocomplete?companyId=1&idsToExclude=10,25&searchText[query]=SAN JUAN
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId |
integer |
Yes | Company scope. |
searchText[query] |
string |
No | Search text matching numeric ID, full_name, name, or customer_code. |
idsToExclude |
string |
No | Comma-separated list of IDs to exclude (e.g. 10,25,32). |
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 1045,
"company_id": 1,
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"full_name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"comercial_name": "COMERCIAL SAN JUAN",
"customer_code": "C20485918231",
"is_customer": "Y",
"customer_status": "A",
"is_employee": "N",
"status": "A"
}
]
}
Performs deep filtering by attributes across legal and commercial names with standard pagination metadata.
GET /v1/base/business-partners/search?companyId=1&search=SAN JUAN&idsToExclude=10,25&page=1&per_page=20
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": {
"data": [
{
"id": 1045,
"company_id": 1,
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"customer_code": "C20485918231",
"status": "A"
}
],
"pagination": {
"total": 1,
"count": 1,
"per_page": 20,
"current_page": 1,
"total_pages": 1
}
}
}
Batch import business partners from a structured Excel template (.xlsx). Supports dry-run validation without committing to the database.
GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_INSERTPOST /v1/base/business-partners/bulk-import?companyId=1
Content-Type: application/json
{
"company_id": 1,
"files": [
{
"path": "/storage/app/tmp/imports/socios_plantilla.xlsx",
"fileName": "socios_plantilla.xlsx"
}
],
"template_has_comments": true,
"dry_run": false
}
200 OK{
"success": true,
"message": "Importación de socios de negocio procesada.",
"data": [
{
"row": 3,
"success": true,
"code": "C20556677889",
"action": "created"
},
{
"row": 4,
"success": false,
"errors": ["El RUC 20485918231 ya se encuentra registrado"]
}
]
}
Mass update of electronic invoicing email addresses directly into SAP Business One OCRD.E_Mail and OCRD.u_bks_enviomail = 'Y'.
POST /v1/base/business-partners/import-emails?companyId=1
Content-Type: application/json
{
"company_id": 1,
"files": [
{
"path": "/storage/app/tmp/imports/correos_facturacion.xlsx",
"fileName": "correos_facturacion.xlsx"
}
]
}
Excel columns required: CardCode, Email.
200 OK{
"success": true,
"message": "Se importaron los correos correctamente para la empresa ROMA S.A.C.\nSe actualizaron 150 registros.",
"data": []
}
Retrieve all registered shipping and fiscal addresses in GOAL with related branch, territory, seller, and business type details.
GET /v1/base/business-partners/1045/addresses?companyId=1
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 312,
"company_id": 1,
"business_partner_id": 1045,
"code": "001",
"address_type": "delivery",
"address": "AV. LOS PROCERES 1234",
"comercial_name": "BODEGA PROCERES",
"latitude": -12.046374,
"longitude": -77.042793,
"branch": { "id": 2, "code": "SUC01", "name": "Sucursal Centro" },
"territory": { "id": 15, "code": "TERR01", "name": "Zona Norte" },
"seller": { "id": 84, "code": "V01", "name": "Vendedor Principal" },
"has_credit_line": "Y",
"credit_limit": 20000.00,
"apply_credit_charge": "Y"
}
]
}
Retrieve delivery addresses directly from SAP Business One ERP using the active database adapter.
GET /v1/base/business-partners/1045/erp-addresses?companyId=1
200 OK{
"success": true,
"message": "Direcciones de entrega",
"data": [
{
"address": "ENTREGA PRINCIPAL",
"street": "AV. LOS PROCERES 1234",
"district": "LIMA",
"city": "LIMA",
"country": "PE",
"tax_code": "IGV",
"federal_tax_id": "20485918231"
}
]
}
/{id}/sales-teams)Manages commercial sales team assignments (sales_team_customers) for the customer in GOAL.
GET /v1/base/business-partners/1045/sales-teams?companyId=1&view=ACTIVE
| Parameter | Type | Default | Description |
|---|---|---|---|
companyId |
integer |
Required | Operational company ID. |
view |
string |
ACTIVE |
ACTIVE, INACTIVE, ALL, DELETED. |
salesTeamId |
integer |
- | Filter by sales team ID. |
stationCode |
string |
- | Filter by station code. |
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 88,
"company_id": 1,
"customer_id": 1045,
"sales_team_id": 12,
"sales_team_code": "039",
"seller_id": 84,
"zone_code": "Z01",
"route_code": "R01",
"day_code": "LUN",
"frequency": "S",
"has_custom_credit_limit": "Y",
"custom_credit_limit": 12000.00,
"apply_credit_charge": "Y",
"status": "A"
}
]
}
POST /v1/base/business-partners/1045/sales-teams?companyId=1
Content-Type: application/json
{
"sales_team_id": 12,
"business_partner_address_id": 312,
"seller_id": 84,
"zone_code": "Z01",
"route_code": "R01",
"day_code": "LUN",
"frequency": "S",
"credit_limit": 15000.00
}
201 Created{
"success": true,
"message": "Asignación de equipo de ventas creada exitosamente",
"data": {
"id": 89,
"sales_team_id": 12,
"customer_id": 1045,
"status": "A"
}
}
GET /v1/base/business-partners/1045/sales-teams/88?companyId=1
PUT /v1/base/business-partners/1045/sales-teams/88?companyId=1
Content-Type: application/json
{
"seller_id": 92,
"route_code": "R02",
"day_code": "MAR",
"frequency": "Q"
}
Soft delete the sales team assignment.
DELETE /v1/base/business-partners/1045/sales-teams/88?companyId=1
PUT /v1/base/business-partners/1045/sales-teams/88/restore?companyId=1
GET /v1/base/business-partners/1045/sales-teams/trasheds?companyId=1
Triggers batch synchronization of active sales team relations from SAP B1 into GOAL.
POST /v1/base/business-partners/1045/sales-teams/sync?companyId=1
Content-Type: application/json
{
"limit": 10000,
"force": false,
"without_confirmation": false
}
200 OK{
"success": true,
"message": "Sincronización de equipos de ventas completada",
"data": {
"processed": 1450,
"created": 12,
"updated": 1438,
"failed": 0
}
}
Direct operations over SAP Business One sales team tables (gproc.cliente_mesa, sp_up_cartera, and GIS pre-sale boundaries).
Queries SAP Business One gproc.cliente_mesa for the active and historical mesa assignments of the customer.
GET /v1/base/business-partners/1045/erp-sales-teams?companyId=1
200 OK{
"success": true,
"message": "Equipos de venta ERP obtenidos",
"data": [
{
"sales_team_code": "039",
"sales_team_name": "MESA BEES SUR",
"zone_code": "Z01",
"route_code": "R01",
"day_code": "LUN",
"frequency": "S",
"status": "A",
"seller_code": "084"
}
]
}
Update route, day, frequency, or seller parameters for the customer in the SAP B1 mesa.
PUT /v1/base/business-partners/1045/erp-sales-teams/update?companyId=1
Content-Type: application/json
{
"customer_code": "C20485918231",
"sales_team_code": "039",
"zone_code": "Z01",
"route_code": "R02",
"day_code": "MAR",
"frequency": "Q",
"warehouse_code": "01",
"seller_code": "084"
}
200 OK{
"success": true,
"message": "Equipo de ventas del cliente actualizado correctamente (Simulado)",
"data": null
}
Activates the customer in the SAP B1 sales team / cartera using ActivateBusinessCustomerForSalesTeamAction.
POST /v1/base/business-partners/1045/erp-sales-teams/activate?companyId=1
Content-Type: application/json
{
"customer_code": "C20485918231",
"sales_team_code": "039"
}
200 OK{
"success": true,
"message": "Cliente activado en la mesa correctamente",
"data": null
}
Sets U_BKP_ESTADO = 'I' in SAP B1 gproc.cliente_mesa and triggers cartera reconciliation via exec [gProc].[sp_up_cartera].
POST /v1/base/business-partners/1045/erp-sales-teams/deactivate?companyId=1
Content-Type: application/json
{
"customer_code": "C20485918231",
"sales_team_code": "039"
}
200 OK{
"success": true,
"message": "Cliente desactivado de la mesa correctamente",
"data": null
}
Validates that the customer has valid latitude/longitude coordinates and that those coordinates intersect with active GIS polygon territories assigned to the specified sales team.
POST /v1/base/business-partners/1045/erp-sales-teams/validate?companyId=1
Content-Type: application/json
{
"customer_code": "C20485918231",
"sales_team_code": "039"
}
200 OK{
"success": true,
"message": "El cliente se encuentra dentro del territorio del equipo de ventas.",
"data": {
"is_valid": true,
"territory_id": 15,
"territory_code": "TERR01"
}
}
400 Bad RequestReturned when coordinates are missing or fall outside configured territory polygons:
{
"success": false,
"message": "El cliente no tiene coordenadas geográficas válidas para validar. Codigo: C20485918231 Direccion: AV. LOS PROCERES 1234",
"data": null
}
Audit and verify that the customer is fully configured for mobile pre-sale operations: validates branch coordinates, ERP customer status, delivery address coordinates, and GIS territory polygon intersection.
GET /v1/base/business-partners/1045/check-presale?companyId=1&branchCode=01
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId |
integer |
Yes | Operational company ID. |
branchCode |
string |
Yes | Target operational branch code. |
200 OK{
"success": true,
"message": "Validación de preventa completada.",
"data": {
"customers": 1,
"address": 1,
"polygon": 1,
"division": 1,
"is_ready_for_presale": true
}
}
Sync or refresh a business partner directly from SAP B1 OCRD (SyncBusinessPartnerFromSapAction). Path {id} may be GOAL numeric id, uuid, or SAP CardCode (e.g. CL00021894).
POST /v1/base/business-partners/CL00021894/import-from-sap?companyId=8&company_id=8
Requires companyId (or company_id) and permission GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_UPDATE. GET on the same path remains for legacy clients.
200 OK{
"success": true,
"message": "Socio de negocio sincronizado exitosamente desde SAP",
"data": {
"id": 1045,
"code": "C20485918231",
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"tax_id": "20485918231",
"status": "A"
}
}
Returns hierarchical credit metrics, payment-term context, and credit-purchase surcharge flags (apply_credit_charge, credit_charge_applicable).
GET /v1/base/business-partners/1045/credit-summary?companyId=1
200 OK{
"success": true,
"message": "Resumen de línea de crédito obtenido con éxito",
"data": {
"business_partner_id": 1045,
"customer_code": "C20485918231",
"name": "DISTRIBUIDORA SAN JUAN S.A.C.",
"has_credit_line": "Y",
"credit_limit": 50000.0,
"balance": 5000.0,
"total_address_reserved_credit": 20000.0,
"available_credit": 45000.0,
"unallocated_credit": 30000.0,
"utilization_percent": 10.0,
"sell_payment_term_id": 12,
"sell_payment_term_name": "Crédito 30 días",
"sell_payment_term_days": 30,
"is_credit_payment_term": true,
"credit_purchase_allowed": true,
"apply_credit_charge": "Y",
"credit_charge_applicable": true,
"shipping_addresses": [
{
"id": 312,
"code": "001",
"has_credit_line": "Y",
"credit_limit": 20000.0,
"apply_credit_charge": "Y",
"credit_charge_applicable": true
}
],
"sales_teams": [
{
"id": 88,
"sales_team_code": "039",
"has_custom_credit_limit": "Y",
"custom_credit_limit": 12000.0,
"apply_credit_charge": "Y",
"credit_charge_applicable": true
}
]
}
}
Updates GOAL has_credit_line / credit_limit and pushes OCRD.CreditLine to SAP for the partner code (CardCode). On SAP failure, GOAL values are rolled back.
PUT /v1/base/business-partners/1045/credit-line?companyId=1
Content-Type: application/json
{
"has_credit_line": "Y",
"credit_limit": 75000.00
}
| Field | Type | Description |
|---|---|---|
has_credit_line |
Y | N |
Whether global credit line is enabled. |
credit_limit |
number |
Required when has_credit_line is Y; written to SAP CreditLine (0 when inactive). |
Sets credit allocation for a specific shipping address of the partner.
PUT /v1/base/business-partners/1045/addresses/312/credit-reservation?companyId=1
Content-Type: application/json
{
"has_credit_line": "Y",
"credit_limit": 25000.00
}
Sets custom credit limit for a sales team customer assignment.
PUT /v1/base/business-partners/1045/sales-teams/88/credit-limit?companyId=1
Content-Type: application/json
{
"has_custom_credit_limit": "Y",
"custom_credit_limit": 12000.00
}
Per-level opt-out of financial surcharges on credit orders (default Y). Does not affect credit limits.
PUT /v1/base/business-partners/1045/credit-charge-flag?companyId=1
PUT /v1/base/business-partners/1045/addresses/312/credit-charge-flag?companyId=1
PUT /v1/base/business-partners/1045/sales-teams/88/credit-charge-flag?companyId=1
Content-Type: application/json
{
"apply_credit_charge": "N"
}
Enable or disable multi-role memberships (customer, supplier, employee) for a single Business Partner entity.
PUT /v1/base/business-partners/1045/roles?companyId=1
Content-Type: application/json
{
"is_customer": true,
"is_supplier": true,
"is_employee": false
}
Enforces the same field-group authorization rules as Update Business Partner:
GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_SUPPLIER_UPDATE.GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_EMPLOYEE_UPDATE.GOAL_V2_BASE_BUSINESSPARTNER_BUSINESS_PARTNER_UPDATE.200 OK{
"success": true,
"message": "Roles actualizados correctamente",
"data": {
"id": 1045,
"roles": ["customer", "supplier"],
"is_customer": "Y",
"is_vendor": "Y",
"is_employee": "N"
}
}
| Code | Meaning / When Returned |
|---|---|
200 OK |
Request processed successfully with standard ActionResult envelope. |
201 Created |
Entity successfully created (POST /v1/base/business-partners). |
400 Bad Request |
Validation failure, missing required query/body parameters, or business constraint error. |
401 Unauthorized |
Missing, expired, or invalid OAuth2 JWT Bearer token. |
403 Forbidden |
Authenticated user lacks granular V2 permissions for requested model action or field group. |
404 Not Found |
Business partner, company, address, or sales team relation was not found. |
422 Unprocessable Entity |
Model sequence unconfigured or constraint failure (tax_id uniqueness, document type format). |
500 Server Error |
Unexpected backend exception, database connection failure, or unhandled SAP adapter error. |