Invoices | Get Single Invoice

Invoice Retrieval Endpoint

This document provides guidance on using the API to fetch a single invoice through the get_invoice endpoint: header, status and flags, lines, VAT rows per VAT rate, totals, payment transactions, the per-channel sent log, the customer snapshot and the public payment link. Use it to confirm created invoices, reconcile payments added through set_invoice_transaction and check what was actually sent.

API ENDPOINT FOR INVOICE RETRIEVAL

To fetch an invoice, you provide your API credentials and either the numeric invoice_id or the payment reference number returned by set_invoice.

Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/get_invoice/
  • Method: POST

Parameters | Payload

API Authentication Parameters

  • TOKEN (api_key): Your unique API key for authentication. How to Create API Credentials.
  • username: Your login username.
  • password: Your login password.
  • account: Your specific account ID.

Invoice Retrieval Parameters

  • invoice_id (integer): The numeric invoice id (either this or reference is required).
  • reference (string): The invoice payment reference number (either this or invoice_id is required).

Handling Responses

The response invoice.status is one of draft, open, paid, cancelled; status_flags carries additional states such as is_overdue or is_partially_paid. transactions lists every payment with its numeric payment_type and resolved payment_method name, and entry_type shows 1 for API-added transactions (0 = entered manually in the admin).



Call Examples in Different Languages


curl -X POST 'https://easycms.fi/public_api/get_invoice' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&invoice_id=1042'

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://easycms.fi/public_api/get_invoice",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query(['username' => 'USERNAME', 'password' => 'PASSWORD', 'account' => 'ACCOUNT_ID', 'invoice_id' => '1042']),
  CURLOPT_HTTPHEADER => array("Authorization1: TOKEN"),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

import requests
url = "https://easycms.fi/public_api/get_invoice"
headers = {"Authorization1": "TOKEN"}
payload = {'username': 'USERNAME', 'password': 'PASSWORD', 'account': 'ACCOUNT_ID', 'invoice_id': '1042'}
response = requests.post(url, headers=headers, data=payload)
print(response.text)

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://easycms.fi/public_api/get_invoice"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&invoice_id=1042"))
    .build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

const https = require('https');
const data = new URLSearchParams({ 
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "invoice_id": "1042",
}).toString();
const options = {
  hostname: 'easycms.fi',
  path: '/public_api/get_invoice',
  method: 'POST',
  headers: {
    'Authorization1': 'TOKEN',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': data.length
  }
};
const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(data); });
});
req.on('error', (e) => { console.error(e); });
req.write(data);
req.end();

import React, { useEffect, useState } from 'react';
function App() {
  const [responseText, setResponseText] = useState('');
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch('https://easycms.fi/public_api/get_invoice', {
          method: 'POST',
          headers: {'Authorization1': 'TOKEN', 'Content-Type': 'application/x-www-form-urlencoded'},
          body: new URLSearchParams({"username": "USERNAME", "password": "PASSWORD", "account": "ACCOUNT_ID", "invoice_id": "1042"}).toString()
        });
        const data = await response.text();
        setResponseText(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{responseText}
); } export default App;

// Kotlin example requires using a third-party library like OkHttp for POST requests with a body
// Kotlin Example using OkHttp for POST request
import okhttp3.OkHttpClient
import okhttp3.FormBody
import okhttp3.Request

fun main() {
    val client = OkHttpClient()

    val formBody = FormBody.Builder()
        .add("username", "USERNAME")
        .add("password", "PASSWORD")
        .add("account", "ACCOUNT_ID")
        .add("invoice_id", "1042")
        .build()

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/get_invoice")
        .post(formBody)
        .addHeader("Authorization1", "TOKEN")
        .build()

    client.newCall(request).execute().use { response ->
        if (!response.isSuccessful) throw IOException("Unexpected code $response")

        println(response.body?.string())
    }
}

using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
    static async Task Main()
    {
        var token = "TOKEN";
        var content = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair("username", "USERNAME"),
            new KeyValuePair("password", "PASSWORD"),
            new KeyValuePair("account", "ACCOUNT_ID"),
            new KeyValuePair("invoice_id", "1042")
        });
        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Add("Authorization1", token);
            var response = await httpClient.PostAsync("https://easycms.fi/public_api/get_invoice", content);
            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseData);
            }
            else
            {
                Console.WriteLine($"Error: {response.StatusCode}");
            }
        }
    }
}

Handling Endpoint Results

When you make a request to the endpoint, you receive a JSON response containing various keys and values. Here's an explanation of the response keys and their meanings:


{
    "OUTPUT": {
        "response_type": "success",
        "message": "invoice_data_returned_successfully",
        "invoice": {
            "invoice_id": 1042,
            "reference": "10753096392167",
            "title": "Invoice",
            "status": "paid",
            "status_flags": [],
            "invoice_date": "2026-10-06 14:02:11",
            "due_date": "2026-10-20 00:00:00",
            "delivery_date": "2026-10-06 14:02:11",
            "currency": "EUR",
            "total": 380.63,
            "total_net": 305.05,
            "total_vat": 75.58,
            "total_paid": 380.63,
            "total_due": 0,
            "vat_rows": [
                { "vat_percent": 24, "net": 225.0, "vat_amount": 54.0, "gross": 279.0 },
                { "vat_percent": 25.5, "net": 80.05, "vat_amount": 20.41, "gross": 100.46 }
            ],
            "lines": [ { "invoice_line_id": 9011, "number": 1, "pid": 4475, "title": "Consulting hours", "product_code": "CONS-1", "quantity": 2.5, "unit": "pcs", "unit_price": 100, "unit_price_is_net_excl_vat": true, "discount_percent": 10, "vat_percent": 24, "line_note": "Phase 1", "line_total_gross": 279.0 } ],
            "transactions": [
                { "transaction_id": "c1d0f2...", "date": "2026-10-07 09:11:04", "amount": 380.63, "payment_type": 0, "payment_method": "bank_transfer", "entry_type": 1 }
            ],
            "sent_log": [
                { "date": "2026-10-06 14:02:12", "type": "email", "sender": "API-Shop_1" }
            ],
            "customer": { "customer_id": 361, "firstname": "Maija", "lastname": "Meikäläinen", "email": "[email protected]", "billing_email": "[email protected]" },
            "note": "Thank you for your business!",
            "invoice_url": "https://yourdomain.fi/invoice.php?ref=8f14e45fceea167a5a36dedd4bea2543&id=343",
            "barcode": "4"
        }
    },
    "INFO": { "start": 0, "limit": 50, "count": 1, "total_count": 1, "tip": "", "docs": "https://easycms.fi/DOCUMENTATION/bt5/get_invoice" }
}
    

Error Handling

Here are the possible error messages and their meanings:

  • invoice_id_or_reference_must_be_provided_via_api: Neither invoice_id nor reference was sent.
  • invoice_not_found: No live invoice matches the id/reference in this account.
  • UN-AUTHORIZED - ...: Authentication failed (wrong TOKEN/username/password/account).