Skip to content

PRO REST API

REST API in the polski-pro/v1 namespace for managing invoices, settings and legal documents. Requires authentication and manage_woocommerce capability.

The API requires two authorization elements:

  1. WordPress nonce - the X-WP-Nonce header with a value generated by wp_create_nonce('wp_rest')
  2. Capability - the logged-in user must have the manage_woocommerce capability
const response = await fetch('/wp-json/polski-pro/v1/invoices', {
headers: {
'X-WP-Nonce': wpApiSettings.nonce,
'Content-Type': 'application/json',
},
});
$nonce = wp_create_nonce('wp_rest');
$response = wp_remote_get(
rest_url('polski-pro/v1/invoices'),
[
'headers' => [
'X-WP-Nonce' => $nonce,
],
]
);

Unauthenticated requests or requests from users without the required capability receive a 401 Unauthorized or 403 Forbidden response.

GET /wp-json/polski-pro/v1/invoices

Query parameters:

ParameterTypeDefaultDescription
pageint1Page number
per_pageint20Results per page (max 100)
statusstringanyStatus filter: draft, issued, sent, paid, cancelled
date_fromstringnullDate from (Y-m-d)
date_tostringnullDate to (Y-m-d)
order_idintnullFilter by WooCommerce order ID
searchstringnullSearch by invoice number or contractor name

Response (200 OK):

{
"invoices": [
{
"id": 1,
"number": "FV/2026/04/001",
"order_id": 567,
"status": "issued",
"type": "vat",
"buyer": {
"name": "Firma Testowa Sp. z o.o.",
"nip": "1234567890",
"address": "ul. Testowa 1, 00-001 Warszawa"
},
"net_total": "1000.00",
"tax_total": "230.00",
"gross_total": "1230.00",
"currency": "PLN",
"issued_at": "2026-04-01T10:30:00+02:00",
"due_date": "2026-04-15",
"external_id": "FV-12345",
"provider": "fakturownia"
}
],
"total": 42,
"pages": 3
}
POST /wp-json/polski-pro/v1/invoices

Body parameters (JSON):

ParameterTypeRequiredDescription
order_idintYesWooCommerce order ID
typestringNoType: vat (default), proforma, receipt
issue_datestringNoIssue date (Y-m-d), defaults to today
due_datestringNoPayment due date (Y-m-d)
notesstringNoInvoice notes
send_to_providerboolNoSend to accounting system (default true)

Request:

{
"order_id": 567,
"type": "vat",
"due_date": "2026-04-15",
"notes": "Termin płatności 14 dni",
"send_to_provider": true
}

Response (201 Created):

{
"id": 43,
"number": "FV/2026/04/002",
"order_id": 567,
"status": "issued",
"type": "vat",
"buyer": {
"name": "Firma Testowa Sp. z o.o.",
"nip": "1234567890",
"address": "ul. Testowa 1, 00-001 Warszawa"
},
"net_total": "500.00",
"tax_total": "115.00",
"gross_total": "615.00",
"currency": "PLN",
"issued_at": "2026-04-05T14:00:00+02:00",
"due_date": "2026-04-15",
"external_id": null,
"provider_status": "pending"
}
GET /wp-json/polski-pro/v1/invoices/{id}

Returns complete invoice data including line items.

Response (200 OK):

{
"id": 43,
"number": "FV/2026/04/002",
"order_id": 567,
"status": "issued",
"type": "vat",
"buyer": {
"name": "Firma Testowa Sp. z o.o.",
"nip": "1234567890",
"address": "ul. Testowa 1, 00-001 Warszawa"
},
"seller": {
"name": "Mój Sklep Sp. z o.o.",
"nip": "9876543210",
"address": "ul. Sklepowa 5, 02-222 Warszawa"
},
"items": [
{
"name": "Produkt testowy",
"sku": "TEST-001",
"quantity": 2,
"unit": "szt.",
"net_price": "100.00",
"tax_rate": 23,
"tax_amount": "46.00",
"gross_price": "246.00"
},
{
"name": "Dostawa - InPost Paczkomat",
"sku": null,
"quantity": 1,
"unit": "szt.",
"net_price": "12.20",
"tax_rate": 23,
"tax_amount": "2.80",
"gross_price": "15.00"
}
],
"net_total": "212.20",
"tax_total": "48.80",
"gross_total": "261.00",
"currency": "PLN",
"payment_method": "transfer",
"issued_at": "2026-04-05T14:00:00+02:00",
"due_date": "2026-04-15",
"notes": "Termin płatności 14 dni",
"external_id": "FV-12346",
"provider": "fakturownia",
"provider_status": "issued",
"ksef_number": null
}

Response (404 Not Found):

{
"code": "invoice_not_found",
"message": "Faktura o podanym ID nie istnieje.",
"data": { "status": 404 }
}
POST /wp-json/polski-pro/v1/invoices/{id}/pdf

Regenerates the invoice PDF file and returns the download URL.

Body parameters (optional):

ParameterTypeDescription
templatestringPDF template: default, minimal, detailed
languagestringLanguage: pl, en, de

Response (200 OK):

{
"id": 43,
"pdf_url": "https://example.com/wp-content/uploads/polski-pro/invoices/FV-2026-04-002.pdf",
"generated_at": "2026-04-05T14:05:00+02:00",
"file_size": 45678
}
POST /wp-json/polski-pro/v1/invoices/{id}/ksef

Submits the invoice to the National e-Invoice System (KSeF).

Body parameters (optional):

ParameterTypeDescription
test_modeboolSubmit to the KSeF test environment (default false)

Response (200 OK):

