Saltar al contenido principal

kobana finance companies

Comandos de kobana finance companies. Toda opción global (Opciones globales) vale aquí.

ComandoHTTPDescripción
companies listGET /v1/companiesListar empresas
companies createPOST /v1/companiesCrear empresa
companies getGET /v1/companies/{id}Obtener empresa por ID
companies updatePATCH /v1/companies/{id}Actualizar empresa
companies deleteDELETE /v1/companies/{id}Eliminar empresa

companies list​

Listar empresas

kobana finance companies list [OPCIONES]

GET /v1/companies

Returns a cursor-paginated page of companies for the workspace tied to the token's sub claim. Requires scope finance/companies with access level read. Catalogal entity — defaults to alphabetical sort by name.

Parámetros de consulta

NombreTipoObligatorioDescripción
activestringnoFilter by active flag. true returns only active; omit to return both. Valores: true, false.
typestringnomatriz (head office) or filial (branch). Accepts [in]=matriz,filial. Valores: matriz, filial.
cnpjstringnoFilter by CNPJ (14-digit numeric string, no formatting). Accepts [in]=cnpj1,cnpj2.
namestringnoFilter by exact name. Accepts [in].
sort_bystringnoField to order by. Default: sort_by=name&sort_order=asc. Valores: created_at, name.
sort_orderstringnoOrder direction. Defaults to asc; ignored without sort_by. Valores: asc, desc.
limitintegernoPage size. Default 25, max 100.
cursorstringnoOpaque cursor for the next page. Round-trip meta.next_cursor from the previous response.
fieldsstringnoComma-separated top-level fields to return, e.g. fields=description,amount,due_date. Omit for every field. id is always included; naming an object field returns it whole. An unknown name is a 400 whose details lists unknown and available.

Encabezados

NombreTipoObligatorioDescripción
X-Workspace-IdstringsíWorkspace to act on, as a UUID. The token identifies the organization; this header picks which of its workspaces the request reads or writes. It is checked against the token's organization, so a workspace owned by anyone else answers UNKNOWN_WORKSPACE — the same code as one that does not exist. Omitting it answers WORKSPACE_REQUIRED (400).

Respuestas

HTTPDescripción
200Page of companies plus pagination metadata.
400Malformed query (unknown filter / operator, invalid limit, bad cursor).

companies create​

Crear empresa

kobana finance companies create [OPCIONES]

POST /v1/companies

Creates a company. Requires scope finance/companies with access level write. cnpj is required and validated with the standard BR check-digit algorithm — a missing, invalid, or document-less value returns 422 (there is no pessoa-física / document-less company in this API; a migrating client whose source row has no CNPJ must supply one). The CNPJ must be unique among active companies in the workspace (duplicate → 409). type (matriz/filial) is derived server-side from the CNPJ branch digits and is never read from the request. active starts true. Pass an X-Idempotency-Key header on retries.

Encabezados

NombreTipoObligatorioDescripción
X-Workspace-IdstringsíWorkspace to act on, as a UUID. The token identifies the organization; this header picks which of its workspaces the request reads or writes. It is checked against the token's organization, so a workspace owned by anyone else answers UNKNOWN_WORKSPACE — the same code as one that does not exist. Omitting it answers WORKSPACE_REQUIRED (400).

Cuerpo de la solicitud

NombreTipoObligatorioDescripción
namestringsíLegal name as registered.
cnpjstringsíCNPJ — 14 characters. Formatting (dots / slash / dash) is accepted and stripped; letters are uppercased. Supports both numeric-only (legacy) and alphanumeric (new RFB format) CNPJs. Validated with the standard BR check-digit algorithm. Required — a missing, invalid, or document-less value returns 422. Must be unique among active companies in the workspace (duplicate → 409). type (matriz/filial) is derived server-side.
trade_namestringno
municipal_registrationstringno
tax_regimestringnoValores: SimplesNacional, SimplesNacionalExcessoSublimite, MicroempreendedorIndividual, LucroPresumido, LucroReal, Isento.
addressobjectno
custom_metadataobjectnoMetadados do usuário: objeto JSON livre. Envie null para limpar. Máx. 64 KB serializado, 16 níveis.

Otros campos y objetos anidados: kobana schema finance.companies.create.

Respuestas

