# How to send attachment using bill api

**URL:** <https://api-discuss.freeagent.com/t/how-to-send-attachment-using-bill-api/6288>\
**Category:** Uncategorized\
**Created:** [4 December 2025 11:18 UTC](https://api-discuss.freeagent.com/t/how-to-send-attachment-using-bill-api/6288 "2025-12-04T11:18:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinodjaiswal](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/v/dfb087/32.png) [@vinodjaiswal](https://api-discuss.freeagent.com/u/vinodjaiswal)\
**Post date:** [4 December 2025 11:18 UTC](https://api-discuss.freeagent.com/t/how-to-send-attachment-using-bill-api/6288/1 "2025-12-04T11:18:01Z")

</div>

I am currently facing an issue while working with the FreeAgent API. I am able to create a bill successfully using the **Bill API** , but I am stuck on how to upload an attachment to the same bill.

I checked the API documentation, but I couldn’t find any API endpoint that allows uploading or attaching a file to a bill. I only found details about creating bills, but nothing related to inserting attachments.

API refernce: [FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/attachments)

Could you please guide me on:

1. Is there an API endpoint available to upload an attachment to a bill in FreeAgent?

2. If yes, could you please share the correct API URL and payload format?

3. If no, is there any alternative method to associate documents with a bill programmatically?

Below is my code:

```auto
function freeagent_old_createBill($data, $id, $is_line_items = 0)
   {

    $access_token = 'xxxxxxxxxxxxxxxxxxxx';

    /\* STEP 1: CREATE BILL \*/

    $billPayload = \[

        "bill" => \[

            "contact" => "https://api.sandbox.freeagent.com/v2/contacts/211536",

            "reference" => "BILL-10012",

            "dated_on" => "2025-01-10",

            "due_on" => "2025-01-20",

            "bill_items" => \[

                \[

                    "category" => "https://api.sandbox.freeagent.com/v2/categories/285",

                    "description" => "Office supplies purchase",

                    "sales_tax_rate" => "20.0",

                    "total_value" => "500.00"

                \]

            \]

        \]

    \];

    $ch = curl_init("https://api.sandbox.freeagent.com/v2/bills");

    curl_setopt_array($ch, \[

        CURLOPT_POST => true,

        CURLOPT_RETURNTRANSFER => true,

        CURLOPT_HTTPHEADER => \[

            "Authorization: Bearer $access_token",

            "Content-Type: application/json",

            "User-Agent: MyApp (support@myapp.com)"

        \],

        CURLOPT_POSTFIELDS => json_encode($billPayload)

    \]);

    $response = curl_exec($ch);

    curl_close($ch);

    $billResponse = json_decode($response, true);

    if (!isset($billResponse\['bill'\]\['url'\])) {

        return \[

            "error" => "Failed to create bill",

            "response" => $response

        \];

    }

    $bill_url = $billResponse\['bill'\]\['url'\]; // full URL

 }

```

---

<div class="post-metadata">

**Author:** ![johnfinch204](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@johnfinch204](https://api-discuss.freeagent.com/u/johnfinch204)\
**Post date:** [5 December 2025 12:54 UTC](https://api-discuss.freeagent.com/t/how-to-send-attachment-using-bill-api/6288/2 "2025-12-05T12:54:04Z")

</div>

To attach a file to a FreeAgent bill, you must include the attachment data directly within the bill payload when you create or update the bill using the standard bill API endpoint (/v2/bills). There is no separate upload endpoint. The file must be Base64 encoded and included in the attachment object of your JSON request, specifying the file\_name, content\_type, and the Base64 data string.

Best regards,  
John Finch

---

<div class="post-metadata">

**Author:** ![vinodjaiswal](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/v/dfb087/32.png) [@vinodjaiswal](https://api-discuss.freeagent.com/u/vinodjaiswal)\
**Post date:** [5 December 2025 13:14 UTC](https://api-discuss.freeagent.com/t/how-to-send-attachment-using-bill-api/6288/3 "2025-12-05T13:14:20Z")

</div>

Thank you @johnfinch204.

I will try.
