Import a Supplier Invoice
How to Import Supplier Invoices via API
This tutorial will guide you through the process of importing supplier invoices into Pennylane using our API endpoints.
Prerequisites
Before importing invoices, you need:
- OAuth token with
supplier_invoices:all
andfile_attachments:all
scopes - Supplier ID (existing supplier)
- Ledger account IDs (for precise accounting mapping, optional)
Step 1: Upload the Invoice PDF
First, upload your PDF invoice using the file attachments endpoint:
POST https://app.pennylane.com/api/external/v2/file_attachments
This will return an id
that will be used as file_attachment_id
in the next step.
Step 2: Import the Invoice
Use the following endpoint to import the supplier invoice in Pennylane:
POST https://app.pennylane.com/api/external/v2/supplier_invoices/import
Required Information:
- File Attachment ID: Use the ID obtained from Step 1
- Supplier Information: You'll need the
supplier_id
- Dates: Provide date and deadline of the invoice
- Amounts: Provide the following amounts
currency_amount_before_tax
: Invoice currency amount before tax ("montant HT de la facture" in French)currency_amount
: Invoice currency amount ("montant TTC de la facture" in French)currency_tax
: Invoice taxable amount ("montant de la TVA de la facture" in French)
Invoice Line Details:
Each invoice line requires:
currency_amount
: Total amount for the linecurrency_tax
: Total VAT amountvat_rate
: VAT rate code (e.g., "FR_200" for 20%)
Ledger Accounts: It is advised to provide on each invoice line a ledger_account_id
in order for Pennylane to generate accounting entries properly mapped to accounts
- Find existing accounts:
GET /ledger_accounts?filter=\[{"field": "number", "operator": "start_with", "value": "YOUR_ACCOUNT_NUMBER"}\]
- Create new account:
POST /ledger_accounts\
Example request body :
{
"file_attachment_id": your_file_id,
"supplier_id": supplier_id,
"date": "YYYY-MM-DD",
"deadline": "YYYY-MM-DD",
"currency_amount_before_tax": "100.00",
"currency_amount": "120.00",
"currency_tax": "20.00",
"invoice_lines": [
{
"currency_amount": "120.00",
"currency_tax": "20.00",
"vat_rate": "FR_200",
"ledger_account_id": account_id
}
}
Optional - Step 3: Categorize the Invoice
After creating the invoice, you can categorize it:
-
Get or create a category:
-
Apply the category:
PUT /supplier_invoices/{invoice_id}/categories
Include the category weight in the request body:
[
{
"id": category_id,
"weight": "0.5"
},
{
"id": category_id,
"weight": "0.5"
}
]
Note: The weight represents the percentage allocation to this category (e.g., 1 for 100%, 0.5 for 50%).
That's it! Your purchase invoice has been imported, created, and categorized in Pennylane.
Updated 7 days ago