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

# Create Credit Note

Create a new credit note for a customer account.

<ParamField body="accountId" type="string" required>
  The account ID to create the credit note for.
</ParamField>

<ParamField body="invoiceId" type="string">
  Optional invoice ID to associate the credit note with.
</ParamField>

<ParamField body="billingPeriodStart" type="string">
  Optional billing period start date (ISO 8601).
</ParamField>

<ParamField body="billingPeriodEnd" type="string">
  Optional billing period end date (ISO 8601).
</ParamField>

<ParamField body="description" type="string">
  Description of the credit note.
</ParamField>

<ParamField body="lineItems" type="array">
  Array of line items for the credit note.
</ParamField>

<ParamField body="status" type="string">
  Initial status: `draft` or `issued`.
</ParamField>

<ParamField body="legalEntityId" type="string">
  Optional legal entity ID.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.alguna.io/credit-notes \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "accountId": "acc_abc123",
      "description": "Service credit for downtime",
      "lineItems": [
        {
          "description": "Service credit",
          "unitPrice": "100.00",
          "quantity": "1"
        }
      ],
      "status": "draft"
    }'
  ```

  ```javascript Node.js theme={null}
  const creditNote = await alguna.creditNotes.create({
    accountId: 'acc_abc123',
    description: 'Service credit for downtime',
    lineItems: [
      {
        description: 'Service credit',
        unitPrice: '100.00',
        quantity: '1'
      }
    ],
    status: 'draft'
  });
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "id": "cn_xyz789",
    "accountId": "acc_abc123",
    "invoiceId": null,
    "status": "draft",
    "applyDate": "2024-01-20T10:00:00Z",
    "creditDate": "2024-01-20T10:00:00Z",
    "currency": "USD",
    "description": "Service credit for downtime",
    "lineItems": [
      {
        "description": "Service credit",
        "unitPrice": "100.00",
        "quantity": "1",
        "total": "100.00"
      }
    ],
    "subtotal": "100.00",
    "tax": "0.00",
    "total": "100.00",
    "isPdfAvailable": false,
    "createdAt": "2024-01-20T10:00:00Z",
    "updatedAt": "2024-01-20T10:00:00Z"
  }
  ```
</ResponseExample>

<ResponseField name="id" type="string">
  Unique identifier for the credit note.
</ResponseField>

<ResponseField name="status" type="string">
  Status: `draft`, `issued`, `applied`, `refunded`, or `voided`.
</ResponseField>

<ResponseField name="subtotal" type="string">
  Subtotal before tax.
</ResponseField>

<ResponseField name="tax" type="string">
  Tax amount.
</ResponseField>

<ResponseField name="total" type="string">
  Total credit note amount.
</ResponseField>
