---
title: Create
slug: xero/m8HW-create
description: Learn how to create Bills in Xero using the "Invoice" object, with a step-by-step guide and sample Apex code. Set the "Type" field to "ACCPAY" and include necessary fields like "DateString" and "DueDateString." Add line items and receive response JSON wit
docTags: 
createdAt: 2021-11-02T07:47:30.000Z
---

In Xero, the "Invoice" object includes Invoices, Bills, and Credit Notes. So, when creating a Bill, set the field "Type" with the value "ACCPAY".

**Note:** For ACCPAY records, use "InvoiceNumber" as the reference field.

:::CodeblockTabs
Request

```apex
//  Create a Map to store all the data of a Bill
List<Object> billList = new List<Object>();
Map<String, Object> billMap = new Map<String, Object>();
    billMap.put('Type', 'ACCPAY');
    billMap.put('DateString', '2021-11-11T00:00:00');
    billMap.put('DueDateString', '2021-12-06T00:00:00');
    billMap.put('Status', 'DRAFT');
    billMap.put('InvoiceNumber', 'This is the reference for Bill');

    //  Initializing the Bill
    Map<String, Object> contactMap = new Map<String, Object>();
    contactMap.put('ContactID', 'c84ebb15-0a8d-4145-933f-203e68d014a0');
    billMap.put('Contact', contactMap);
    //  Initializing the Bill Line Items
    List<Object> lineItemList = new List<Object>();
        Map<String, Object> lineItemMap = new Map<String, Object>(); 
        lineItemMap.put('Description', 'Line Item Description');
        lineItemMap.put('UnitAmount', 100);
        lineItemMap.put('Quantity', 10);
		lineItemMap.put('AccountCode', '310');
        lineItemList.add(lineItemMap);
        
    //  Adding the Line Items to Bill
    billMap.put('LineItems', lineItemList);
    billList.add(billMap);

//  Initializing the RequestJSON Data to be passed.
    Map<String, Object> reqJSONMap = new Map<String, Object>(); 
    reqJSONMap.put('invoices', billList); 
    String reqJSON = JSON.serialize(reqJSONMap); 

    Map<String, Object> finalReqMap = new Map<String, Object>(); 
    finalReqMap.put('version', '1.0'); 
    finalReqMap.put('action', 'createBill'); 
    finalReqMap.put('RequestJSON', reqJSON); 
    finalReqMap.put('skipDML', false); 
    //Required, if Xero Multi-Org is enabled in Breadwinner. 
    finalReqMap.put('xeroOrgId', '!aa00TM');  
    System.debug('Request ::: ' + finalReqMap);

//  Placing a request to Breadwinner Global API
    Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
    System.debug('Response ::: ' + respMap);
```

Response

```json
{
   action=createBill,
   responseJSON={
      "statusCode":200,
      "bills":[
         {
            "UpdatedDateUTC":null,
            "Type":"ACCPAY",
            "TotalTax":0.00,
            "TotalDiscount":null,
            "Total":1000.00,
            "Telephone":"",
            "SubTotal":1000.00,
            "Status":"DRAFT",
            "SentToContact":false,
            "SalesforceRecordId":"a0K7F00001eFt7OUAS",
            "Reference":"",
            "PurchaseOrderNumber":null,
            "PurchaseOrderID":null,
            "Payments":null,
            "LineItems":[
               {
                  "UnitAmount":100.00,
                  "Tracking":[
                     
                  ],
                  "TaxType":"INPUT",
                  "TaxAmount":0.00,
                  "Quantity":10.0000,
                  "LineItemID":"1294d14b-30e6-4c76-85f5-d66de2c02b83",
                  "LineAmount":1000.00,
                  "ItemCode":null,
                  "DiscountRate":null,
                  "Description":"Line Item Description",
                  "AccountCode":"310"
               }
            ],
            "LineAmountTypes":"Exclusive",
            "IsDiscounted":false,
            "InvoiceNumber":"This is the reference for Bill",
            "InvoiceID":"192d2166-7cfa-4f30-89c1-9ad1dc1f55df",
            "HasErrors":false,
            "DueDateString":"2021-12-06T00:00:00",
            "DueDate":"/Date(1638748800000+0000)/",
            "DeliveryInstructions":"",
            "DeliveryDateString":null,
            "DeliveryDate":null,
            "DeliveryAddress":"",
            "DateVariable":"/Date(1636588800000+0000)/",
            "DateString":"2021-11-11T00:00:00",
            "CurrencyRate":1.0000000000,
            "CurrencyCode":"INR",
            "CreditNotes":null,
            "Contact":{
               "Name":"Test Contact 2",
               "ContactStatus":"ACTIVE",
               "ContactID":"c84ebb15-0a8d-4145-933f-203e68d014a0"
            },
            "BrandingThemeID":null,
            "AttentionTo":"",
            "AmountPaid":0.00,
            "AmountDue":1000.00,
            "AmountCredited":0.00
         }
      ],
      "errors":[
         
      ]
   },
   timestamp=1636631567378,
   validRequest=true,
   version=1.0
}
```
:::

