> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API data access

> Retrieve ABBYY FlexiCapture reporting archives through the data access REST API using DataFile methods and Bearer-token authentication, with a sample.

The REST API provides the following methods for retrieving reporting data:

* [DataFile method](/flexi-capture/reporting-service/reporting-data-file)
* [DataFile/GetFileList method](/flexi-capture/reporting-service/reporting-data-file-get-file-list)
* [DataFile/CreateFile method](/flexi-capture/reporting-service/reporting-data-file-create-file)

<Info>
  You must [authenticate](/flexi-capture/reporting-service/reporting-data-access-authentication) every request with a Bearer token obtained from the ABBYY FlexiCapture application server. Only an Administrator or Monitoring Operator for the tenant can access that tenant's data.
</Info>

To view the API description, open `http://localhost:8002` on any machine where the ABBYY FlexiCapture Reporting service data access is installed.

## Example script

The following PowerShell script downloads a reporting statistics archive for a specified tenant and period, authenticating with an ABBYY FlexiCapture account.

```powershell theme={null}
# Downloads an archive with reporting statistics for the specified tenant
function GetDataFile {
    Param (
        [Parameter(Mandatory=$true)][String]$AppServer,
        [Parameter(Mandatory=$true)][AllowEmptyString()][string]$TenantName,
        [Parameter(Mandatory=$true)][string]$User,
        [Parameter(Mandatory=$true)][string]$Password,
        [Parameter(Mandatory=$true)][Int]$Year,
        [Parameter(Mandatory=$true)][Int]$Month,
        [Parameter(Mandatory=$true)][string]$DownloadPath,
        [Parameter(Mandatory=$true)][string]$ReportingServiseUri
    )
    # Use the tenant name and the application server address passed in the function parameters
    $URI = "https://$AppServer/Flexicapture12/Server/FCAuth/API/wsdl?Tenant=$TenantName"
    # Create a PSCredential object with the given username and password
    $creds = New-Object System.Management.Automation.PSCredential -ArgumentList @($user,(ConvertTo-SecureString -String $password -AsPlainText -Force))
    # Create a proxy web service that will authenticate with these credentials
    $proxy = New-WebServiceProxy -Uri $URI -Credential $creds
    $proxy.Url = "https://$AppServer/flexicapture12/Server/FCAuth/API/Soap?Tenant=$TenantName"
    $proxy.Credentials = $creds
    # And use it to ask FlexiCapture API for the token
    $ticket = $proxy.GetCurrentUserAuthTicket()
    $nameFile = $year.ToString() + "-" + $month.ToString()
    # Create path for download file
    $path = "$DownloadPath\$nameFile.zip"
    # Create a request with Bearer authentication header containing the token
    # and send it to Reporting data access service to get the archive for the specified tenant and period
    $headers = @{ Authorization = "Bearer " + $ticket}
    Invoke-RestMethod -Uri $ReportingServiseUri"?tenantName=$TenantName&year=$year&month=$month" -Headers $headers -OutFile $path
}
GetDataFile
```
