---
title: "Delete a company"
method: DELETE
path: "/v1/companies/{company_id}"
tags: ["Company"]
---

# Delete a company

`DELETE /v1/companies/{company_id}`

## Request

- Base URL: `https://app.beel.es/api`
- URL: `https://app.beel.es/api/v1/companies/{company_id}`
- Auth: HTTP bearer

Removes a company from the account: it stops appearing and stops being billed.

- **Existing invoices:** those already issued are retained, but the company-scoped API
  can no longer resolve them once the NIF is removed.
- **What blocks removal:** a NIF activated in Live
  (`409 COMPANY_ACTIVE_IN_PRODUCTION`), one holding any invoice in Live — issued, draft
  or proforma (`409 COMPANY_HAS_INVOICES`) — and the account's primary NIF
  (`400 CANNOT_DELETE_PRIMARY`).
- **Deactivating first:** switching off in Live is scheduled to the end of the paid
  cycle, so the removal only becomes possible once that takes effect.
- **Test:** NIFs never activated, or activated only in Test, are removed right away, and
  invoices in Test never block.
- **`Idempotency-Key`:** without one, a retry after a timeout answers `403` instead of
  the original `204`.

## Response `204`

Company deleted

## Other responses

- `400`: The NIF is the primary company of the account (`CANNOT_DELETE_PRIMARY`).
- `401`: Missing or invalid authentication. Like every other error, `message`/`detail` is localized according to `Accept-Language` (`es`, `en`, `ca`); defaults to English when the header is missing or asks for none of those.
- `403`: `ACTIVE_COMPANY_NOT_ACCESSIBLE` — your account does not own or manage this company with write access. A company that belongs to someone else, one already deleted and one that never existed all answer the same way.
- `409`: The company cannot be deleted: - `COMPANY_ACTIVE_IN_PRODUCTION` — it is active in Live. Deactivate it in Live and delete it from the effective date of that deactivation. - `COMPANY_HAS_INVOICES` — it has invoices in Live (issued, draft or proforma). Delete its drafts and proformas first; once it has issued, deactivate it instead. Invoices in Test never block the deletion.
- `429`: Rate limit exceeded. `RATE_LIMIT_EXCEEDED` when the request rate of your credential is over its limit; `TOO_MANY_REQUESTS` when an email the operation sends is held back because too many went out to that recipient in a short time. Either way, retry after the `Retry-After` seconds. `QUOTA_EXCEEDED` is the other `429`: the operation would go over a quota of your plan for the current period (issued invoices, for instance). Retrying does not help until the quota resets or the plan changes. `error.details` carries `feature_code`, `current_usage`, `quota_limit` and `reset_date`, and `RateLimit-Reset` the seconds until the reset when it is known.
- `500`: Internal server error
- `default`: Any status code the operation does not list above. Every operation declares it, so a generated client always has a branch to fall into and never loses the cause of a failure it did not anticipate. This is where the transport-level answers land — `405`, `406`, `415` and `429` — together with any status a future version of the API starts returning. All of them carry the same error envelope as the codes listed explicitly, so `error.code` is what tells them apart: switching on the status code alone is not enough. See «Transport-level errors» in the API description for when each one is produced. A `402` carrying `SUBSCRIPTION_REQUIRED` lands here when the account has no active subscription. `error.details` says why and what to do: `current_status` (absent if it never had one), `required_permission` and `action`. A `503` carrying `SERVICE_UNAVAILABLE` lands here too, with a `Retry-After` header: a dependency of BeeL itself (the database, the email provider) was momentarily unavailable and nothing was done. Retry after those seconds. A `502` carrying `EXTERNAL_SERVICE_ERROR` also lands here: an outbound integration the operation depends on failed or did not answer in time. It is a transient condition — retry with the same `Idempotency-Key` where the operation accepts one. One exception to the envelope: a failure of the network edge that never reaches the application (`502`, `503`, `504`, `524`) is generated by Cloudflare and its body is not BeeL's — it may not even be JSON. Treat those as "no answer", and retry.

---

[API](https://skmtc.dev/beel/apis/beel-public-api.md) · [All operations](https://skmtc.dev/beel/apis/beel-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/beel/apis/beel-public-api/revisions/ffbc0ae31f79?raw)
