# Einvoices

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


An e-invoice record associated with an invoice or credit note. It includes processing status, provider references, nested artifacts (for example application responses), and related status messages.

## Sample Einvoice

```json
{
  "id": "HmaT0avT2mtbTL3mR",
  "entity_type": "invoice",
  "entity_id": "__demo_inv__1",
  "status": "scheduled",
  "message": "E-invoice sending is scheduled and not yet processed.",
  "provider_references": [
    {
      "key": "Receipt Message ID",
      "value": "receipt-001"
    },
    {..}
  ],
  "deleted": false,
  "created_at": 1517462003,
  "object": "einvoice",
  "resource_version": 1517462003147,
  "artifacts": [
    {
      "id": "einvoice_artifact_HmaT0avT2mtbTL3mR",
      "artifact_type": "APPLICATION_RESPONSE",
      "direction": "inbound",
      "status": "success",
      "code": "AP",
      "external_artifact_id": "ext-art-001",
      "object": "einvoice_artifact",
      "created_at": 1517462005,
      "resource_version": 1517462005149,
      "deleted": false
    },
    {..}
  ]
}
```

## Einvoices attributes

## Input Parameters

- `id` (required, string, max chars=50)
  The unique `id` for the e-invoice. This is auto-generated by Chargebee.

- `entity_type` (required, enumerated string)
  The type of the parent document this e-invoice belongs to.
  Possible enum values:
    - `invoice`
      Invoice
    - `credit_note`
      Credit note

- `entity_id` (required, string, max chars=50)
  The unique id of the parent document this e-invoice belongs to. When `entity_type` is `invoice`, this is the invoice id; when `entity_type` is `credit_note`, this is the credit note id.

- `reference_id` (optional, string, max chars=50)
  Identifier returned by the connected e-invoicing provider for this submission (for example, a document submission id). Chargebee uses this value when communicating with the provider to retrieve submission status and related artifacts.

- `reference_number` (optional, string, max chars=100)
  This attribute is used to populate the unique reference number assigned to an invoice on the Invoice Registration Portal (IRP) network. It is essential for identifying and tracking invoices that are processed through the IRP network.
  
  In the future, this field may be used to store similar reference numbers for other networks.

- `status` (required, enumerated string)
  The status of processing the e-invoice. To obtain detailed information about the current `status`, see `message`.
  Possible enum values:
    - `scheduled`
      Sending the e-invoice to the customer has been scheduled.
    - `skipped`
      The e-invoice was not sent. This could be due to missing information or because the `entity_identifier` is not registered on the e-invoicing network.
    - `in_progress`
      The e-invoice has been sent and Chargebee is waiting for confirmation from the receiving entity.
    - `success`
      The e-invoice has been successfully delivered to the customer.
    - `failed`
      The e-invoice was sent and there was an error due to which it was not delivered.
    - `registered`
      The e-invoice was sent and there was an error due to which it was not delivered but got cleared in the IRP.
    - `accepted`
      The e-invoice was sent and it was accepted by the receiving entity. The sending entity shall also accept the e-invoice.
    - `rejected`
      The e-invoice was sent and it was rejected by the receiving entity due to some reason. The sending entity shall also reject the e-invoice.
    - `message_acknowledgement`
      An acknowledgment confirming that the application response was successfully received by the receiving entity.
    - `in_process`
      The e-invoice is currently being processed by the receiving entity.
    - `under_query`
      The receiving entity has raised a query regarding the e-invoice. Additional information or clarification is required before proceeding.
    - `conditionally_accepted`
      The e-invoice has been accepted with conditions.
    - `paid`
      The receiving entity has confirmed that the e-invoice has been paid.

- `message` (optional, string, max chars=3000)
  Detailed information about the status of the e-invoice. When `status` is `skipped` or `failed`, this contains the reason or error details. The following are some valid examples:
  
  -   Invoice successfully sent to customer via the e-invoicing network 9090:123456
  -   Invoice successfully sent to customer via email id abc@acme.com

- `created_at` (required, timestamp(UTC) in seconds)
  Timestamp indicating when this e-invoice resource was created.

- `resource_version` (optional, long)
  Version number of this resource. The `resource_version` is updated with a new timestamp in milliseconds for every change made to the resource. This attribute will be present only if the resource has been updated after 2016-09-28.

- `updated_at` (optional, timestamp(UTC) in seconds)
  Timestamp indicating when this e-invoice was last updated. This attribute will be present only if the resource has been updated after 2016-09-28.

- `deleted` (required, boolean)
  Indicates that this resource has been deleted.

- `provider_references` (optional)
  List of key-value pairs from the e-invoicing provider (for example, a Receipt Message ID).

- `business_entity_id` (optional, string, max chars=50)
  The unique ID of the [business entity](/docs/api/advanced-features) of this e-invoice. Same as the business entity of the parent invoice or credit note.

- `artifacts` (optional, list of einvoice_artifact)
  List of e-invoice artifacts related to this e-invoice (for example application responses).
  - `artifact_type` (required, string, max chars=50)
    Type of artifact that is sent as e-invoice from Chargebee or received as a result of processing the primary e-invoice. Example: `APPLICATION_RESPONSE`.
  - `direction` (required, enumerated string)
    Indicates whether the artifact was sent or received.
    Possible enum values:
      - `outbound`
        The artifact was generated by Chargebee and sent to an external e-invoicing provider/platform.
      - `inbound`
        The artifact was received by Chargebee from an external e-invoicing provider/platform.
  - `status` (required, enumerated string)
    Processing or business status of the artifact.
    Possible enum values:
      - `scheduled`
        Sending the artifact has been scheduled.
      - `skipped`
        The artifact was not sent. This could be due to missing information.
      - `in_progress`
        The artifact has been sent and Chargebee is waiting for confirmation from the receiving entity.
      - `success`
        The artifact has been successfully delivered.
      - `failed`
        The artifact was sent and there was an error due to which it was not delivered.
      - `registered`
        The artifact was sent and there was an error due to which it was not delivered but got cleared in the IRP.
  - `code` (optional, string, max chars=100)
    The code associated with the artifact corresponds to its relation to the primary e-invoice. For example, in an Application Response artifact, the code indicates whether the primary e-invoice is accepted or rejected.
  - `external_artifact_id` (optional, string, max chars=100)
    The id of the artifact received from the external e-invoicing provider/platform when sent as e-invoice.
  - `created_at` (required, timestamp(UTC) in seconds)
    Timestamp indicating when this artifact was created.
  - `resource_version` (optional, long)
    Version number of this resource. The `resource_version` is updated with a new timestamp in milliseconds for every change made to the resource. This attribute will be present only if the resource has been updated after 2016-09-28.
  - `updated_at` (optional, timestamp(UTC) in seconds)
    Timestamp indicating when this artifact was last updated. This attribute will be present only if the resource has been updated after 2016-09-28.
  - `deleted` (required, boolean)
    Indicates that this resource has been deleted.

