> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/platform/control-panel/api/real-world-use-cases/rss-feed-for-invoices.md).

# RSS feed for invoices

***

The Glesys API can be used for many purposes—for example, you can retrieve all invoices associated with the customer number linked to an account.&#x20;

The PHP example below fetches a list of all invoices and formats them as an RSS feed. Deploy the script on your own server and create an API key that has permission to use the `invoice/list` function from your server’s IP address. Then add the feed to an RSS reader to receive notifications whenever a new invoice is sent to you.

More information about the API is available on [GitHub](https://github.com/glesys/api-docs).

{% code title="invoice-rss.php" %}

```php
<?php
  $account = "cl12345";
  $apikey  = "secret";
  $invoicesJson = file_get_contents("https://$account:$apikey@api.glesys.com/invoice/list/format/json");
  $invoices = json_decode($invoicesJson, true);
?>
  <?xml version='1.0' encoding='UTF-8'>
  <rss version="2.0">
    <channel>
        <title>GleSYS invoices</title>
        <description>A list of all invoices for the account <?=$account?></description>
        <link>http://www.glesys.se/</link>
        <lastbuilddate>
          <?php
            $timestamp = strtotime($invoices['response']['invoices'][0]['invoicedate']);
            $rss_datetime = date(DATE_RFC2822, $timestamp);
            print $rss_datetime;
          ?>
        </lastbuilddate>
        <pubdate>Mon, 19 Dec 2011 08:45:00 +0000</pubdate>
        <ttl>1800</ttl>
        <?php foreach($invoices['response']['invoices'] as $invoice): ?>
          <item>
            <title>Invoice <?=$invoice['invoicenumber']?></title>
            <description>
              Due date: <?=$invoice['duedate']?>
              Amount: <?=$invoice['total']?> <?=$invoice['currency']?>
            </description>
            <link><?=htmlentities($invoice['url'])?></link>
            <guid><?=htmlentities($invoice['url'])?></guid>
            <pubdate>
              <?php
                $timestamp = strtotime($invoice['invoicedate']);
                $rss_datetime = date(DATE_RFC2822, $timestamp);
                print $rss_datetime;
              ?>
            </pubdate>
          </item>
        <?php endforeach; ?>
  </channel>
</rss>
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.glesys.com/platform/control-panel/api/real-world-use-cases/rss-feed-for-invoices.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
