---
title: "Generate the representation document"
method: POST
path: "/v1/companies/{company_id}/representation"
tags: ["CompanyRepresentation"]
---

# Generate the representation document

`POST /v1/companies/{company_id}/representation`

## Request

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

Generates the unsigned AEAT representation PDF of a company, the first step of the
representation flow.

- **Next steps:** download the PDF from
  `GET /v1/companies/{company_id}/representation/document`, sign it digitally and return
  it through `POST /v1/companies/{company_id}/representation/submit`.
- **Fiscal identity:** must be complete before the document can be produced. An incomplete
  one is rejected with `400` naming what is missing.
- **Existing representation:** a company that already holds an active one is rejected too.
  Cancel it first.

## Headers

- `Idempotency-Key` string

## Response `200`

Representation document generated

- RepresentationActionResponse
  - `success` boolean
  - `data` object
    - `status` string
    - `message` string
  - `meta` ResponseMeta
    - `timestamp` string, date-time
    - `request_id` string

## Other responses

- `400`: The document cannot be generated. Branch on `error.code`: * `REPRESENTATION_ALREADY_ACTIVE` — the company already holds an active representation. Cancel it with `DELETE /v1/companies/{company_id}/representation` first. * `ALREADY_REGISTERED` — the VeriFactu provider already holds a signed, active representation for this NIF that the company does not have in BeeL. Nothing is generated on top of it; contact support. * `REPRESENTATION_DOCUMENT_GENERATION_FAILED` — the provider could not produce the document. Nothing was stored; repeat the request later. An incomplete fiscal identity is also answered with `400`, naming what is missing.
- `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`: Your account does not own or manage this company, or does not hold write access over it. That case answers `error.code` `ACTIVE_COMPANY_NOT_ACCESSIBLE`.
- `422`: `VALIDATION_ERROR` — the body parses but a value is not acceptable. `details` is a flat map from the offending property's name (in the contract's `snake_case`, nested paths joined with a dot, e.g. `recipient.address.postal_code`) to a message describing what is wrong with it, one entry per property. When the rejected value is one outside an enum's vocabulary, `details` instead follows `FieldDeserializationError` (`field`, `invalid_value`, `allowed_values`). Two more codes share this status for a value that passes the contract but does not fit where it is stored: `VALUE_TOO_LONG` (a text longer than its column holds) and `VALUE_OUT_OF_RANGE` (a number outside what its column holds). Nothing was written.
- `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)
