Pular para o conteúdo principal

kobana finance companies

Comandos de kobana finance companies. Toda opção global (Opções globais) vale aqui.

ComandoHTTPDescrição
companies listGET /v1/companiesListar empresas
companies createPOST /v1/companiesCriar empresa
companies getGET /v1/companies/{id}Obter empresa por ID
companies updatePATCH /v1/companies/{id}Atualizar empresa
companies deleteDELETE /v1/companies/{id}Excluir empresa

companies list​

Listar empresas

kobana finance companies list [OPÇÕES]

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

NomeTipoObrigatórioDescrição
activestringnãoFilter by active flag. true returns only active; omit to return both. Valores: true, false.
typestringnãomatriz (head office) or filial (branch). Accepts [in]=matriz,filial. Valores: matriz, filial.
cnpjstringnãoFilter by CNPJ (14-digit numeric string, no formatting). Accepts [in]=cnpj1,cnpj2.
namestringnãoFilter by exact name. Accepts [in].
sort_bystringnãoField to order by. Default: sort_by=name&sort_order=asc. Valores: created_at, name.
sort_orderstringnãoOrder direction. Defaults to asc; ignored without sort_by. Valores: asc, desc.
limitintegernãoPage size. Default 25, max 100.
cursorstringnãoOpaque cursor for the next page. Round-trip meta.next_cursor from the previous response.
fieldsstringnãoComma-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.

Cabeçalhos

NomeTipoObrigatórioDescrição
X-Workspace-IdstringsimWorkspace 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).

Respostas

HTTPDescrição
200Page of companies plus pagination metadata.
400Malformed query (unknown filter / operator, invalid limit, bad cursor).

companies create​

Criar empresa

kobana finance companies create [OPÇÕES]

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.

Cabeçalhos

NomeTipoObrigatórioDescrição
X-Workspace-IdstringsimWorkspace 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).

Corpo da requisição

NomeTipoObrigatórioDescrição
namestringsimLegal name as registered.
cnpjstringsimCNPJ — 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_namestringnão
municipal_registrationstringnão
tax_regimestringnãoValores: SimplesNacional, SimplesNacionalExcessoSublimite, MicroempreendedorIndividual, LucroPresumido, LucroReal, Isento.
addressobjectnão
custom_metadataobjectnãoMetadados do usuário: objeto JSON livre. Envie null para limpar. Máx. 64 KB serializado, 16 níveis.

Outros campos e objetos aninhados: kobana schema finance.companies.create.

Respostas

HTTPDescrição
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​

Obter empresa por ID

kobana finance companies get [ID] [OPÇÕES]

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 do caminho: id

Parâmetros de consulta

NomeTipoObrigatórioDescrição
fieldsstringnãoComma-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.

Cabeçalhos

NomeTipoObrigatórioDescrição
X-Workspace-IdstringsimWorkspace 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).

Respostas

HTTPDescrição
200Get a company by id
404Company not found within the tenant.

companies update​

Atualizar empresa

kobana finance companies update [ID] [OPÇÕES]

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 do caminho: id

Cabeçalhos

NomeTipoObrigatórioDescrição
X-Workspace-IdstringsimWorkspace 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).

Corpo da requisição

NomeTipoObrigatórioDescrição
namestringnão
activebooleannãoSet false to soft-deactivate the company (existing references are preserved).
trade_namestringnão
municipal_registrationstringnão
tax_regimestringnãoValores: SimplesNacional, SimplesNacionalExcessoSublimite, MicroempreendedorIndividual, LucroPresumido, LucroReal, Isento.
addressobjectnãoReplaces 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_metadataobjectnãoMetadados do usuário: objeto JSON livre. Envie null para limpar. Máx. 64 KB serializado, 16 níveis.
custom_metadata_modestringnãoComo 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.

Outros campos e objetos aninhados: kobana schema finance.companies.update.

Respostas

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

companies delete​

Excluir empresa

kobana finance companies delete [ID] [OPÇÕES]

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 do caminho: id

Cabeçalhos

NomeTipoObrigatórioDescrição
X-Workspace-IdstringsimWorkspace 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).

Respostas

HTTPDescrição
200Company deleted.
404Company not found within the tenant.
409The company has financial records or active people (details carries the counts).