xero-php-oauth2 Files SDK Docs

# Xero Files API

## SDK Documentation

# 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";

    try {
      $result = $apiInstance->createFileAssociation($xeroTenantId, $fileId, $association);
    } 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

Body parameters

Name | Description
--- | ---
association | Association

# 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";

    try {
      $result = $apiInstance->createFolder($xeroTenantId, $folder);
    } 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

Body parameters

Name | Description
--- | ---
folder | Folder

# 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,

    /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";

    try {
      $result = $apiInstance->getAssociationsByObject($xeroTenantId, $objectId);
    } 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

# 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";

    try {
      $result = $apiInstance->updateFile($xeroTenantId, $fileId, $fileObject);
    } 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

Body parameters

Name | Description
--- | ---
fileObject | FileObject

# 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";

    try {
      $result = $apiInstance->updateFolder($xeroTenantId, $folderId, $folder);
    } 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

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";
    $mimeType = "mimeType_example";

    try {
      $result = $apiInstance->uploadFile($xeroTenantId, $body, $name, $filename, $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

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";
    $mimeType = "mimeType_example";

    try {
      $result = $apiInstance->uploadFileToFolder($xeroTenantId, $folderId, $body, $name, $filename, $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

Form parameters

Name | Description
--- | ---
body* | byte[] (byte) Required
name* | String exact name of the file you are uploading Required
filename* | String Required
mimeType | String