Danh sách hóa đơn đầu vào
API này dùng để lấy danh sách hóa đơn đầu vào (hóa đơn mua vào) của doanh nghiệp đã được đồng bộ từ Tổng cục Thuế, hỗ trợ lọc theo người bán, ngày lập, ngày duyệt, ngày nhận và trạng thái.
POST
URLhttps://open-api.tingee.vn/v1/e-invoice/input/list
Lấy danh sách hóa đơn đầu vào có phân trang và bộ lọc.
Header Request
| Header | Bắt buộc | Mô tả |
|---|---|---|
Content-Type | ✓ | application/json |
x-client-id | ✓ | Mã định danh của đối tác do TINGEE cung cấp. |
x-signature | ✓ | Chữ ký xác thực HMAC SHA512. Xem thêm tại Cách sinh chữ ký. |
x-request-timestamp | ✓ | Thời gian gửi request (format: yyyyMMddHHmmssSSS, múi giờ UTC+7) |
Body Parameter
| Trường | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
merchantId | number | ~ | ID của Merchant (Bắt buộc nếu kết nối bằng tài khoản Master Merchant). |
accountId | number | ✕ | ID tài khoản hóa đơn điện tử (lấy từ Danh sách tài khoản). Bỏ trống để dùng tài khoản mặc định. |
page | number | ✕ | Trang cần lấy, bắt đầu từ 0. Mặc định 0. |
size | number | ✕ | Số bản ghi mỗi trang (tối thiểu 1). Mặc định 50. |
pageSize, current | number | ✕ | Tham số phân trang bổ sung, được chuyển nguyên sang nhà cung cấp. Khuyến nghị dùng page và size. |
sellerTaxCode | string | ✕ | Lọc theo mã số thuế người bán. |
buyerTaxCode | string | ✕ | Lọc theo mã số thuế người mua. Mặc định là mã số thuế của doanh nghiệp. |
invoiceNo | string | ✕ | Lọc theo số hóa đơn. |
invoiceFromDate, invoiceToDate | string | ✕ | Lọc theo ngày lập hóa đơn. |
approvedFromDate, approvedToDate | string | ✕ | Lọc theo ngày duyệt. |
receivedFromDate, receivedToDate | string | ✕ | Lọc theo ngày nhận. |
invoiceProperty | number | ✕ | Tính chất hóa đơn: 1 Gốc, 2 Thay thế, 3 Điều chỉnh, 4 Bị thay thế, 5 Bị điều chỉnh, 6 Bị xóa/hủy. |
approvalStatus | number | ✕ | Trạng thái phê duyệt: 1 Chờ duyệt, 2 Đã duyệt, 3 Không duyệt, 4 Đã hủy, 5 Đã xử lý. |
label | string | ✕ | Lọc theo nhãn. |
Ghi chú
Các trường ngày lọc dùng định dạng yyyy-MM-dd HH:mm:ss.SSS (ví dụ 2026-10-01 00:00:00.000). Có thể truyền yyyy-MM-dd hoặc ISO 8601 (ví dụ 2026-10-01), hệ thống tự chuyển về định dạng trên; không dùng dd/MM/yyyy như API Đồng bộ. Với mỗi cặp ngày, giá trị "từ ngày" phải nhỏ hơn hoặc bằng "đến ngày".
Ví dụ mã nguồn
- cURL
- NestJS
- C#
- Java
- PHP
curl --location --request POST 'https://open-api.tingee.vn/v1/e-invoice/input/list' \
--header 'accept: application/json' \
--header 'x-client-id: YOUR_CLIENT_ID' \
--header 'x-request-timestamp: 20240509154004003' \
--header 'x-signature: YOUR_SIGNATURE' \
--header 'Content-Type: application/json' \
--data '{
"page": 0,
"size": 50,
"invoiceFromDate": "2026-10-01 00:00:00.000",
"invoiceToDate": "2026-10-10 23:59:59.999"
}'
import axios from "axios";
import { createHmac } from "crypto";
const CLIENT_ID = "YOUR_CLIENT_ID";
const SECRET_KEY = "YOUR_SECRET_KEY";
// Timestamp theo múi giờ UTC+7, định dạng yyyyMMddHHmmssSSS
function getTimestamp() {
return new Date(Date.now() + 7 * 60 * 60 * 1000)
.toISOString()
.replace(/[-:TZ.]/g, "")
.slice(0, 17);
}
async function eInvoiceInputList() {
const body = {
page: 0,
size: 50,
invoiceFromDate: "2026-10-01 00:00:00.000",
invoiceToDate: "2026-10-10 23:59:59.999",
};
const bodyJson = JSON.stringify(body);
const timestamp = getTimestamp();
const signature = createHmac("sha512", SECRET_KEY)
.update(`${timestamp}:${bodyJson}`)
.digest("hex");
const res = await axios.request({
method: "POST",
url: "https://open-api.tingee.vn/v1/e-invoice/input/list",
data: bodyJson,
headers: {
accept: "application/json",
"Content-Type": "application/json",
"x-client-id": CLIENT_ID,
"x-request-timestamp": timestamp,
"x-signature": signature,
},
});
console.log(res.data);
}
eInvoiceInputList();
using System;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private const string ClientId = "YOUR_CLIENT_ID";
private const string SecretKey = "YOUR_SECRET_KEY";
private static readonly HttpClient Client = new HttpClient();
public static async Task Main()
{
var body = new
{
page = 0,
size = 50,
invoiceFromDate = "2026-10-01 00:00:00.000",
invoiceToDate = "2026-10-10 23:59:59.999"
};
// Không escape tiếng Việt / ký tự đặc biệt để khớp với JSON.stringify phía TINGEE
var jsonOptions = new JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
var bodyJson = JsonSerializer.Serialize(body, jsonOptions);
// Timestamp theo múi giờ UTC+7, định dạng yyyyMMddHHmmssSSS
var timestamp = DateTime.UtcNow.AddHours(7).ToString("yyyyMMddHHmmssfff");
var signature = HmacSha512(SecretKey, $"{timestamp}:{bodyJson}");
var request = new HttpRequestMessage(HttpMethod.Post, "https://open-api.tingee.vn/v1/e-invoice/input/list");
request.Headers.Add("accept", "application/json");
request.Headers.Add("x-client-id", ClientId);
request.Headers.Add("x-request-timestamp", timestamp);
request.Headers.Add("x-signature", signature);
request.Content = new StringContent(bodyJson, Encoding.UTF8, "application/json");
var response = await Client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
private static string HmacSha512(string key, string message)
{
using var hmac = new HMACSHA512(Encoding.UTF8.GetBytes(key));
var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(message));
return Convert.ToHexString(hash).ToLower();
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class Main {
private static final String CLIENT_ID = "YOUR_CLIENT_ID";
private static final String SECRET_KEY = "YOUR_SECRET_KEY";
public static void main(String[] args) throws Exception {
// JSON minified, giống kết quả JSON.stringify()
String bodyJson = "{\"page\":0,\"size\":50,\"invoiceFromDate\":\"2026-10-01 00:00:00.000\",\"invoiceToDate\":\"2026-10-10 23:59:59.999\"}";
// Timestamp theo múi giờ UTC+7, định dạng yyyyMMddHHmmssSSS
String timestamp = ZonedDateTime.now(ZoneId.of("Asia/Ho_Chi_Minh"))
.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
String signature = hmacSha512(SECRET_KEY, timestamp + ":" + bodyJson);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://open-api.tingee.vn/v1/e-invoice/input/list"))
.header("accept", "application/json")
.header("Content-Type", "application/json")
.header("x-client-id", CLIENT_ID)
.header("x-request-timestamp", timestamp)
.header("x-signature", signature)
.method("POST", HttpRequest.BodyPublishers.ofString(bodyJson, StandardCharsets.UTF_8))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
private static String hmacSha512(String key, String data) throws Exception {
Mac mac = Mac.getInstance("HmacSHA512");
mac.init(new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA512"));
byte[] hash = mac.doFinal(data.getBytes(StandardCharsets.UTF_8));
StringBuilder hex = new StringBuilder();
for (byte b : hash) hex.append(String.format("%02x", b));
return hex.toString();
}
}
<?php
$clientId = "YOUR_CLIENT_ID";
$secretKey = "YOUR_SECRET_KEY";
$body = [
"page" => 0,
"size" => 50,
"invoiceFromDate" => "2026-10-01 00:00:00.000",
"invoiceToDate" => "2026-10-10 23:59:59.999",
];
// Không escape "/" và tiếng Việt để khớp với JSON.stringify phía TINGEE
$bodyJson = json_encode($body, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
// Timestamp theo múi giờ UTC+7, định dạng yyyyMMddHHmmssSSS
$now = new DateTime("now", new DateTimeZone("Asia/Ho_Chi_Minh"));
$timestamp = $now->format("YmdHisv");
$signature = hash_hmac("sha512", $timestamp . ":" . $bodyJson, $secretKey);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://open-api.tingee.vn/v1/e-invoice/input/list",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $bodyJson,
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Content-Type: application/json",
"x-client-id: " . $clientId,
"x-request-timestamp: " . $timestamp,
"x-signature: " . $signature,
],
]);
$response = curl_exec($ch);
if ($response === false) {
echo "cURL Error: " . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
Response mẫu
{
"code": "00",
"message": "Success",
"data": {
"totalCount": 1,
"items": [
{
"id": 123456,
"invoiceCode": "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"fileHistoryId": "f9e8d7c6-b5a4-4321-9876-543210fedcba",
"invoiceNo": "0000125",
"invoicePattern": "1",
"invoiceSeries": "C26TAA",
"sellerName": "CÔNG TY TNHH ABC",
"sellerTaxCode": "0101234567",
"totalBeforeTax": 1000000,
"taxAmount": 80000,
"totalAfterTax": 1080000,
"invoiceDate": "2026-10-05",
"receivedDate": "2026-10-06",
"invoiceStatus": 1,
"approvalStatus": 1,
"tctStatus": 1,
"invoiceType": 1,
"invoiceProperty": 1,
"importMethod": 1,
"orderNo": null,
"note": null
}
]
}
}
| Trường | Kiểu | Mô tả |
|---|---|---|
code | string | Mã kết quả (00 = Thành công). |
message | string | Thông điệp phản hồi. |
data.totalCount | number | Tổng số hóa đơn thỏa mãn điều kiện. |
data.items | array | Danh sách hóa đơn đầu vào của trang hiện tại. |
data.items[].id | number | ID hóa đơn tại nhà cung cấp. |
data.items[].invoiceCode | string | Mã định danh hóa đơn, dùng cho API Chi tiết và Bản thể hiện PDF. |
data.items[].fileHistoryId | string | Mã lịch sử file hóa đơn tại nhà cung cấp. |
data.items[].invoiceNo | string | Số hóa đơn. |
data.items[].invoicePattern | string | Mẫu số hóa đơn. |
data.items[].invoiceSeries | string | Ký hiệu hóa đơn. |
data.items[].sellerName | string | Tên người bán. |
data.items[].sellerTaxCode | string | Mã số thuế người bán. |
data.items[].totalBeforeTax | number | Tổng tiền trước thuế. |
data.items[].taxAmount | number | Tiền thuế. |
data.items[].totalAfterTax | number | Tổng tiền thanh toán. |
data.items[].invoiceDate | string | Ngày lập hóa đơn. |
data.items[].receivedDate | string | Ngày nhận hóa đơn. |
data.items[].approvalStatus | number | Trạng thái phê duyệt (xem bảng tham số approvalStatus). |
data.items[].invoiceProperty | number | Tính chất hóa đơn (xem bảng tham số invoiceProperty). |
data.items[].invoiceStatus | number | Trạng thái hóa đơn (theo dữ liệu của nhà cung cấp). |
data.items[].tctStatus | number | Trạng thái hóa đơn tại cơ quan thuế. |
data.items[].invoiceType | number | Loại hóa đơn (theo dữ liệu của nhà cung cấp). |
data.items[].importMethod | number | Phương thức nhập hóa đơn (theo dữ liệu của nhà cung cấp). |
data.items[].orderNo | string | Số đơn hàng (nếu có). |
data.items[].note | string | Ghi chú (nếu có). |
Mã lỗi thường gặp
| Code | Mô tả | Hướng xử lý |
|---|---|---|
2040 | Khoảng thời gian không hợp lệ | Ngày bắt đầu phải nhỏ hơn hoặc bằng ngày kết thúc. |
400 | Lấy danh sách hóa đơn đầu vào thất bại | message chứa mô tả chi tiết. |
2036 | Tài khoản chưa đăng ký dịch vụ Hóa đơn đầu vào | Cập nhật tài khoản với services chứa input-invoice qua API Tạo/Cập nhật tài khoản. |
2007 | Nhà cung cấp chưa được hỗ trợ | Hóa đơn đầu vào chỉ hỗ trợ tài khoản nhà cung cấp x-cyber. |
2032 | Chưa cấu hình tài khoản mặc định | Truyền accountId, hoặc đặt một tài khoản làm mặc định. |
1057 | Không tìm thấy thông tin tài khoản | Kiểm tra accountId. |
1095, 1096 | Lỗi merchantId của Master Merchant | Truyền merchantId thuộc Master Merchant đang gọi API. |
90, 91, 92, 97 | Lỗi xác thực request (timestamp, client-id, chữ ký) | Xem Mã lỗi hệ thống. |
Others | Lỗi khác | Xem Danh sách mã lỗi. |