You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无客户ContactID时,如何通过Xero API创建并提交新客户发票?

Creating Invoices for New Xero Customers Without Pre-Creating a Contact

Great question! Let's break down exactly how to handle this with Xero's API:

Can you directly create an invoice for a new customer?

Absolutely—you don't need to first create a contact and fetch its ContactID to generate an invoice for a new customer. Xero's API lets you create both the contact and the invoice in a single POST request to the Invoices endpoint.

How to include the customer name in the same POST request (no ContactID required)?

Instead of specifying a ContactID, you'll embed a full Contact object directly within your invoice payload. The only mandatory field for this embedded contact is Name—you can add extra details like email, phone, or address if you want, but they're optional.

Here's a simplified example of the JSON payload you'd send:

{
  "Invoices": [
    {
      "Type": "ACCREC", // Use ACCREC for accounts receivable (customer invoices)
      "Contact": {
        "Name": "Freshly Created Customer"
        // Optional additional contact fields:
        // "EmailAddress": "new.customer@example.com",
        // "Phone": "555-7890"
      },
      "LineItems": [
        {
          "Description": "Web Design Package",
          "Quantity": 1,
          "UnitAmount": 2500.00,
          "AccountCode": "200" // Match your Xero revenue account code
        }
      ],
      "Date": "2024-05-20",
      "DueDate": "2024-06-19"
    }
  ]
}

Important Things to Keep in Mind:

  • If a contact with the exact same Name already exists in your Xero org, the API will link the invoice to that existing contact instead of making a new one. To guarantee a new contact is created, include a unique field like EmailAddress—Xero uses this to avoid duplicate contacts.
  • Double-check that other invoice fields (like Type, AccountCode, and LineItems) meet Xero's requirements for valid invoices.

内容的提问来源于stack exchange,提问作者Derk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:28:37