# Get draft invoice history by invoice ID

> 🔐 **Required role:** `API_ADMIN`
📖 **Data dictionary:** [Draft invoice history](/reference/data-dictionary/draft-invoice-history)

**Retrieve the draft invoice history record of a posted invoice**
The `id` path parameter is an **invoice id** (the `invoiceId` of a draft
invoice history record, equal to the invoice's AR transaction id), not a
draft invoice id or a history record id. The endpoint returns the first
draft invoice history record whose `invoiceId` equals `id`.
The body is wrapped in a `draft_invoice_history` array containing at most one
record. An id that matches no record returns 200 with an empty array; the
endpoint never returns 404 for an unknown id.
**Response Example:**

```json
{
  "draft_invoice_history": [
    {
      "clientId": 7720,
      "invoiceId": 125890,
      "jobId": 2514,
      "client": {
        "active": true,
        "clientRef": "TF-2024-789",
        "name": "TechFlow Enterprises",
        "pmsRef": "240815"
      },
      "draftInvoice": {
        "approvedAt": "2024-03-15T14:32:18+00:00",
        "arTranId": 125880,
        "approverStaffId": 301,
        "approvedByStaffId": 301,
        "invoiceId": 125890,
        "isActive": true,
        "pms_invoice_number": null,
        "status": "APPROVED"
      }
    }
  ]
}
```

Endpoint: GET /gql/v1/draft_invoice_history/{id}
Version: 1.0.0
Security: BearerAuth, CfAccessClientId, CfAccessClientSecret

## Security:

  - `BearerAuth` (unknown)
    http bearer JWT

  - `CfAccessClientId` (unknown)
    apiKey in header CF-Access-Client-Id

  - `CfAccessClientSecret` (unknown)
    apiKey in header CF-Access-Client-Secret

## Path parameters:

  - `id` (integer, required)
    Invoice id (`invoiceId`) whose draft invoice history record is returned

## Response 200:

  - `200` (unknown)
    Draft invoice history lookup completed. `draft_invoice_history` holds the
matching record, or is empty when no record has this `invoiceId`.

## Response 200 fields (application/json):

  - `draft_invoice_history` (array, required)
    At most one draft invoice history record (empty if the invoice id has none)

  - `draft_invoice_history.clientId` (integer, required)
    Client identifier
    Example: 7720

  - `draft_invoice_history.invoiceId` (integer | null, required)
    Identifier of the posted invoice. Null until the draft has produced an invoice.
    Example: 125890

  - `draft_invoice_history.jobId` (integer, required)
    Associated job/project identifier
    Example: 2514

  - `draft_invoice_history.client` (object, required)
    Client summary information

  - `draft_invoice_history.client.active` (boolean, required)
    Example: true

  - `draft_invoice_history.client.clientRef` (string, required)
    Example: TF-2024-789

  - `draft_invoice_history.client.name` (string, required)
    Example: TechFlow Enterprises

  - `draft_invoice_history.client.pmsRef` (string, required)
    Example: 240815

  - `draft_invoice_history.draftInvoice` (object | null, required)
    Draft invoice metadata. Null when the history record has no draft invoice
or the draft's AR transaction is inactive.

  - `draft_invoice_history.draftInvoice.approvedAt` (string | null, required)
    Approval timestamp. Null until the draft is approved.
    Example: 2024-03-15T14:32:18+00:00

  - `draft_invoice_history.draftInvoice.arTranId` (integer, required)
    AR transaction identifier of the draft invoice
    Example: 125880

  - `draft_invoice_history.draftInvoice.approverStaffId` (integer, required)
    Example: 301

  - `draft_invoice_history.draftInvoice.approvedByStaffId` (integer | null, required)
    Staff who approved the draft. Null until the draft is approved.
    Example: 301

  - `draft_invoice_history.draftInvoice.invoiceId` (integer | null, required)
    Identifier of the posted invoice. Null until the draft is posted.
    Example: 125890

  - `draft_invoice_history.draftInvoice.isActive` (boolean, required)
    Example: true

  - `draft_invoice_history.draftInvoice.pms_invoice_number` (string | null, required)
    Invoice number in the practice management system. Null unless the draft was pushed to a PMS.
    Example: null

  - `draft_invoice_history.draftInvoice.status` (string, required)
    Example: APPROVED

  - `draft_invoice_history.draftInvoice.attachTimeEntries` (boolean | null, required)
    Whether time entries are attached to the invoice
    Example: false

  - `draft_invoice_history.draftInvoice.automaticallyBillOn` (string | null, required)
    When the draft is scheduled to bill automatically. Null when it is not scheduled.
    Example: null

  - `draft_invoice_history.draftInvoice.billAddressContactInfoId` (integer | null, required)
    Identifier of the contact info used as the bill-to address
    Example: 4410

  - `draft_invoice_history.draftInvoice.billerStaffId` (integer, required)
    Identifier of the biller staff member
    Example: 301

  - `draft_invoice_history.draftInvoice.createdAt` (string, required)
    When the draft was created
    Example: 2024-05-12T22:50:20.595961+00:00

  - `draft_invoice_history.draftInvoice.createdByStaffId` (integer | null, required)
    Identifier of the staff member who created the draft
    Example: 301

  - `draft_invoice_history.draftInvoice.currentAssignedStaffId` (integer, required)
    Identifier of the staff member the draft is currently assigned to
    Example: 301

  - `draft_invoice_history.draftInvoice.deliveryMethod` (string | null, required)
    How the invoice will be delivered: EMAIL, DOWNLOAD, EMAIL_AND_DOWNLOAD or POST_ONLY
    Example: EMAIL

  - `draft_invoice_history.draftInvoice.emailRecipients` (string | null, required)
    Email recipients for the invoice
    Example: ap@techflow.example

  - `draft_invoice_history.draftInvoice.expenseLineItemStrategy` (string | null, required)
    How expenses are presented as line items: SINGLE_LINE, HIDE or ALL
    Example: HIDE

  - `draft_invoice_history.draftInvoice.invoiceDate` (string | null, required)
    Invoice date to use when the draft is billed
    Example: null

  - `draft_invoice_history.draftInvoice.lineItemStrategy` (string | null, required)
    How time is presented as line items
    Example: JOB

  - `draft_invoice_history.draftInvoice.postOn` (string | null, required)
    Date the invoice is scheduled to post
    Example: null

  - `draft_invoice_history.draftInvoice.reversalReason` (string | null, required)
    Reason the draft was reversed
    Example: null

  - `draft_invoice_history.draftInvoice.reversedAt` (string | null, required)
    When the draft was reversed
    Example: null

  - `draft_invoice_history.draftInvoice.reversedByStaffId` (integer | null, required)
    Identifier of the staff member who reversed the draft
    Example: null

  - `draft_invoice_history.draftInvoice.reviewedAt` (string | null, required)
    When the draft was reviewed
    Example: 2024-03-14T10:05:00+00:00

  - `draft_invoice_history.draftInvoice.reviewedByStaffId` (integer | null, required)
    Identifier of the staff member who reviewed the draft
    Example: 301

  - `draft_invoice_history.draftInvoice.reviewerStaffId` (integer, required)
    Identifier of the reviewer staff member
    Example: 301

  - `draft_invoice_history.draftInvoice.scheduledByStaffId` (integer | null, required)
    Identifier of the staff member who scheduled the draft
    Example: null

  - `draft_invoice_history.draftInvoice.senderStaffId` (integer, required)
    Identifier of the sender staff member
    Example: 301

  - `draft_invoice_history.draftInvoice.timeEntryGrouping` (string | null, required)
    How attached time entries are grouped
    Example: null

  - `draft_invoice_history.draftInvoice.timeEntryPageOrientation` (string | null, required)
    Page orientation of attached time entries
    Example: null

  - `draft_invoice_history.draftInvoice.updatedAt` (string, required)
    When the draft was last updated
    Example: 2024-05-12T22:50:20.595961+00:00

  - `draft_invoice_history.draftInvoice.wipUnbilledAsOf` (string | null, required)
    Cut-off date for unbilled WIP included in the draft
    Example: null

## Response 400:

  - `400` (unknown)
    Bad request - the id is not an integer

## Response 400 fields (application/json):

  - `path` (string)
    Example: $

  - `error` (string, required)
    Example: invalid input syntax for type bigint: "abc"

  - `code` (string, required)
    Example: data-exception

## Response 401:

  - `401` (unknown)
    Unauthorized - Invalid or missing authentication token

## Response 403:

  - `403` (unknown)
    Forbidden - Insufficient permissions to access draft invoice histories

## Response 500:

  - `500` (unknown)
    Internal server error

## Response 200 examples:

  - `Record found` (unknown)

  - `No record for this invoice id` (unknown)