{
"id": 43,
"ksef_number": "1234567890-20260405-ABC123DEF456",
"ksef_status": "accepted",
"submitted_at": "2026-04-05T14:10:00+02:00",
"upo_url": "https://example.com/wp-content/uploads/polski-pro/ksef/UPO-43.xml"
}

Response (422 Unprocessable Entity):

{
"code": "ksef_validation_error",
"message": "Faktura nie spełnia wymagań schematu KSeF.",
"data": {
"status": 422,
"errors": [
"Brak numeru NIP nabywcy",
"Nieprawidłowa stawka VAT dla pozycji 2"
]
}
}
POST /wp-json/polski-pro/v1/invoices/{id}/correction

Creates a correction invoice linked to the source invoice.

Body parameters (JSON):

ParameterTypeRequiredDescription
reasonstringYesReason for correction
itemsarrayYesCorrected items
items[].original_indexintYesItem index on the source invoice (from 0)
items[].quantityintNoNew quantity
items[].net_pricestringNoNew net price

Request:

{
"reason": "Zwrot 1 sztuki produktu",
"items": [
{
"original_index": 0,
"quantity": 1,
"net_price": "100.00"
}
]
}

Response (201 Created):

{
"id": 44,
"number": "FK/2026/04/001",
"type": "correction",
"original_invoice_id": 43,
"original_invoice_number": "FV/2026/04/002",
"reason": "Zwrot 1 sztuki produktu",
"items": [
{
"name": "Produkt testowy",
"quantity_before": 2,
"quantity_after": 1,
"net_difference": "-100.00",
"tax_difference": "-23.00",
"gross_difference": "-123.00"
}
],
"net_total": "-100.00",
"tax_total": "-23.00",
"gross_total": "-123.00",
"status": "issued",
"issued_at": "2026-04-05T15:00:00+02:00"
}
GET /wp-json/polski-pro/v1/invoices/stats

Query parameters:

ParameterTypeDefaultDescription
daysint30Number of days back
group_bystringdayGrouping: day, week, month

Response (200 OK):

{
"period": {
"from": "2026-03-06",
"to": "2026-04-05"
},
"summary": {
"total_invoices": 156,
"total_net": "125430.00",
"total_tax": "28848.90",
"total_gross": "154278.90",
"total_corrections": 3,
"average_invoice_value": "989.22"
},
"by_status": {
"issued": 120,
"sent": 25,
"paid": 8,
"cancelled": 3
},
"by_tax_rate": {
"23": { "count": 140, "net": "110000.00", "tax": "25300.00" },
"8": { "count": 12, "net": "12000.00", "tax": "960.00" },
"5": { "count": 4, "net": "3430.00", "tax": "171.50" }
},
"timeline": [
{ "date": "2026-04-05", "count": 5, "gross": "4890.00" },
{ "date": "2026-04-04", "count": 7, "gross": "6230.00" }
]
}
POST /wp-json/polski-pro/v1/settings

Body parameters (JSON):

ParameterTypeDescription
sectionstringSettings section: invoices, catalog, quote, inpost, accounting
settingsobjectObject with key-value setting pairs

Request:

{
"section": "invoices",
"settings": {
"auto_issue": true,
"trigger_status": "processing",
"default_type": "vat",
"due_days": 14,
"number_format": "FV/{year}/{month}/{number}"
}
}

Response (200 OK):

{
"section": "invoices",
"settings": {
"auto_issue": true,
"trigger_status": "processing",
"default_type": "vat",
"due_days": 14,
"number_format": "FV/{year}/{month}/{number}"
},
"updated_at": "2026-04-05T14:20:00+02:00"
}
POST /wp-json/polski-pro/v1/legal/generate

Generates legal documents (terms of service, privacy policy) based on store data.

Body parameters (JSON):

ParameterTypeRequiredDescription
typestringYesDocument type: terms, privacy, withdrawal, cookies
company_dataobjectYesCompany data
company_data.namestringYesCompany name
company_data.nipstringYesVAT ID (NIP)
company_data.addressstringYesAddress
company_data.emailstringYesContact email
company_data.phonestringNoPhone number
formatstringNoFormat: html (default), markdown, pdf
languagestringNoLanguage: pl (default)

Request:

{
"type": "terms",
"company_data": {
"name": "Mój Sklep Sp. z o.o.",
"nip": "9876543210",
"address": "ul. Sklepowa 5, 02-222 Warszawa",
"email": "[email protected]",
"phone": "+48 123 456 789"
},
"format": "html"
}

Response (200 OK):

{
"type": "terms",
"content": "<h1>Regulamin sklepu internetowego...</h1>...",
"format": "html",
"generated_at": "2026-04-05T14:25:00+02:00",
"word_count": 3200,
"sections": [
"Postanowienia ogólne",
"Składanie zamówień",
"Płatności",
"Dostawa",
"Prawo odstąpienia od umowy",
"Reklamacje",
"Dane osobowe",
"Postanowienia końcowe"
]
}

All endpoints return standardized error codes:

HTTP codeError codeDescription
400invalid_paramsInvalid request parameters
401rest_not_logged_inUser not logged in
403rest_forbiddenMissing manage_woocommerce capability
404invoice_not_foundInvoice does not exist
409invoice_already_existsInvoice for this order already exists
422validation_errorData validation error
429rate_limit_exceededRequest rate limit exceeded (60/min)
500internal_errorInternal server error

The API applies rate limiting: a maximum of 60 requests per minute per user. After exceeding the limit, a 429 response is returned with a Retry-After header.

HTTP/1.1 429 Too Many Requests
Retry-After: 30
This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.