Xero Files API

Files

createFileAssociation

Creates a new file association

By passing in the appropriate options, you can create a new folder


/Files/{FileId}/Associations

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";
$idempotencyKey = "KEY_VALUE";

try {
  $result = $apiInstance->createFileAssociation($xeroTenantId, $fileId, $association, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->createFileAssociation: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
association *
Association
Required

createFolder

Creates a new folder

By passing in the appropriate properties, you can create a new folder


/Folders

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$idempotencyKey = "KEY_VALUE";

try {
  $result = $apiInstance->createFolder($xeroTenantId, $folder, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->createFolder: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
folder *
Folder
Required

deleteFile

Deletes a specific file

Delete a specific file


/Files/{FileId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $apiInstance->deleteFile($xeroTenantId, $fileId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->deleteFile: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

deleteFileAssociation

Deletes an existing file association

By passing in the appropriate options, you can create a new folder


/Files/{FileId}/Associations/{ObjectId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";
$objectId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $apiInstance->deleteFileAssociation($xeroTenantId, $fileId, $objectId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->deleteFileAssociation: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
ObjectId*
UUID (uuid)
Object id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

deleteFolder

Deletes a folder

By passing in the appropriate ID, you can delete a folder


/Folders/{FolderId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$folderId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $apiInstance->deleteFolder($xeroTenantId, $folderId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->deleteFolder: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FolderId*
UUID (uuid)
Folder id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

getAssociationsByObject

Retrieves an association object using a unique object ID

By passing in the appropriate options, you can retrieve an association


/Associations/{ObjectId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$objectId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";
$pagesize = 50;
$page = 2;
$sort = "Associations/{ObjectId}?sort=CreatedDateUtc";
$direction = "Associations/{ObjectId}?sort=CreatedDateUtc&direction=DESC";

try {
  $result = $apiInstance->getAssociationsByObject($xeroTenantId, $objectId, $pagesize, $page, $sort, $direction);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getAssociationsByObject: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Path parameters
Name Description
ObjectId*
UUID (uuid)
Object id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Query parameters
Name Description
pagesize
Integer
pass an optional page size value
page
Integer
number of records to skip for pagination
sort
String
values to sort by
direction
String
direction to sort by

getAssociationsCount

Retrieves a count of associations for a list of objects.

By passing in the appropriate options, you can retrieve the association count for objects


/Associations/Count

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$objectIds = array()

try {
  $result = $apiInstance->getAssociationsCount($xeroTenantId, $objectIds);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getAssociationsCount: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Query parameters
Name Description
ObjectIds*
array[UUID] (uuid)
A comma-separated list of object ids
Required

getFile

Retrieves a file by a unique file ID


/Files/{FileId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $result = $apiInstance->getFile($xeroTenantId, $fileId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getFile: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

getFileAssociations

Retrieves a specific file associations

By passing in the appropriate options,


/Files/{FileId}/Associations

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $result = $apiInstance->getFileAssociations($xeroTenantId, $fileId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getFileAssociations: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

getFileContent

Retrieves the content of a specific file

By passing in the appropriate options, retrieve data for specific file


/Files/{FileId}/Content

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $result = $apiInstance->getFileContent($xeroTenantId, $fileId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getFileContent: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

getFiles

Retrieves files


/Files

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$pagesize = 50;
$page = 2;
$sort = "CreatedDateUTC DESC";

try {
  $result = $apiInstance->getFiles($xeroTenantId, $pagesize, $page, $sort);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getFiles: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Query parameters
Name Description
pagesize
Integer
pass an optional page size value
page
Integer
number of records to skip for pagination
sort
String
values to sort by

getFolder

Retrieves specific folder by using a unique folder ID

By passing in the appropriate ID, you can search for specific folder


/Folders/{FolderId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$folderId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";

try {
  $result = $apiInstance->getFolder($xeroTenantId, $folderId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getFolder: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Path parameters
Name Description
FolderId*
UUID (uuid)
Folder id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

getFolders

Retrieves folders

By passing in the appropriate options, you can search for available folders


/Folders

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$sort = "CreatedDateUTC DESC";

try {
  $result = $apiInstance->getFolders($xeroTenantId, $sort);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getFolders: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Query parameters
Name Description
sort
String
values to sort by

getInbox

Retrieves inbox folder

Search for the user inbox


/Inbox

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";

try {
  $result = $apiInstance->getInbox($xeroTenantId);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->getInbox: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders
files.read Grant read-only access to files and folders

Parameters

Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required

updateFile

Update a file

Updates file properties of a single file


/Files/{FileId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";
$idempotencyKey = "KEY_VALUE";

try {
  $result = $apiInstance->updateFile($xeroTenantId, $fileId, $fileObject, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->updateFile: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FileId*
UUID (uuid)
File id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
fileObject *
FileObject
Required

updateFolder

Updates an existing folder

By passing in the appropriate ID and properties, you can update a folder


/Folders/{FolderId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$folderId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";
$idempotencyKey = "KEY_VALUE";

try {
  $result = $apiInstance->updateFolder($xeroTenantId, $folderId, $folder, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->updateFolder: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FolderId*
UUID (uuid)
Folder id for single object
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
folder *
Folder
Required

uploadFile

Uploads a File to the inbox


/Files

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$body = BYTE_ARRAY_DATA_HERE;
$name = "name_example";
$filename = "filename_example";
$idempotencyKey = "KEY_VALUE";
$mimeType = "mimeType_example";

try {
  $result = $apiInstance->uploadFile($xeroTenantId, $body, $name, $filename, $idempotencyKey, $mimeType);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->uploadFile: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Form parameters
Name Description
body*
byte[] (byte)
Required
name*
String
exact name of the file you are uploading
Required
filename*
String
Required
mimeType
String

uploadFileToFolder

Uploads a File to a specific folder


/Files/{FolderId}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\FilesApi(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "YOUR_XERO_TENANT_ID";
$folderId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c";
$body = BYTE_ARRAY_DATA_HERE;
$name = "name_example";
$filename = "filename_example";
$idempotencyKey = "KEY_VALUE";
$mimeType = "mimeType_example";

try {
  $result = $apiInstance->uploadFileToFolder($xeroTenantId, $folderId, $body, $name, $filename, $idempotencyKey, $mimeType);
} catch (Exception $e) {
  echo 'Exception when calling FilesApi->uploadFileToFolder: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

files Grant read-write access to files and folders

Parameters

Path parameters
Name Description
FolderId*
UUID (uuid)
pass required folder id to save file to specific folder
Required
Header parameters
Name Description
xero-tenant-id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Form parameters
Name Description
body*
byte[] (byte)
Required
name*
String
exact name of the file you are uploading
Required
filename*
String
Required
mimeType
String