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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class CreateFileAssociationExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            var idempotencyKey = "KEY_VALUE";
            
            try {
                var result = await apiInstance.CreateFileAssociationAsync(accessToken, xeroTenantId, fileId, association, idempotencyKey);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.CreateFileAssociation: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class CreateFolderExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var idempotencyKey = "KEY_VALUE";
            
            try {
                var result = await apiInstance.CreateFolderAsync(accessToken, xeroTenantId, folder, idempotencyKey);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.CreateFolder: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class DeleteFileExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                await apiInstance.DeleteFileAsync(accessToken, xeroTenantId, fileId);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.DeleteFile: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class DeleteFileAssociationExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            var objectId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                await apiInstance.DeleteFileAssociationAsync(accessToken, xeroTenantId, fileId, objectId);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.DeleteFileAssociation: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class DeleteFolderExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var folderId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                await apiInstance.DeleteFolderAsync(accessToken, xeroTenantId, folderId);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.DeleteFolder: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetAssociationsByObjectExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var objectId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            var pagesize = 50;
            var page = 2;
            var sort = "Associations/{ObjectId}?sort=CreatedDateUtc";
            var direction = "Associations/{ObjectId}?sort=CreatedDateUtc&direction=DESC";
            
            try {
                var result = await apiInstance.GetAssociationsByObjectAsync(accessToken, xeroTenantId, objectId, pagesize, page, sort, direction);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetAssociationsByObject: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetAssociationsCountExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var objectIds = 
            
            try {
                var result = await apiInstance.GetAssociationsCountAsync(accessToken, xeroTenantId, objectIds);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetAssociationsCount: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetFileExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                var result = await apiInstance.GetFileAsync(accessToken, xeroTenantId, fileId);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetFile: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetFileAssociationsExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                var result = await apiInstance.GetFileAssociationsAsync(accessToken, xeroTenantId, fileId);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetFileAssociations: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetFileContentExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                var result = await apiInstance.GetFileContentAsync(accessToken, xeroTenantId, fileId);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetFileContent: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetFilesExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var pagesize = 50;
            var page = 2;
            var sort = "CreatedDateUTC DESC";
            
            try {
                var result = await apiInstance.GetFilesAsync(accessToken, xeroTenantId, pagesize, page, sort);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetFiles: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetFolderExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var folderId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            
            try {
                var result = await apiInstance.GetFolderAsync(accessToken, xeroTenantId, folderId);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetFolder: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetFoldersExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var sort = "CreatedDateUTC DESC";
            
            try {
                var result = await apiInstance.GetFoldersAsync(accessToken, xeroTenantId, sort);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetFolders: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class GetInboxExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            
            try {
                var result = await apiInstance.GetInboxAsync(accessToken, xeroTenantId);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.GetInbox: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class UpdateFileExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var fileId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            var idempotencyKey = "KEY_VALUE";
            
            try {
                var result = await apiInstance.UpdateFileAsync(accessToken, xeroTenantId, fileId, fileObject, idempotencyKey);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.UpdateFile: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class UpdateFolderExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var folderId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            var idempotencyKey = "KEY_VALUE";
            
            try {
                var result = await apiInstance.UpdateFolderAsync(accessToken, xeroTenantId, folderId, folder, idempotencyKey);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.UpdateFolder: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class UploadFileExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            byte[] body = BYTE_ARRAY_DATA_HERE;
            var name = "name_example";
            var filename = "filename_example";
            var idempotencyKey = "KEY_VALUE";
            var mimeType = "mimeType_example";
            
            try {
                var result = await apiInstance.UploadFileAsync(accessToken, xeroTenantId, body, name, filename, idempotencyKey, mimeType);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.UploadFile: " + e.Message );
            }
        }
    }
}

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

using System;
using System.Diagnostics;
using Xero.NetStandard.OAuth2.Api;
using Xero.NetStandard.OAuth2.Client;
using Xero.NetStandard.OAuth2.Model;

namespace Example
{
    public class UploadFileToFolderExample
    {
        public async Task Main()
        {            
            var accessToken = "YOUR_ACCESS_TOKEN";          
            var apiInstance = new FilesApi();
            var xeroTenantId = "YOUR_XERO_TENANT_ID";
            var folderId = Guid.Parse("4ff1e5cc-9835-40d5-bb18-09fdb118db9c");
            byte[] body = BYTE_ARRAY_DATA_HERE;
            var name = "name_example";
            var filename = "filename_example";
            var idempotencyKey = "KEY_VALUE";
            var mimeType = "mimeType_example";
            
            try {
                var result = await apiInstance.UploadFileToFolderAsync(accessToken, xeroTenantId, folderId, body, name, filename, idempotencyKey, mimeType);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling apiInstance.UploadFileToFolder: " + e.Message );
            }
        }
    }
}

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