# Invoices

### Invoices#index

Retrieves all firm invoices

```
GET /invoices
```

**Response**

Returns a 200 OK with an array of invoices:

```
[
    {
        "id": 1,
        "firm_id": 1,
        "user_id": 1,
        "contact_id": 1,
        "due_date": "2021-09-29",
        "close_date": null,
        "discount_percent_description": null,
        "discount_percent": 0,
        "discount_amount_description": null,
        "discount_amount": 0,
        "trust_request_amount": null,
        "trust_level": null,
        "last_reminder": null,
        "created_at": "2021-09-22T17:47:49.041Z",
        "updated_at": "2021-09-22T17:47:49.041Z",
        "issue_date": "2021-09-22",
        "invoice_number": "1",
        "footer": null,
        "has_discount_percent": false,
        "has_discount_amount": false,
        "color_scheme": "",
        "include_footer": false,
        "invoice_type": "bill",
        "status": "paid",
        "reminder_frequency": 7,
        "send_reminders": false,
        "public_code": "1234example",
        "discarded_at": null,
        "created_by_id": 1,
        "stored_total": "0.0",
        "stored_balance": "0.0",
        "payment_plan_id": null,
        "description": "Trust Request",
        "channel": "email",
        "viewed_by_contact": false,
        "include_logo": true,
        "quickbooks_uid": null
    }
]
    
```

### Invoices#show

Returns a single invoice

```
GET /invoices/:id
```

**Response**

Returns a 200 OK with a single invoice:

```
{
        "id": 1,
        "firm_id": 1,
        "user_id": 1,
        "contact_id": 1,
        "due_date": "2021-09-29",
        "close_date": null,
        "discount_percent_description": null,
        "discount_percent": 0,
        "discount_amount_description": null,
        "discount_amount": 0,
        "trust_request_amount": null,
        "trust_level": null,
        "last_reminder": null,
        "created_at": "2021-09-22T17:47:49.041Z",
        "updated_at": "2021-09-22T17:47:49.041Z",
        "issue_date": "2021-09-22",
        "invoice_number": "1",
        "footer": null,
        "has_discount_percent": false,
        "has_discount_amount": false,
        "color_scheme": "",
        "include_footer": false,
        "invoice_type": "bill",
        "status": "paid",
        "reminder_frequency": 7,
        "send_reminders": false,
        "public_code": "1234example",
        "discarded_at": null,
        "created_by_id": 1,
        "stored_total": "0.0",
        "stored_balance": "0.0",
        "payment_plan_id": null,
        "description": "Trust Request",
        "channel": "email",
        "viewed_by_contact": false,
        "include_logo": true,
        "quickbooks_uid": null,
        "invoice_matters": [
            {
                "id": 1,
                "invoice_id": 1,
                "matter_id": 1,
                "created_at": "2021-09-22T17:47:49.041Z",
                "updated_at": "2021-09-22T17:47:49.041Z",
                "discarded_at": null
            }
        ]
    }
```

### Invoices#create

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

```
POST /invoices
```

You should pass a JSON with the following parameters:

* `user_id integer`
* `contact_id integer`*`required`*
* `status 'unpaid' or 'paid'`
* `due_date date`
* `close_date date`
* `discount_percent_description string`
* `discount_percent integer`
* `discount_amount_description string`
* `discount_amount integer`
* `trust_request_amount decimal`
* `invoice_type 'bill', 'trust_request' or 'disbursement'`
* `trust_level 'client_level' or 'matter_level'`
* `last_reminder datetime`
* `issue_date date`
* `footer string`
* `has_discount_percent boolean`
* `has_discount_amount boolean`
* `include_footer boolean`
* `send_reminders boolean`
* `reminder_frequency integer, default(7)`
* `description string`
* `include_logo boolean`
* `invoice_matters_attributes array`
  * `matter_id integer`

```
{
    "invoice": {
        "user_id": 1,
				"contact_id": 1,
				"status": "unpaid",
				"due_date": "2021-09-29",
				"close_date": null,
				"discount_percent_description": null,
				"discount_percent": 0,
				"discount_amount_description": null,
				"discount_amount": 0,
				"trust_request_amount": null,
				"invoice_type": "bill",
				"trust_level": null,
				"last_reminder": null,
				"issue_date": "2021-10-06",
				"footer": null,
				"has_discount_percent": false,
				"has_discount_amount": false,
				"include_footer": false,
				"send_reminders": false,
				"reminder_frequency": 7,
				"description": null,
				"include_logo": true,
				"invoice_matters_attributes": [
					{
						"matter_id": 1
					}
				]
    }
}
```

**Response**

Returns a 201 created.&#x20;

### Invoices#update

Updates an existing invoice.&#x20;

```
PUT /invoices/:id
```

You should pass a JSON with the following parameters:

* `user_id integer`
* `contact_id integer`*required*
* `status 'unpaid' or 'paid'`
* `due_date date`
* `close_date date`
* `discount_percent_description string`
* `discount_percent integer`
* `discount_amount_description string`
* `discount_amount integer`
* `trust_request_amount decimal`
* `invoice_type 'bill', 'trust_request' or 'disbursement'`
* `trust_level 'client_level' or 'matter_level'`
* `last_reminder datetime`
* `issue_date date`
* `footer string`
* `has_discount_percent boolean`
* `has_discount_amount boolean`
* `include_footer boolean`
* `send_reminders boolean`
* `reminder_frequency integer, default(7)`
* `description string`
* `include_logo boolean`
* `invoice_matters_attributes array`
  * `matter_id integer`

```
{
    "invoice": {
        "user_id": 1,
				"contact_id": 1,
				"status": "paid",
				"due_date": "2021-09-29",
				"close_date": null,
				"discount_percent_description": null,
				"discount_percent": 0,
				"discount_amount_description": null,
				"discount_amount": 0,
				"trust_request_amount": null,
				"invoice_type": "bill",
				"trust_level": null,
				"last_reminder": null,
				"issue_date": "2021-10-06",
				"footer": null,
				"has_discount_percent": false,
				"has_discount_amount": false,
				"include_footer": false,
				"send_reminders": false,
				"reminder_frequency": 7,
				"description": null,
				"include_logo": true,
				"invoice_matters_attributes": [
					{
						"matter_id": 1
					}
				]
    }
}
```

**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/invoices.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.
