> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerfi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Customer credit object

A Customer Credit represents a transaction that reduces accounts payable to a customer, typically due to returned goods.
Each customer credit has one or more line items specifying debited revenue accounts, and zero or more allocations applying portions of the credit to invoices.

### Attributes

<ParamField body="id" type="string" required="true">
  Unique identifier for the customer credit.
</ParamField>

<ParamField body="external_id" type="string">
  Unique ID of the customer credit in your system for linking purposes. **Idempotency key**.
</ParamField>

<ParamField body="customer" type="Customer object" required="true">
  The [Customer](/api-reference/customer/customer) associated with this credit.
</ParamField>

<ParamField body="sent_at" type="ISO8601 timestamp" required="true">
  Time when the customer credit was sent.
</ParamField>

<ParamField body="line_items" type="array of CustomerCreditLineItem objects" required="true">
  Line items included in this customer credit. See [Customer Credit Line Item Object](#customer-credit-line-item-object) for details.
</ParamField>

<ParamField body="allocations" type="array of CustomerCreditAllocation objects">
  Allocations of this customer credit to invoices. See [Customer Credit Allocation Object](#customer-credit-allocation-object) for details.
</ParamField>

<ParamField body="created_at" type="ISO8601 timestamp" required="true">
  Time when the customer credit was created in Layer.
</ParamField>

<ParamField body="updated_at" type="ISO8601 timestamp" required="true">
  Time when the customer credit was last updated in Layer.
</ParamField>

<ParamField body="deleted_at" type="ISO8601 timestamp">
  Time when the customer credit was deleted, if applicable.
</ParamField>

<ParamField body="transaction_tags" type="Array of Tags">
  Tags associated with the customer credit.

  <Expandable title="Tag properties">
    <ResponseField name="key" required="true" type="string">
      The tag's key
    </ResponseField>

    <ResponseField name="value" required="true" type="string">
      The tag's value
    </ResponseField>

    <ResponseField name="created_at" required="true" type="ISO8601 timestamp">
      When the tag was created
    </ResponseField>

    <ResponseField name="updated_at" required="true" type="ISO8601 timestamp">
      When the tag was last updated
    </ResponseField>

    <ResponseField name="deleted_at" type="ISO8601 timestamp">
      When the tag was deleted
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField body="memo" type="string">
  Memo for any text you would like to associate with the customer credit (for example, to display to end users).
</ParamField>

<ParamField body="metadata" type="object">
  Arbitrary custom metadata in JSON format with a size limit of 1KB.
</ParamField>

<ParamField body="reference_number" type="string">
  Any (typically user-visible) identifier you would like to associate with the customer credit. Can be used to filter when listing customer credits.
</ParamField>

### Customer Credit Line Item Object

A Customer Credit Line Item represents an individual revenue account being credited by the Customer Credit.

<ParamField body="id" type="string" required="true">
  Unique identifier for the customer credit line item.
</ParamField>

<ParamField body="ledger_account" type="SingleApiChartAccount object">
  [Ledger account](/api-reference/ledger/chart#ledger-account-object) associated with this line item. This is what you're specifying with the 'revenue\_account\_identifier' in the create parameters.
</ParamField>

<ParamField body="amount" type="integer" required="true">
  Amount for the line item in cents.
</ParamField>

<ParamField body="memo" type="string">
  Description or notes for the line item.
</ParamField>

<ParamField body="metadata" type="json object">
  Arbitrary metadata you can include with the customer credit line item
</ParamField>

### Customer Credit Allocation Object

A Customer Credit Allocation represents how a portion of a customer credit is applied to a specific invoice. By allocating customer credits to invoices, the amount owed to customers can be reduced accordingly.

<ParamField body="id" type="string" required="true">
  Unique identifier for the customer credit allocation.
</ParamField>

<ParamField body="customer_credit_id" type="string" required="true">
  ID of the customer credit this allocation belongs to.
</ParamField>

<ParamField body="invoice_id" type="string" required="true">
  ID of the invoice this allocation is for.
</ParamField>

<ParamField body="amount" type="integer" required="true">
  Amount of the allocation in cents.
</ParamField>

<ResponseExample>
  ```json Response theme={null}
  {
    "data": {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "external_id": "vc001",
      "customer": {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "external_id": "abc123",
        "individual_name": null,
        "company_name": "Widgets & Co",
        "email": null,
        "mobile_phone": null,
        "office_phone": null,
        "address_string": null,
        "notes": null,
        "status": "ACTIVE",
        "transaction_tags": [
          {
            "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
            "key": "department",
            "value": "sales",
            "dimension_display_name": "Department",
            "value_display_name": "Sales Team",
            "dimension_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
            "definition_id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
            "created_at": "2024-02-27T02:16:40.389772Z",
            "updated_at": "2024-02-27T02:16:40.389772Z",
            "deleted_at": null,
            "archived_at": null
          }
        ]
      },
      "sent_at": "2023-11-07T05:31:56Z",
      "line_items": [
        {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "ledger_account": {
            "id": {
              "type": "AccountId",
              "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
            },
            "name": "Sales",
            "stable_name": {
              "type": "StableName",
              "stable_name": "SALES"
            },
            "normality": "CREDIT",
            "account_type": {
              "value": "REVENUE",
              "display_name": "Revenue"
            },
            "account_subtype": {
              "value": "SALES",
              "display_name": "Sales"
            }
          },
          "amount": 123,
          "memo": null
        }
      ],
      "allocations": [
        {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "customer_credit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "amount": 123
        }
      ],
      "created_at": "2023-11-07T05:31:56Z",
      "updated_at": "2023-11-07T05:31:56Z",
      "deleted_at": null,
      "transaction_tags": [
        {
          "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "key": "department",
          "value": "sales",
          "dimension_display_name": "Department",
          "value_display_name": "Sales Team",
          "dimension_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
          "definition_id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
          "created_at": "2024-02-27T02:16:40.389772Z",
          "updated_at": "2024-02-27T02:16:40.389772Z",
          "deleted_at": null,
          "archived_at": null
        }
      ],
      "metadata": null
    }
  }
  ```
</ResponseExample>
