pennylane-customer-invoiceslisted
Install: claude install-skill Xileades/pennylane-api-toolkit
# Customer invoices (sales)
**Prerequisite: `pennylane-access`.**
Scopes: `customer_invoices:all`, `customers:all`, `quotes:all`, `products:all`.
Here you **issue** documents in the company's name. A finalised invoice goes to
the customer and enters the books. The rule is therefore: **create as a draft
whenever there is the slightest doubt**, have it validated, finalise after.
## 1. The customer first
In v2, **each object is created through its own endpoint**: a customer cannot be
created inline in an invoice payload.
```powershell
$base = 'https://app.pennylane.com/api/external/v2'
$hd = PLHdr 'company-a'
$customers = PLGetAll 'company-a' 'customers' @(
@{ field = 'name'; operator = 'start_with'; value = 'ACME' }
)
```
**Major trap — company vs individual.** Two sets of endpoints:
| | Company | Individual |
|---|---|---|
| Create | `POST /company_customers` | `POST /individual_customers` |
| Update | `PUT /company_customers/{id}` | `PUT /individual_customers/{id}` |
| Own fields | `name`, `vat_number`, `reg_no` | `first_name`, `last_name` |
Calling the **wrong** endpoint **returns no error**: the request succeeds and
corrupts the record (permanent type conversion in the UI, empty display name in
accounting). The documentation's words are "could result in data corruption". So
**always read the type before an update** — the dedicated endpoints do not
return it:
```powershell
$c = Invoke-RestMethod -Uri "$base/customers/$id" -Headers $hd -Method Get
$c.customer_type