> 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

Using the Glesys API, you can get an RSS feed for your 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 %}
