createAccount
Allows you to create a new chart of accounts
/Accounts
Usage and SDK Samples
curl -X "https://api.xero.com/api.xro/2.0/Accounts"
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.AccountingApi;
import java.io.File;
import java.util.*;
public class AccountingApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAuth2
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
AccountingApi apiInstance = new AccountingApi();
String xeroTenantId = YOUR_XERO_TENANT_ID; // String | Xero identifier for Tenant
Account account = { code: "123456", name: "Foobar", type: AccountType.EXPENSE, description: "Hello World" }; // Account |
try {
Accounts result = apiInstance.createAccount(xeroTenantId, account);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AccountingApi#createAccount");
e.printStackTrace();
}
}
}
import org.openapitools.client.api.AccountingApi;
public class AccountingApiExample {
public static void main(String[] args) {
AccountingApi apiInstance = new AccountingApi();
String xeroTenantId = YOUR_XERO_TENANT_ID; // String | Xero identifier for Tenant
Account account = { code: "123456", name: "Foobar", type: AccountType.EXPENSE, description: "Hello World" }; // Account |
try {
Accounts result = apiInstance.createAccount(xeroTenantId, account);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AccountingApi#createAccount");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure OAuth2 access token for authorization: (authentication scheme: OAuth2)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
String *xeroTenantId = YOUR_XERO_TENANT_ID; // Xero identifier for Tenant (default to null)
Account *account = { code: "123456", name: "Foobar", type: AccountType.EXPENSE, description: "Hello World" }; //
AccountingApi *apiInstance = [[AccountingApi alloc] init];
// Allows you to create a new chart of accounts
[apiInstance createAccountWith:xeroTenantId
account:account
completionHandler: ^(Accounts output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
const tokenSet: TokenSet = {
id_token: 'xxx',
access_token: 'yyy',
expires_at: 1582308862,
token_type: 'Bearer',
refresh_token: 'zzz',
session_state: 'xxx'
}
await xero.setTokenSet(tokenSet);
const xeroTenantId = "YOUR_XERO_TENANT_ID"; // {String} Xero identifier for Tenant
const account:Account = { code: "123456", name: "Foobar", type: AccountType.EXPENSE, description: "Hello World" }; // {Account}
try {
const response: any = await xero.accountingApi.createAccount(xeroTenantId, account);
console.log(response.body || response.response.statusCode)
} catch (err) {
console.log(`There was an ERROR! \n Status Code: ${err.response.statusCode}.`);
console.log(`ERROR: \n ${JSON.stringify(err.response.body, null, 2)}`);
}
using System;
using System.Diagnostics;
using .Api;
using .Client;
using .Model;
namespace Example
{
public class createAccountExample
{
public void main()
{
// Configure OAuth2 access token for authorization: OAuth2
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new AccountingApi();
var xeroTenantId = YOUR_XERO_TENANT_ID; // String | Xero identifier for Tenant (default to null)
var account = new Account(); // Account |
try
{
// Allows you to create a new chart of accounts
Accounts result = apiInstance.createAccount(xeroTenantId, account);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AccountingApi.createAccount: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );
$config->setHost("https://api.xero.com/api.xro/2.0");
$xeroTenantId = 'YOUR_XERO_TENANT_ID'; // String | Xero identifier for Tenant
$apiInstance = new XeroAPI\XeroPHP\Api\AccountingApi(
new GuzzleHttp\Client(),
$config
);
try {
$account = new XeroAPI\XeroPHP\Models\Accounting\Account;
$account->setCode("987654321");
$account->setName("FooBar");
$account->setType("EXPENSE");
$account->setDescription("Hello World");
$result = $apiInstance->createAccount($xeroTenantId,$account);
} catch (Exception $e) {
echo 'Exception when calling AccountingApi->createAccount: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use ::Configuration;
use ::AccountingApi;
# Configure OAuth2 access token for authorization: OAuth2
$::Configuration::access_token = 'YOUR_ACCESS_TOKEN';
my $api_instance = ::AccountingApi->new();
my $xeroTenantId = YOUR_XERO_TENANT_ID; # String | Xero identifier for Tenant
my $account = ::Object::Account->new(); # Account |
eval {
my $result = $api_instance->createAccount(xeroTenantId => $xeroTenantId, account => $account);
print Dumper($result);
};
if ($@) {
warn "Exception when calling AccountingApi->createAccount: $@\n";
}
from __future__ import print_statement
import time
import
from .rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: OAuth2
.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the API class
api_instance = .AccountingApi()
xeroTenantId = YOUR_XERO_TENANT_ID # String | Xero identifier for Tenant (default to null)
account = { code: "123456", name: "Foobar", type: AccountType.EXPENSE, description: "Hello World" } # Account |
try:
# Allows you to create a new chart of accounts
api_response = api_instance.create_account(xeroTenantId, account)
pprint(api_response)
except ApiException as e:
print("Exception when calling AccountingApi->createAccount: %s\n" % e)
extern crate AccountingApi;
pub fn main() {
let xeroTenantId = YOUR_XERO_TENANT_ID; // String
let account = { code: "123456", name: "Foobar", type: AccountType.EXPENSE, description: "Hello World" }; // Account
let mut context = AccountingApi::Context::default();
let result = client.createAccount(xeroTenantId, account, &context).wait();
println!("{:?}", result);
}
Scopes
Grant read-only access to your email | |
openid | Grant read-only access to your open id |
profile | your profile information |
accounting.transactions | Grant read-write access to bank transactions, credit notes, invoices, repeating invoices |
accounting.transactions.read | Grant read-only access to invoices |
accounting.reports.read | Grant read-only access to accounting reports |
accounting.journals.read | Grant read-only access to journals |
accounting.settings | Grant read-write access to organisation and account settings |
accounting.settings.read | Grant read-only access to organisation and account settings |
accounting.contacts | Grant read-write access to contacts and contact groups |
accounting.contacts.read | Grant read-only access to contacts and contact groups |
accounting.attachments | Grant read-write access to attachments |
accounting.attachments.read | Grant read-only access to attachments |
assets | Grant read-write access to assets |
assets.read | Grant read-only access to fixed assets |
bankfeeds | Grant read-write access to bankfeeds |
files | Grant read-write access to files and folders |
files.read | Grant read-only access to files and folders |
payroll | Grant read-write access to payroll |
payroll.read | Grant read-only access to payroll |
payroll.employees | Grant read-write access to payroll employees |
payroll.employees.read | Grant read-only access to payroll employees |
payroll.leaveapplications | Grant read-write access to payroll leaveapplications |
payroll.leaveapplications.read | Grant read-only access to payroll leaveapplications |
payroll.payitems | Grant read-write access to payroll payitems |
payroll.payitems.read | Grant read-only access to payroll payitems |
payroll.payrollcalendars | Grant read-write access to payroll calendars |
payroll.payrollcalendars.read | Grant read-only access to payroll calendars |
payroll.payruns | Grant read-write access to payroll payruns |
payroll.payruns.read | Grant read-only access to payroll payruns |
payroll.payslip | Grant read-write access to payroll payslips |
payroll.payslip.read | Grant read-only access to payroll payslips |
payroll.settings.read | Grant read-only access to payroll settings |
payroll.superfunds | Grant read-write access to payroll superfunds |
payroll.superfunds.read | Grant read-only access to payroll superfunds |
payroll.superfundproducts.read | Grant read-only access to payroll superfundproducts |
payroll.timesheets | Grant read-write access to payroll timesheets |
payroll.timesheets.read | Grant read-only access to payroll timesheets |
paymentservices | Grant read-write access to payment services |
projects | Grant read-write access to projects |
projects.read | Grant read-only access to projects |
Parameters
Name | Description |
---|---|
xero-tenant-id* |
String
Xero identifier for Tenant
Required
|
Name | Description |
---|---|
account * |
Account
Account object in body of request
Required
|