Accounts


Overview

URL https://api.xero.com/api.xro/2.0/Accounts
Methods Supported GET, PUT
Description Allows you to create individual accounts in a Xero organisation
Allows you to retrieve the full chart of accounts
Allows you to attach files to an account

Elements for Accounts

The following elements are required for a PUT request
Code Customer defined alpha numeric account code e.g 200 or SALES
Name Name of account
Type See Account Types
The following elements are optional for a PUT request
Description Description of Account. All accounts except bank accounts return this element
Tax Type See Tax Types
EnablePaymentsToAccount Boolean – describes whether account can have payments applied to it
ShowInExpenseClaims Boolean – describes whether account code is available for use with expense claims
Elements returned on a GET request only
AccountID Xero identifier
Class See Account Class Types
ReportingCode Unique identifier for account
Status See Account Status Codes
SystemAccount If this is a system account then this element is returned. See System Account types
BankAccountNumber Shown for bank accounts only
CurrencyCode Shown for bank accounts only
ReportingCode shown if set (NZ Orgs only)
ReportingCodeName shown if set (NZ Orgs only)
HasAttachments boolean to indicate if an account has an attachment

PUT Accounts(beta)

Use this method to create new accounts

Current Limitations

  • You can only add accounts one at a time (i.e. you’ll need to do multiple API calls to add many accounts)
  • Updating accounts is not currently supported
  • Replacing the entire chart of accounts is not currently supported

Example for PUT Accounts

1. Below is an example of creating a new sales account with the minimum elements required

<Account>
<Code>201</Code>
<Name>Sales - clearance lines</Name>
<Type>SALES</Type> 
</Account>

2. Below is an example of creating a new asset account with the minimum elements required

<Account>
<Code>304</Code>
<Name>Clearing - EFTPOS</Name>
<Type>ASSET</Type> 
</Account>

3. Below is an example of creating a new bank account with the minimum elements required. (Note the bank account below is an AU account. )

<Account>
<Name>Cheque Account</Name>
<Type>BANK</Type>
<BankAccountNumber>121-121-1234567</BankAccountNumber>
</Account>

Uploading an Attachment

You can upload up to 10 attachments(each up to 3mb in size) per account, once the account has been created in Xero. To do this you’ll need to know the ID of the account which you’ll use to construct the URL when POST/PUTing a byte stream containing the attachment file. e.g. https://api.xero.com/api.xro/2.0/Accounts/f0ec0d8c-6fce-4330-bb3b-8306278c6fd8/Attachments/image.png. See the Attachments page for more details.

e.g.

POST /api.xro/2.0/Accounts/f0ec0d8c-4330-bb3b-83062c6fd8/Attachments/Image002932.png
Authorization: OAuth...
Content Type: image/png
Content-Length: 10293

{RAW-IMAGE-CONTENT}

GET Accounts

Optional parameters for GET Accounts

AccountID The Xero identifier for an account – specified as a string following the endpoint name
e.g. /297c2dc5-cc47-4afd-8ec8-74990b8761e9
Where Filter by an any element (see Filters)
order Order by any element returned (see Order By)

Example response for GET Accounts

<Accounts>
 	<Account>
 	 	<AccountID>297c2dc5-cc47-4afd-8ec8-74990b8761e9</AccountID>
 	 	<Code/>
 	 	<Name>BNZ Cheque Account</Name>
 	 	<Type>BANK</Type>
 	 	<TaxType>NONE</TaxType>
  		<EnablePaymentsToAccount>false</EnablePaymentsToAccount>
                <BankAccountNumber>3809087654321500</BankAccountNumber>
                <CurrencyCode>NZD</CurrencyCode>
 	</Account>
 	<Account>
  		<AccountID>5040915e-8ce7-4177-8d08-fde416232f18</AccountID>
 	 	<Code>200</Code>
 	 	<Name>Sales</Name>
 	 	<Type>REVENUE</Type>
  	        <TaxType>OUTPUT</TaxType>
 	 	<Description>Income from any normal business activity</Description>
 	 	<EnablePaymentsToAccount>false</EnablePaymentsToAccount>
 	</Account>
</Accounts>

Example response for GET Accounts/297c2dc5-cc47-4afd-8ec8-74990b8761e9

(an AccountID identifier following the endpoint name)

<Accounts>
    <Account>
        <AccountID>297c2dc5-cc47-4afd-8ec8-74990b8761e9</AccountID>
        <Code/>
        <Name>BNZ Cheque Account</Name>
        <Type>BANK</Type>
        <TaxType>NONE</TaxType>
        <EnablePaymentsToAccount>false</EnablePaymentsToAccount>
                <BankAccountNumber>3809087654321500</BankAccountNumber>
                <CurrencyCode>NZD</CurrencyCode>
    </Account>
</Accounts>