# Charges

### Charges#index

Retrieves all invoice charges

```
GET /invoices/:invoice_id/charges
```

**Response**

Returns a 200 OK with an array of invoice charges:

```
[
    {
        "id": 1,
        "matter_id": null,
        "invoice_id": 1,
        "contact_id": 1,
        "firm_id": 1,
        "user_id": 2,
        "description": null,
        "amount": "100.0",
        "status": "service",
        "created_at": "2022-03-03T17:27:09.950Z",
        "updated_at": "2022-03-03T17:27:10.164Z",
        "created_by_migration": null,
        "date": "2022-03-03"
    },
    {
        "id": 2,
        "matter_id": 1,
        "invoice_id": 1,
        "contact_id": 1,
        "firm_id": 1,
        "user_id": 2,
        "description": "New description",
        "amount": "100.0",
        "status": "service",
        "created_at": "2022-01-12T15:35:32.586Z",
        "updated_at": "2022-03-03T17:47:39.669Z",
        "created_by_migration": null,
        "date": "2022-01-12"
    }
]
```

### Charges#create

Creates a new invoice charge. Keep in mind to send charge data inside a charge root key.&#x20;

```
POST /invoices/:invoice_id/charges
```

You should pass a JSON with the following parameters:

* `amount decimal, greater than or equal to 0,`` `*`required`*
* `status 'service' or 'expense' or 'fee',`` `*`required`*
* `date date,`` `*`required`*
* `description string`
* `matter_id integer`

```
{
    "charge": {
        amount: 100,
        status: "service",
        date: "2021-09-22",
        description: "New description"
    }
}
```

**Response**

Returns a 201 created.&#x20;

### Charges#update

Updates an existing charge.&#x20;

```
PUT /charges/:id
```

You should pass a JSON with the following parameters:

* `amount decimal, greater than or equal to 0`
* `status 'service' or 'expense' or 'fee'`
* `date date`
* `description string`
* `matter_id integer`

```
{
    "charge": {
        amount: 200,
        status: "expense",
        date: "2022-01-01",
        description: "New description"
    }
}
```

**Response:**

Returns 200 OK

### Charges#destroy

Destroys an existing charge

```
DELETE /charges/:id
```

**Response:**

Returns 200 OK


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docketwise.gitbook.io/docketwise-api-docs/charges.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
