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

# Snap a receipt into the books

> Photograph a receipt on your phone and attach it to its transaction in Scoutworks, with an iPhone Shortcut or a Power Automate button.

> [!NOTE]
>
> * **For:** treasurers, and leaders who pay for things
> * **You get:** a button on your phone that photographs a receipt, finds the transaction it belongs to and attaches the photo to it
> * **Time:** about twenty minutes the first time
> * **Scopes:** `accounting:read`, `accounting.people:read` and `accounting:write`

Receipts get lost between the shop and the treasurer. With this, whoever paid takes a photo at the till, picks the transaction from a short list, and the photo is on that transaction in Scoutworks before they leave the car park. The treasurer sees it beside the line, as if they had attached it themselves.

There are two versions: an **iPhone Shortcut**, and a **Power Automate** button for Android phones and for groups on Microsoft 365. Both do the same three things: list recent spending, let you choose the line, and upload the photo to `POST /transactions/{transactionId}/attachments`.

> [!WARNING]
>
> Attaching a receipt changes your records, so the read-only [sandbox key](https://developers.scoutworks.app/guides/sandbox.md) can list the transactions but cannot attach anything. Use your own key with `accounting:write`, and [try it on one receipt](#try-it-on-one-receipt) first.

## 1. Try the request

The list the button shows is the last fortnight's spending. Paste this into a terminal to see the demo group's:

```bash theme={null}
curl "https://api-demo.scoutworks.app/api/v1/transactions?type=expense&from=2026-11-01&limit=50" \
  -H "Authorization: Bearer sw_test_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab"
```

Each line has an `id`, a `date`, an `amount` in pounds and, with `accounting.people:read`, a `description` and `counterparty`. The button shows those, so you can tell the camp gas from the hall cleaning.

The upload itself is one request with the photo in a part named `file`:

```bash theme={null}
curl -X POST "https://api.scoutworks.app/api/v1/transactions/PASTE_TRANSACTION_ID/attachments" \
  -H "Authorization: Bearer PASTE_YOUR_KEY" \
  -F "file=@receipt.jpg"
```

It answers `201` with the attachment. A photo of up to 10 MB is fine; a PDF, a JPEG or PNG photo, or a saved email (`.eml`, `.msg`) all work. Each one is virus scanned before it is stored.

## 2. Make a key

In Scoutworks, go to **Settings → Integrations → API keys** and create a key called "Receipts" with `accounting:read`, `accounting.people:read` and `accounting:write`. Copy it: it is shown once. The key only ever changes the books as the admin who created it, and Scoutworks marks each receipt with the key's name.

> [tab] iPhone Shortcut
>
> ## 3. Build the Shortcut
>
> Open **Shortcuts**, tap **+**, and add these actions in order. Search for each by name.
>
> **1. Take Photo**
>
> Leave **Show Camera Preview** on.
>
> **2. Resize Image**
>
> Width **2000**, height auto. A receipt stays readable and the upload stays small.
>
> **3. Convert Image**
>
> To **JPEG**.
>
> **4. Adjust Date and Format Date**
>
> Add **Adjust Date**: subtract **14 days** from **Current Date**. Then **Format Date** with a custom format of `yyyy-MM-dd`.
>
> **5. Get Contents of URL (the list)**
>
> URL: `https://api.scoutworks.app/api/v1/transactions?type=expense&limit=50&from=` followed by the **Formatted Date** variable. Under **Headers**, add `Authorization` with the value `Bearer ` and your key.
>
> **6. Get Dictionary Value**
>
> Get the value for `data` in **Contents of URL**.
>
> **7. Repeat with Each**
>
> For each item in **Dictionary Value**: add a **Text** action with the item's `date`, `£`, its `amount` and its `description`. Then **Set Dictionary Value** on a dictionary variable called `Payments`: key **Text**, value the item's `id`. (Start with an empty **Dictionary** action named `Payments` before the repeat.)
>
> **8. Choose from List**
>
> From the keys of **Payments**, with the prompt "Which payment is this receipt for?". Then **Get Dictionary Value** for **Chosen Item** in **Payments**, and **Set Variable** `TransactionId` to it.
>
> **9. Get Contents of URL (the upload)**
>
> URL: type `https://api.scoutworks.app/api/v1/transactions/PASTE_TRANSACTION_ID/attachments`, then replace `PASTE_TRANSACTION_ID` with the **TransactionId** variable. Method **POST**. Headers: `Authorization` as before. Request Body: **Form**. Add one field of type **File**, key `file`, value **Converted Image**.
>
> **10. Show Notification**
>
> "Receipt attached". If the upload answered an error, the notification shows its message instead.
>
> Name it "Receipt" and add it to your Home Screen. Tap it at the till.

> [tab] Power Automate (Android and Microsoft 365)
>
> ## 3. Build the flow
>
> In [Power Automate](https://make.powerautomate.com), choose **Create → Instant cloud flow**, name it "Receipt", and pick the **Manually trigger a flow** trigger. Add three inputs to it: a **File** called `Receipt`, a **Number** called `Amount`, and a **Date** called `Paid on`.
>
> Then add these actions. The **HTTP** action needs a premium licence; a charity's Microsoft 365 nonprofit plan usually includes one.
>
> **1. HTTP: list the day's spending**
>
> Method **GET**. URI: type `https://api.scoutworks.app/api/v1/transactions?type=expense&limit=50&to=` and add the **Paid on** input, then type `&from=` and add **Paid on** again. Header `Authorization`: `Bearer ` followed by your key.
>
> **2. Filter array: the payment for this amount**
>
> From `body('HTTP')?['data']`, keep items where `float(item()?['amount'])` is equal to the **Amount** input.
>
> **3. Condition: exactly one**
>
> If `length(body('Filter_array'))` is equal to `1`, go on. If not, add **Send me a mobile notification**: "No single payment of £@{triggerBody()['number']} on that day. Attach this one in Scoutworks." and stop.
>
> **4. HTTP: attach the receipt**
>
> In the **Yes** branch: method **POST**. URI: type `https://api.scoutworks.app/api/v1/transactions/PASTE_TRANSACTION_ID/attachments`, then replace `PASTE_TRANSACTION_ID` with this **Expression**: `first(body('Filter_array'))?['id']`.
>
> Header `Authorization` as before. Body:
>
> ```json theme={null}
> {
>   "$content-type": "multipart/form-data",
>   "$multipart": [
>     {
>       "headers": { "Content-Disposition": "form-data; name=\"file\"; filename=\"@{triggerBody()?['file']?['name']}\"" },
>       "body": {
>         "$content-type": "image/jpeg",
>         "$content": "@{triggerBody()?['file']?['contentBytes']}"
>       }
>     }
>   ]
> }
> ```
>
> **5. Send me a mobile notification**
>
> Set the text to `Receipt attached to @{first(body('Filter_array'))?['description']}`.
>
> Save it, install the **Power Automate** app on your phone, and the flow appears under **Buttons**. Tap it, take the photo, type the amount and the date.

## Try it on one receipt

Before you hand the button to the whole team, check one receipt lands where you expect.

**1. Attach one**

Photograph a receipt for a payment you can find easily, and run the button once.

**2. Check it in Scoutworks**

Open that transaction in **Finance → Transactions**. The photo is under its attachments, readable, and on the right line. If it is on the wrong one, remove it there and run the button again.

## Safe to press twice

Sending the same photo to the same transaction again answers `200` with the attachment it already has: nothing is stored twice. A receipt changes nothing about the money, so a line from the bank, GoCardless or a closed year takes one too.

## If something goes wrong

* **`413 file_too_large`**: the photo is over 10 MB. Keep the **Resize Image** step, or take the photo at a lower resolution.
* **`415 unsupported_file_type`**: the file is not a photo, a PDF or a saved email.
* **`422 file_infected`**: the virus scan found something in the file, and nothing was stored. Do not send it again.
* **`404 not_found`**: the transaction is not in your group, or was deleted.
* **`429 rate_limited`**: the key has uploaded more than 50 MB in a minute. Wait a minute. See [Rate limits](https://developers.scoutworks.app/guides/rate-limits.md).
* **`403 insufficient_scope`**: the key cannot write. Add `accounting:write`, or use your own key in place of the sandbox key.

See [Errors](https://developers.scoutworks.app/guides/errors.md) for every code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.