---
title: Create
slug: xero/GI6h-create
docTags: 
createdAt: 2026-02-13T12:47:56.481Z
---

In this example, we are creating a Credit Note for an Invoice, but the same process can also be used for Bills with minor adjustments, as noted in the comments within the request.

To create a Credit Note, set the field "Type" with the value "ACCRECCREDIT" for Sales Credit Note and "ACCPAYCREDIT" for Bill Credit Note, respectively.

:::CodeblockTabs
Request

```apex
// Create a List to store credit notes data
List<Object> creditNoteList = new List<Object>();
Map<String, Object> creditNoteMap = new Map<String, Object>();

// REQUIRED: Credit Note type
// Use 'ACCRECCREDIT' for Sales Credit Note
// Use 'ACCPAYCREDIT' for Bill Credit Note
creditNoteMap.put('Type', 'ACCRECCREDIT');

// Set the Credit Note Date
creditNoteMap.put('Date', '2021-11-11');

// Line amount type (Exclusive / Inclusive / NoTax)
creditNoteMap.put('LineAmountTypes', 'Exclusive');

// Status of the Credit Note
creditNoteMap.put('Status', 'DRAFT');

//Contact Information
Map<String, Object> contactMap = new Map<String, Object>();
contactMap.put('ContactID', 'c84ebb15-0a8d-4145-933f-203e68d014a0');
creditNoteMap.put('Contact', contactMap);

// Credit Note Line Items
List<Object> lineItemList = new List<Object>();

Map<String, Object> lineItemMap = new Map<String, Object>();
lineItemMap.put('Description', 'Line Item Description');
lineItemMap.put('Quantity', 10);
lineItemMap.put('UnitAmount', 100);
lineItemMap.put('AccountCode', '200');

lineItemList.add(lineItemMap);

// Attach line items to Credit Note
creditNoteMap.put('LineItems', lineItemList);

// Add Credit Note to list
creditNoteList.add(creditNoteMap);

// Request JSON Payload
Map<String, Object> reqJSONMap = new Map<String, Object>();

reqJSONMap.put('creditnotes', creditNoteList);

String reqJSON = JSON.serialize(reqJSONMap);

// Final Global API Request
Map<String, Object> finalReqMap = new Map<String, Object>();
Map<String, Object> reqOptions = new Map<String, Object>();
finalReqMap.put('queryParameters', reqOptions);
finalReqMap.put('version', '1.0');
finalReqMap.put('action', 'createCreditNote');
finalReqMap.put('RequestJSON', reqJSON);
finalReqMap.put('skipDML', false);
// REQUIRED if Xero Multi-Org is enabled
finalReqMap.put('xeroOrgId', '!aa00TM'); // Replace with your Xero Org ID

System.debug('CN Create Request ::: ' + finalReqMap);

// Call Breadwinner Global API
Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);

System.debug('CN Create Response ::: ' + respMap);
```

Response

```json
{
   action=createCreditNote,
   responseJSON={
      "statusCode":200,
      "CreditNotes": [
    {
      "CreditNoteID": "dac2c670-e3cb-41ff-a6a5-ff2ac9149e73",
      "Payments": [],
      "ID": "dac2c670-e3cb-41ff-a6a5-ff2ac9149e73",
      "HasErrors": false,
      "CurrencyRate": 1.0000000000,
      "Type": "ACCPAYCREDIT",
      "Reference": "",
      "RemainingCredit": 100.00,
      "Allocations": [],
      "Contact": {
        "ContactID": "021b18f8-b62f-4d8a-889e-71fd5427892a",
        "ContactStatus": "ACTIVE",
        "Name": "Young Bros Transport",
        "EmailAddress": "rog@ybt.co",
        "Addresses": [
          {
            "AddressType": "STREET",
            "City": "",
            "Region": "",
            "PostalCode": "",
            "Country": ""
          },
          {
            "AddressType": "POBOX",
            "AddressLine1": "P O Box 5678\r\n",
            "City": "Oaktown",
            "Region": "",
            "PostalCode": "1235",
            "Country": ""
          }
        ],
        "Phones": [
          {
            "PhoneType": "MOBILE",
          },
          {
            "PhoneType": "DEFAULT",
          },
          {
            "PhoneType": "FAX",
          },
          {
            "PhoneType": "DDI",
          }
        ],
        "UpdatedDateUTC": "\/Date(1769623421917+0000)\/",
        "ContactGroups": [],
        "ContactPersons": [],
        "HasValidationErrors": false
      },
      "DateString": "2026-03-11T00:00:00",
      "Date": "\/Date(1773187200000+0000)\/",
      "Status": "AUTHORISED",
      "LineAmountTypes": "Inclusive",
      "LineItems": [
        {
          "Description": "CN INV Line Item Description Final check",
          "UnitAmount": 100.00,
          "TaxType": "OUTPUT",
          "TaxAmount": 7.62,
          "LineAmount": 100.00,
          "AccountCode": "200",
          "Tracking": [],
          "Quantity": 1.0000,
          "LineItemID": "0f50a00c-5934-4d38-9ac1-1dc7698ade99",
          "AccountID": "d1ebb97b-d207-4ccb-9ab6-8a466a8b4d39",
          "ValidationErrors": []
        }
      ],
      "SubTotal": 92.38,
      "TotalTax": 7.62,
      "Total": 100.00,
      "UpdatedDateUTC": "\/Date(1770903590453+0000)\/",
      "CurrencyCode": "USD"
    }
  ],
    "errors":[
         
    ]      
   },
   timestamp=1636616272349,
   validRequest=true,
   version=1.0
}
```
:::