HTTPDescripción
201Company created. The Location header points at the new row; type is derived from the CNPJ.
400Malformed JSON body.
409A company with the same CNPJ already exists (active), or X-Idempotency-Key reuse with a different body.
422Schema validation failure, or a missing / invalid / document-less cnpj.

companies get​

Obtener empresa por ID

kobana finance companies get [ID] [OPCIONES]

GET /v1/companies/{id}

Returns the same shape as the rows from the list endpoint. Requires scope finance/companies with access level read. 404 covers both "doesn't exist" and "not in the tenant" — the API does not distinguish.

Argumentos de la ruta: id

Parámetros de consulta

NombreTipoObligatorioDescripción
fieldsstringnoComma-separated top-level fields to return, e.g. fields=description,amount,due_date. Omit for every field. id is always included; naming an object field returns it whole. An unknown name is a 400 whose details lists unknown and available.

Encabezados

NombreTipoObligatorioDescripción
X-Workspace-IdstringsíWorkspace to act on, as a UUID. The token identifies the organization; this header picks which of its workspaces the request reads or writes. It is checked against the token's organization, so a workspace owned by anyone else answers UNKNOWN_WORKSPACE — the same code as one that does not exist. Omitting it answers WORKSPACE_REQUIRED (400).

Respuestas

HTTPDescripción
200Get a company by id
404Company not found within the tenant.

companies update​

Actualizar empresa

kobana finance companies update [ID] [OPCIONES]

PATCH /v1/companies/{id}

Partial update of name and active. Requires scope finance/companies with access level write. The CNPJ (and the type it derives) is immutable via the public API — send active: false to soft-deactivate.

Argumentos de la ruta: id

Encabezados

NombreTipoObligatorioDescripción
X-Workspace-IdstringsíWorkspace to act on, as a UUID. The token identifies the organization; this header picks which of its workspaces the request reads or writes. It is checked against the token's organization, so a workspace owned by anyone else answers UNKNOWN_WORKSPACE — the same code as one that does not exist. Omitting it answers WORKSPACE_REQUIRED (400).

Cuerpo de la solicitud

NombreTipoObligatorioDescripción
namestringno
activebooleannoSet false to soft-deactivate the company (existing references are preserved).
trade_namestringno
municipal_registrationstringno
tax_regimestringnoValores: SimplesNacional, SimplesNacionalExcessoSublimite, MicroempreendedorIndividual, LucroPresumido, LucroReal, Isento.
addressobjectnoReplaces the fiscal address wholesale. null clears it; omitting it leaves it untouched. It is never merged field by field — a partial merge would leave a company registered under half of one address and half of another.
custom_metadataobjectnoMetadados do usuário: objeto JSON livre. Envie null para limpar. Máx. 64 KB serializado, 16 níveis.
custom_metadata_modestringnoComo o custom_metadata enviado é reconciliado com o valor armazenado: replace (padrão) substitui o objeto inteiro, merge faz deep merge sobre o valor atual. Aceito apenas na atualização. Valores: replace, merge.

Otros campos y objetos anidados: kobana schema finance.companies.update.

Respuestas

HTTPDescripción
200Updated company.
400Malformed JSON body.
404Company not found within the tenant.
409X-Idempotency-Key reused with a different body.
422Schema validation failure.

companies delete​

Eliminar empresa

kobana finance companies delete [ID] [OPCIONES]

DELETE /v1/companies/{id}

Hard-deletes a company. Requires scope finance/companies with access level delete. Blocked with 409 (details carries the per-table counts { transactions, payables, receivables, people }) when the company still has financial records or active people — remove or reassign those first, or soft-deactivate via PATCH { active: false }. Config tables (categories, classification centers, financial accounts, soft-deleted people) cascade automatically. Calling DELETE twice returns 200 then 404.

Argumentos de la ruta: id

Encabezados

NombreTipoObligatorioDescripción
X-Workspace-IdstringsíWorkspace to act on, as a UUID. The token identifies the organization; this header picks which of its workspaces the request reads or writes. It is checked against the token's organization, so a workspace owned by anyone else answers UNKNOWN_WORKSPACE — the same code as one that does not exist. Omitting it answers WORKSPACE_REQUIRED (400).

Respuestas

HTTPDescripción
200Company deleted.
404Company not found within the tenant.
409The company has financial records or active people (details carries the counts).