Skip to main content

get-datahub-invoice-import

dci get-datahub-invoice-import <id>

Returns the status and result of one PDF invoice import. While status is processing, call again after a few seconds. The other statuses are final:

  • imported: records were written; dataset, datasetCreated, recordCount and invoice are set. An import whose records were later replaced by a newer import of the same invoice is also reported as imported, without recordCount.
  • duplicate: the invoice was already imported and force was not set; existingImportId names the earlier import. Nothing was written.
  • needsReview: extraction worked but an automatic check blocked the import (see errorCode); invoice holds what was read. Nothing was written. A DataHub Admin can fix and import it from the Invoice imports list in the DoiT console; to retry through the API, upload a corrected PDF.
  • failed: nothing was written; errorCode and errorMessage say why.

errorCode values and what to do:

  • not_an_invoice: the PDF is not an invoice. Upload an invoice PDF.
  • no_line_items: no line items could be read. Upload a PDF that lists line items.
  • unreadable: the PDF could not be read. Upload a clearer or text-based PDF.
  • encrypted: the PDF is password-protected. Remove the password and upload again.
  • too_many_pages: the PDF has more than 20 pages. Split it or upload a shorter invoice.
  • content_blocked: the document was refused by content safety. Upload a different document.
  • lines_do_not_reconcile: the line amounts do not add up to the invoice total (needsReview). Open it in the console to correct the lines.
  • no_exchange_rate: no USD exchange rate exists for the invoice currency and date (needsReview). Open it in the console, or retry later.
  • low_confidence: the vendor, invoice date, currency or total was read with low confidence (needsReview). Open it in the console to confirm the values.
  • amount_far_above_total: a line amount is more than ten times the invoice total, which usually means a quantity was read as money (needsReview). Open it in the console, check the line against the PDF and import it; credit-heavy invoices whose lines add up can be imported as they are.
  • replace_not_yet_available: force was used within 90 minutes of the earlier import. Resend after the time in retryAfter.
  • invalid_dataset_name: the dataset does not exist, or the dataset name is not valid (needsReview). Upload again with an existing dataset or a valid newDatasetName.
  • import_in_progress: another import of the same invoice was running at that moment (needsReview). Upload again shortly.
  • unfinished_import: an earlier import of the same invoice was interrupted after some of its records were written, and must be finished first so the invoice is not counted twice (needsReview). errorMessage names that import; finish it from the Invoice imports list in the DoiT console, then upload again with force set to true if this file should replace it.
  • too_many_records: the invoice would create too many records (needsReview). Upload with costDating set to invoiceDate, or split the invoice.
  • invalid_invoice: the extracted invoice is not importable, for example a missing date or total (needsReview; failed when the PDF has more than 500 line items or an amount that is not a number). Open it in the console to correct it.
  • import_partially_written: a write was interrupted after some records were written. Do not upload the invoice again: open the import from the Invoice imports list in the DoiT console and confirm it to finish the invoice. Until then, other imports of this invoice are refused with unfinished_import.
  • cancelled: the import was cancelled in the console. Upload again if needed.
  • internal_error: a temporary failure. Upload again.
  • duplicate_invoice: see duplicate above.

Error responses have code and error; not_found (404) means no import with this id exists for the customer.

  • id — The import id returned when the invoice was uploaded or in the list of invoice imports.

Output​

OK - The import.

By default dci renders the result as a table. Use --output json to get the full structure described below — see Output formats.

FieldTypeDescription
idstring
statusstringprocessing is the only non-final status. See getDatahubInvoiceImport for what each final status means. One of: "processing", "needsReview", "imported", "duplicate", "failed".
errorCodestringWhy the import did not complete, or why it needs review. Present for duplicate and failed, and for needsReview when the reason is known. See getDatahubInvoiceImport for the values and what to do.
errorMessagestringHuman-readable detail for errorCode.
datasetstringThe dataset the records were written to. Present when status is imported.
datasetCreatedbooleantrue when the import created dataset. Present when status is imported.
recordCountintegerNumber of records written. Present when status is imported.
existingImportIdstringThe earlier import of the same invoice. Present when status is duplicate.
retryAfterstring (date-time)When a forced replace becomes allowed. Present with errorCode replace_not_yet_available.
invoiceobjectThe invoice as extracted from the PDF, or as confirmed when the import completed.
invoice.vendorstring
invoice.invoiceNumberstring
invoice.invoiceDatestring (date)
invoice.currencystringISO 4217 currency code of the invoice.
invoice.totalnumber
invoice.linesarray of object
invoice.lines[].descriptionstring
invoice.lines[].typestringOne of: "charge", "discount", "credit", "tax".
invoice.lines[].amountnumberAmount in the invoice currency. Discounts and credits are negative.
invoice.lines[].includedInOtherLinesbooleantrue for a tax or levy already included in the other lines' prices. Such a line is shown but not imported.
suggestedIntegrationstringKey of the DoiT integration whose provider issued this invoice, for example xai, when one exists. Connecting that integration imports this vendor's costs daily and in more detail than an invoice; if it is already connected, importing the invoice may count the same costs twice. Absent when no integration matches. The key is not filtered by the customer's entitlements, so the integration may not be available to this customer. It never affects the import.
createdAtstring (date-time)
createdBystringEmail of the user, or identifier of the service account, that uploaded the invoice.

