> This is Payabli documentation. For a complete page index, fetch https://docs.payabli.com/llms.txt — append .md to any page URL for lightweight markdown. For section-level indexes, query parameters, and other AI-optimized access methods, see https://docs.payabli.com/ai-agents.md

# Get invoice attachment

GET https://api-sandbox.payabli.com/api/Invoice/attachedFileFromInvoice/{idInvoice}/{filename}

Retrieves a file attached to an invoice.

Reference: https://docs.payabli.com/developers/api-reference/invoice/get-attached-file-from-an-invoice

## Authentication

- `Authorization` header (bearer token, required)
- `requestToken` header (required) — Long-lived API token sent in the `requestToken` header. See [API token authentication](/developers/api-tokens).

## Servers

- `https://api-sandbox.payabli.com/api` (Sandbox, default)
- `https://api.payabli.com/api` (Production)

## Request

### Path parameters

- `filename` (string, required) — The filename in Payabli. Get this from the `zipName` field in the `DocumentsRef.filelist` array returned by `/api/Invoice/{idInvoice}`. Example: `0_Bill.pdf`.
- `idInvoice` (integer, required) — Invoice ID

### Query parameters

- `returnObject` (boolean, optional, default: false) — When `true`, the request returns the file content as a Base64-encoded string.

## Response

### 200

A successful response returns a binary file when `returnObject` is `false`. When `returnObject` is `true`, the response contains the file content as a Base64-encoded string in an object. Due to technical limitations, only the object response is documented here.

- `fContent` (string, optional) — Content of file, Base64-encoded. Ignored if `furl` is specified. Max upload size is 30 MB.
- `filename` (string, optional) — The name of the attached file.
- `ftype` (enum, optional) — The MIME type of the file (if content is provided).
  - Allowed values: `pdf`, `doc`, `docx`, `jpg`, `jpeg`, `png`, `gif`, `txt`
- `furl` (string, optional) — Optional URL provided to show or download the file remotely.

## Examples

**Response**

```json
{
  "fContent": "string",
  "filename": "string",
  "ftype": "pdf",
  "furl": "string"
}
```

**SDK Code**

```typescript
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        clientId: "YOUR_CLIENT_ID",
        clientSecret: "YOUR_CLIENT_SECRET",
    });
    await client.invoice.getAttachedFileFromInvoice(1, "filename", {});
}
main();

```

```python
from payabli import payabli

client = payabli(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

client.invoice.get_attached_file_from_invoice(
    id_invoice=1,
    filename="filename",
)

```

```java
package com.example.usage;

import io.github.payabli.api.PayabliApiClient;
import io.github.payabli.api.resources.invoice.requests.GetAttachedFileFromInvoiceRequest;

public class Example {
    public static void main(String[] args) {
        PayabliApiClient client = PayabliApiClient.withCredentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
            .build()
        ;

        client.invoice().getAttachedFileFromInvoice(
            1,
            "filename",
            GetAttachedFileFromInvoiceRequest
                .builder()
                .build()
        );
    }
}
```

```ruby
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.invoice.get_attached_file_from_invoice(
  id_invoice: 1,
  filename: "filename"
)

```

```csharp
using PayabliApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new PayabliApiClient(
            clientId: "YOUR_CLIENT_ID",
            clientSecret: "YOUR_CLIENT_SECRET"
        );

        await client.Invoice.GetAttachedFileFromInvoiceAsync(
            idInvoice: 1,
            filename: "filename",
            request: new GetAttachedFileFromInvoiceRequest()
        );
    }

}

```

```go
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithClientCredentials(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET",
        ),
    )
    request := &payabli.GetAttachedFileFromInvoiceRequest{}
    client.Invoice.GetAttachedFileFromInvoice(
        context.TODO(),
        1,
        "filename",
        request,
    )
}

```

```php
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Invoice\Requests\GetAttachedFileFromInvoiceRequest;

$client = new PayabliClient(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->invoice->getAttachedFileFromInvoice(
    1,
    'filename',
    new GetAttachedFileFromInvoiceRequest([]),
);

```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Invoice/attachedFileFromInvoice/1/filename")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```