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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'
idempotency_key = 'KEY_VALUE'

begin
  response = xero_client.accounting_api.create_file_association(xero_tenant_id, file_id, association, idempotency_key)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling create_file_association: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
idempotency_key = 'KEY_VALUE'

begin
  response = xero_client.accounting_api.create_folder(xero_tenant_id, folder, idempotency_key)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling create_folder: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.delete_file(xero_tenant_id, file_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling delete_file: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'
object_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.delete_file_association(xero_tenant_id, file_id, object_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling delete_file_association: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
folder_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.delete_folder(xero_tenant_id, folder_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling delete_folder: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
object_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'
pagesize = 50
page = 2
sort = 'Associations/{ObjectId}?sort=CreatedDateUtc'
direction = 'Associations/{ObjectId}?sort=CreatedDateUtc&direction=DESC'

begin
  response = xero_client.accounting_api.get_associations_by_object(xero_tenant_id, object_id, pagesize, page, sort, direction)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_associations_by_object: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
objectIds = []

begin
  response = xero_client.accounting_api.get_associations_count(xero_tenant_id, objectIds)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_associations_count: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.get_file(xero_tenant_id, file_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_file: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.get_file_associations(xero_tenant_id, file_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_file_associations: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.get_file_content(xero_tenant_id, file_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_file_content: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
pagesize = 50
page = 2
sort = 'CreatedDateUTC DESC'

begin
  response = xero_client.accounting_api.get_files(xero_tenant_id, pagesize, page, sort)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_files: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
folder_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'

begin
  response = xero_client.accounting_api.get_folder(xero_tenant_id, folder_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_folder: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
sort = 'CreatedDateUTC DESC'

begin
  response = xero_client.accounting_api.get_folders(xero_tenant_id, sort)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_folders: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'

begin
  response = xero_client.accounting_api.get_inbox(xero_tenant_id)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_inbox: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
file_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'
idempotency_key = 'KEY_VALUE'

begin
  response = xero_client.accounting_api.update_file(xero_tenant_id, file_id, fileObject, idempotency_key)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling update_file: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
folder_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'
idempotency_key = 'KEY_VALUE'

begin
  response = xero_client.accounting_api.update_folder(xero_tenant_id, folder_id, folder, idempotency_key)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling update_folder: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
body = BYTE_ARRAY_DATA_HERE
name = 'name_example'
filename = 'filename_example'
idempotency_key = 'KEY_VALUE'
mimeType = 'mimeType_example'

begin
  response = xero_client.accounting_api.upload_file(xero_tenant_id, body, name, filename, idempotency_key, mimeType)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling upload_file: #{e}"
end

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

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
folder_id = '4ff1e5cc-9835-40d5-bb18-09fdb118db9c'
body = BYTE_ARRAY_DATA_HERE
name = 'name_example'
filename = 'filename_example'
idempotency_key = 'KEY_VALUE'
mimeType = 'mimeType_example'

begin
  response = xero_client.accounting_api.upload_file_to_folder(xero_tenant_id, folder_id, body, name, filename, idempotency_key, mimeType)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling upload_file_to_folder: #{e}"
end

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