Example response (--output json)​

{
"id": "8f2c1a7e4b9d",
"status": "imported",
"dataset": "Example Vendor",
"datasetCreated": true,
"recordCount": 31,
"invoice": {
"vendor": "Example Vendor",
"invoiceNumber": "INV-1042",
"invoiceDate": "2026-11-01",
"currency": "EUR",
"total": 120,
"lines": [
{
"description": "Platform plan",
"type": "charge",
"amount": 100,
"includedInOtherLines": false
},
{
"description": "VAT 20%",
"type": "tax",
"amount": 20,
"includedInOtherLines": false
}
]
},
"createdAt": "2026-11-22T10:00:00Z",
"createdBy": "[email protected]"
}
Raw JSON schema
{
"type": "object",
"required": [
"id",
"status",
"createdAt",
"createdBy"
],
"properties": {
"id": {
"type": "string",
"example": "8f2c1a7e4b9d"
},
"status": {
"type": "string",
"enum": [
"processing",
"needsReview",
"imported",
"duplicate",
"failed"
],
"description": "`processing` is the only non-final status. See `getDatahubInvoiceImport` for what each final status means."
},
"errorCode": {
"type": "string",
"description": "Why the import did not complete, or why it needs review. Present for `duplicate` and `failed`, and for `needsReview` when the reason is known. See `getDatahubInvoiceImport` for the values and what to do.",
"example": "lines_do_not_reconcile"
},
"errorMessage": {
"type": "string",
"description": "Human-readable detail for `errorCode`."
},
"dataset": {
"type": "string",
"description": "The dataset the records were written to. Present when `status` is `imported`.",
"example": "Example Vendor"
},
"datasetCreated": {
"type": "boolean",
"description": "`true` when the import created `dataset`. Present when `status` is `imported`."
},
"recordCount": {
"type": "integer",
"description": "Number of records written. Present when `status` is `imported`.",
"example": 31
},
"existingImportId": {
"type": "string",
"description": "The earlier import of the same invoice. Present when `status` is `duplicate`."
},
"retryAfter": {
"type": "string",
"format": "date-time",
"description": "When a forced replace becomes allowed. Present with `errorCode` `replace_not_yet_available`."
},
"invoice": {
"type": "object",
"description": "The invoice as extracted from the PDF, or as confirmed when the import completed.",
"properties": {
"vendor": {
"type": "string",
"example": "Example Vendor"
},
"invoiceNumber": {
"type": "string",
"example": "INV-1042"
},
"invoiceDate": {
"type": "string",
"format": "date",
"example": "2026-11-01"
},
"currency": {
"type": "string",
"description": "ISO 4217 currency code of the invoice.",
"example": "EUR"
},
"total": {
"type": "number",
"example": 120
},
"lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {
"type": "string",
"example": "Platform plan"
},
"type": {
"type": "string",
"enum": [
"charge",
"discount",
"credit",
"tax"
]
},
"amount": {
"type": "number",
"description": "Amount in the invoice currency. Discounts and credits are negative.",
"example": 100
},
"includedInOtherLines": {
"type": "boolean",
"description": "`true` for a tax or levy already included in the other lines' prices. Such a line is shown but not imported."
}
}
}
}
}
},
"suggestedIntegration": {
"type": "string",
"description": "Key of the DoiT integration whose provider issued this invoice, for example `xai`, when one exists. Connecting that integration imports this vendor's costs daily and in more detail than an invoice; if it is already connected, importing the invoice may count the same costs twice. Absent when no integration matches. The key is not filtered by the customer's entitlements, so the integration may not be available to this customer. It never affects the import.",
"example": "xai"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"createdBy": {
"type": "string",
"description": "Email of the user, or identifier of the service account, that uploaded the invoice.",
"example": "[email protected]"
}
}
}

Errors​

On failure, dci prints a single error message — with a hint when one is available — and exits with a typed code your scripts can branch on. See Errors and exit codes for the full contract.

HTTP status to exit code mapping
HTTP statusExit codeError codeMeaning
40110AUTHENTICATION_FAILEDNot signed in, or the API token is invalid. Run dci login or check DCI_API_KEY.
40311PERMISSION_DENIEDThe DoiT user or the active customer context does not have access.
40420RESOURCE_NOT_FOUNDThe requested resource does not exist. Check the identifier argument.
50040API_SERVER_ERRORThe API failed to process the request. Retryable; contact DoiT support if it persists.

Aliases: getdatahubinvoiceimport