> 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 bill attachment

GET https://api-sandbox.payabli.com/api/Bill/attachedFileFromBill/{idBill}/{filename}

Retrieves a file attached to a bill, either as a binary file or as a Base64-encoded string.

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

## 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/Bill/{idBill}`. Example: `0_Bill.pdf`.
- `idBill` (integer, required) — Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

### 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": "TXkgdGVzdCBmaWxlHJ==...",
  "filename": "my-doc.pdf",
  "ftype": "pdf",
  "furl": "https://mysite.com/my-doc.pdf"
}
```

**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.bill.getAttachedFromBill(285, "0_Bill.pdf", {
        returnObject: true,
    });
}
main();

```

```python
from payabli import payabli

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

client.bill.get_attached_from_bill(
    id_bill=285,
    filename="0_Bill.pdf",
    return_object=True,
)

```

```java
package com.example.usage;

import io.github.payabli.api.PayabliApiClient;
import io.github.payabli.api.resources.bill.requests.GetAttachedFromBillRequest;

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

        client.bill().getAttachedFromBill(
            285,
            "0_Bill.pdf",
            GetAttachedFromBillRequest
                .builder()
                .returnObject(true)
                .build()
        );
    }
}
```

```ruby
require "payabli"

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

client.bill.get_attached_from_bill(
  id_bill: 285,
  filename: "0_Bill.pdf",
  return_object: true
)

```

```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.Bill.GetAttachedFromBillAsync(
            idBill: 285,
            filename: "0_Bill.pdf",
            request: new GetAttachedFromBillRequest {
                ReturnObject = true
            }
        );
    }

}

```

```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.GetAttachedFromBillRequest{
        ReturnObject: payabli.Bool(
            true,
        ),
    }
    client.Bill.GetAttachedFromBill(
        context.TODO(),
        285,
        "0_Bill.pdf",
        request,
    )
}

```

```php
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Bill\Requests\GetAttachedFromBillRequest;

$client = new PayabliClient(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->bill->getAttachedFromBill(
    285,
    '0_Bill.pdf',
    new GetAttachedFromBillRequest([
        'returnObject' => true,
    ]),
);

```

```swift
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Bill/attachedFileFromBill/285/0_Bill.pdf?returnObject=true")! 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()
```