# Retry an e-invoice

> The einvoices.retry operation: POST /api/v1/einvoices/{id}/retry in the REST API and the einvoices_retry tool in the MCP server.

Sends a `failed` or `rejected` e-invoice again, once its cause is fixed: for example after setting the customer's
`einvoice_endpoint` metadata (its electronic address). The e-invoice goes back to `pending` with the customer's
and the entity's current e-invoicing details, one attempt more, and is generated and handed to its provider after
the call returns (`einvoice.sent`, or `einvoice.failed` again). The document itself never changes: correct a wrong
invoice with a credit note.

## At a glance

- **REST:** `POST /api/v1/einvoices/{id}/retry`
- **MCP tool:** `einvoices_retry`
- **Operation ID:** `einvoices.retry`
- **Scope:** Brand
- **Permission:** `invoices:write`
- **Risk tier:** `write`
- **Dry run:** Supported (send `Ownrecord-Dry-Run: true`)
- **Idempotency:** `Idempotency-Key` required
- **Modes:** Test and live
- **Authentication:** API key with the `invoices:write` scope
- **Since:** M13

## Request

### Path parameters

| Field | Type        | Description |
| ----- | ----------- | ----------- |
| `id`  | `einv_…` ID |             |

### Body

This operation takes no body.

## Response

`200 OK` with a JSON object:

