Orders
Generate Order Invoice
Trigger generation of an order’s invoice.
Scopes: orders:read
POST
/
v1
/
orders
/
{id}
/
invoice
python (new sdk)
from polar.v2026_04 import Polar
polar = Polar("polar_oat_xxx")
response = polar.orders.generate_invoice(
'00000000-0000-4000-8000-000000000000',
)
print(response)import { createPolar } from "@polar-sh/sdk/2026-04";
const polar = createPolar({
accessToken: "polar_oat_xxx",
});
const response = await polar.orders.generateInvoice(
"00000000-0000-4000-8000-000000000000",
);
console.log(response);curl --request POST \
--url https://api.polar.sh/v1/orders/{id}/invoice \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.polar.sh/v1/orders/{id}/invoice"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.polar.sh/v1/orders/{id}/invoice', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.polar.sh/v1/orders/{id}/invoice",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.polar.sh/v1/orders/{id}/invoice"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.polar.sh/v1/orders/{id}/invoice")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polar.sh/v1/orders/{id}/invoice")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}Once the invoice is generated, it’s permanent and cannot be modified.Make sure the billing details (name and address) are correct before generating the invoice. You can update them before generating the invoice by calling the
PATCH /v1/orders/{id} endpoint.After successfully calling this endpoint, you get a
202 response, meaning the generation of the invoice has been scheduled. It usually only takes a few seconds before you can retrieve the invoice using the GET /v1/orders/{id}/invoice endpoint.If you want a reliable notification when the invoice is ready, you can listen to the order.updated webhook and check the is_invoice_generated field.Was this page helpful?
⌘I
python (new sdk)
from polar.v2026_04 import Polar
polar = Polar("polar_oat_xxx")
response = polar.orders.generate_invoice(
'00000000-0000-4000-8000-000000000000',
)
print(response)import { createPolar } from "@polar-sh/sdk/2026-04";
const polar = createPolar({
accessToken: "polar_oat_xxx",
});
const response = await polar.orders.generateInvoice(
"00000000-0000-4000-8000-000000000000",
);
console.log(response);curl --request POST \
--url https://api.polar.sh/v1/orders/{id}/invoice \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.polar.sh/v1/orders/{id}/invoice"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.polar.sh/v1/orders/{id}/invoice', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.polar.sh/v1/orders/{id}/invoice",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.polar.sh/v1/orders/{id}/invoice"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.polar.sh/v1/orders/{id}/invoice")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polar.sh/v1/orders/{id}/invoice")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}