| Field              | Type                                                                      | Description                                                                                                                                                         |
| ------------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`               | `einv_…` ID                                                               |                                                                                                                                                                     |
| `object`           | `"einvoice"`                                                              |                                                                                                                                                                     |
| `livemode`         | boolean                                                                   |                                                                                                                                                                     |
| `orgId`            | `org_…` ID                                                                |                                                                                                                                                                     |
| `entityId`         | `ent_…` ID                                                                |                                                                                                                                                                     |
| `brandId`          | `brd_…` ID                                                                |                                                                                                                                                                     |
| `documentKind`     | one of `invoice`, `credit_note`                                           |                                                                                                                                                                     |
| `documentId`       | string                                                                    | The invoice (`inv_…`) or credit note (`cn_…`) it was generated from.                                                                                                |
| `documentNumber`   | string                                                                    |                                                                                                                                                                     |
| `customerId`       | string or null                                                            |                                                                                                                                                                     |
| `country`          | string                                                                    |                                                                                                                                                                     |
| `transactionType`  | one of `b2b`, `b2g`, `b2c`                                                |                                                                                                                                                                     |
| `provider`         | string                                                                    |                                                                                                                                                                     |
| `format`           | one of `UBL_2_1_PEPPOL_BIS_3`, `CII`, `national`                          |                                                                                                                                                                     |
| `status`           | one of `pending`, `queued`, `delivered`, `accepted`, `rejected`, `failed` | `pending` (queued for sending), `queued` (the provider took it), `delivered`, `accepted`, `rejected` (by the receiver) or `failed` (couldn't be generated or sent). |
| `externalId`       | string or null                                                            | The provider's ID of the transmission.                                                                                                                              |
| `buyerEndpoint`    | string or null                                                            |                                                                                                                                                                     |
| `sellerEndpoint`   | string or null                                                            |                                                                                                                                                                     |
| `buyerReference`   | string or null                                                            |                                                                                                                                                                     |
| `file`             | object or null                                                            | The generated document as stored (UBL XML) and the generator version that wrote it.                                                                                 |
| `error`            | object or null                                                            |                                                                                                                                                                     |
| `attempts`         | integer                                                                   |                                                                                                                                                                     |
| `sentAt`           | date-time or null                                                         |                                                                                                                                                                     |
| `lastCheckedAt`    | date-time or null                                                         |                                                                                                                                                                     |
| `history`          | array of object                                                           |                                                                                                                                                                     |
| `history[].status` | one of `pending`, `queued`, `delivered`, `accepted`, `rejected`, `failed` |                                                                                                                                                                     |
| `history[].at`     | date-time                                                                 |                                                                                                                                                                     |
| `history[].reason` | string or null                                                            |                                                                                                                                                                     |
| `createdAt`        | date-time                                                                 |                                                                                                                                                                     |
| `updatedAt`        | date-time                                                                 |                                                                                                                                                                     |

## Examples

### Send a failed e-invoice again

```http
POST /api/v1/einvoices/einv_01jbxa6qk3f0v8w9zq2y7k5n70/retry
Authorization: Bearer or_test_…
Idempotency-Key: 3f1c9a52-7d0e-4b8f-9a61-0c2d5e8b7f14
```

Response (`200`):

```json
{
  "id": "einv_01jbxa6qk3f0v8w9zq2y7k5n70",
  "object": "einvoice",
  "livemode": false,
  "orgId": "org_01jacq4m3xf0v8w9zq2y7k5n6a",
  "entityId": "ent_01jacq4m3xf0v8w9zq2y7k5n6h",
  "brandId": "brd_01jacq4m3xf0v8w9zq2y7k5n6j",
  "documentKind": "invoice",
  "documentId": "inv_01jacq4m3xf0v8w9zq2y7k5n70",
  "documentNumber": "ACME-2026-000101",
  "customerId": "cus_01jacq4m3xf0v8w9zq2y7k5n6k",
  "country": "HR",
  "transactionType": "b2b",
  "provider": "fake",
  "format": "UBL_2_1_PEPPOL_BIS_3",
  "status": "pending",
  "externalId": null,
  "buyerEndpoint": "0208:0123456789",
  "sellerEndpoint": null,
  "buyerReference": null,
  "file": null,
  "error": null,
  "attempts": 2,
  "sentAt": null,
  "lastCheckedAt": null,
  "history": [
    {
      "status": "pending",
      "at": "2026-10-14T09:30:05.000Z",
      "reason": null
    },
    {
      "status": "failed",
      "at": "2026-10-14T09:31:02.000Z",
      "reason": "The buyer has no electronic address: set the customer's `einvoice_endpoint` metadata (<scheme>:<identifier>)."
    },
    {
      "status": "pending",
      "at": "2026-10-15T08:00:00.000Z",
      "reason": null
    }
  ],
  "createdAt": "2026-10-14T09:30:05.000Z",
  "updatedAt": "2026-10-15T08:00:00.000Z"
}
```

## Errors

| Code                                                                                                           | HTTP status | When                                                                                     | What to do                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`einvoice_not_retryable`](https://ownrecord.io/docs/reference/errors.md#einvoice_not_retryable)               | 409         | The e-invoice is pending, on its way or done.                                            | Only a `failed` or `rejected` e-invoice can be sent again. One that is pending, queued, delivered or accepted is on its way or done.                                                |
| [`einvoice_provider_unavailable`](https://ownrecord.io/docs/reference/errors.md#einvoice_provider_unavailable) | 400         | Its provider can't be used here any more; change the entity's route and contact support. | Choose a provider that is available in this environment. The fake provider exists only in development and test; certified providers are added with the product owner (spec §35 #8). |
| [`einvoice_endpoint_invalid`](https://ownrecord.io/docs/reference/errors.md#einvoice_endpoint_invalid)         | 400         | The customer's `einvoice_endpoint` metadata is malformed.                                | Write it as \<scheme>:\<identifier> with a scheme from the Peppol list of electronic address schemes, e.g. 9934:HR12345678903 or 0208:0123456789.                                   |
| [`resource_not_found`](https://ownrecord.io/docs/reference/errors.md#resource_not_found)                       | 404         | No such e-invoice for this brand in this mode.                                           | Check the ID and that your credentials are scoped to the right organization, entity, brand and mode.                                                                                |
| [`version_conflict`](https://ownrecord.io/docs/reference/errors.md#version_conflict)                           | 409         | The e-invoice changed at the same moment; try again.                                     | Fetch the object again and retry the change.                                                                                                                                        |
| [`permission_denied`](https://ownrecord.io/docs/reference/errors.md#permission_denied)                         | 403         | You can't change this brand's invoices.                                                  | Ask an organization owner or admin for a role or scope that allows this action.                                                                                                     |

It can also return these [common errors](https://ownrecord.io/docs/reference.md#common-errors): [`validation_failed`](https://ownrecord.io/docs/reference/errors.md#validation_failed), [`api_version_unsupported`](https://ownrecord.io/docs/reference/errors.md#api_version_unsupported), [`invalid_json`](https://ownrecord.io/docs/reference/errors.md#invalid_json), [`unsupported_media_type`](https://ownrecord.io/docs/reference/errors.md#unsupported_media_type), [`authentication_required`](https://ownrecord.io/docs/reference/errors.md#authentication_required), [`api_key_invalid`](https://ownrecord.io/docs/reference/errors.md#api_key_invalid), [`scope_required`](https://ownrecord.io/docs/reference/errors.md#scope_required), [`idempotency_key_required`](https://ownrecord.io/docs/reference/errors.md#idempotency_key_required), [`idempotency_key_reused`](https://ownrecord.io/docs/reference/errors.md#idempotency_key_reused), [`idempotency_in_progress`](https://ownrecord.io/docs/reference/errors.md#idempotency_in_progress), [`approval_required`](https://ownrecord.io/docs/reference/errors.md#approval_required), [`approval_rejected`](https://ownrecord.io/docs/reference/errors.md#approval_rejected), [`approval_expired`](https://ownrecord.io/docs/reference/errors.md#approval_expired), [`stale_approval`](https://ownrecord.io/docs/reference/errors.md#stale_approval), [`approval_policy_denied`](https://ownrecord.io/docs/reference/errors.md#approval_policy_denied), [`rate_limited`](https://ownrecord.io/docs/reference/errors.md#rate_limited), [`internal_error`](https://ownrecord.io/docs/reference/errors.md#internal_error).
