POST /v1/convert — examples by language
Conversions between serializations, via ?from=&to=:
| from | to | Additional parameter | Result |
|---|---|---|---|
cii |
ubl |
variant (required) |
UBL XML |
ubl |
cii |
— | CII XML |
cii |
facturx |
profile (required) |
Factur-X PDF/A-3 |
facturx |
cii |
— | Raw CII XML (distinct from the /extract JSON) |
curl — CII to UBL
curl -X POST "https://api.example/v1/convert?from=cii&to=ubl&variant=peppol-bis" \
-H "Authorization: Bearer $FACTURX_API_KEY" \
--data-binary @invoice.cii.xml \
-o invoice.ubl.xml
curl — Package a CII as Factur-X
curl -X POST "https://api.example/v1/convert?from=cii&to=facturx&profile=EN16931" \
-H "Authorization: Bearer $FACTURX_API_KEY" \
--data-binary @invoice.cii.xml \
-o invoice.pdf
Python — UBL to CII
import requests, os
with open("invoice.ubl.xml", "rb") as f:
resp = requests.post(
"https://api.example/v1/convert",
params={"from": "ubl", "to": "cii"},
headers={"Authorization": f"Bearer {os.environ['FACTURX_API_KEY']}"},
data=f,
)
with open("invoice.cii.xml", "wb") as out:
out.write(resp.content)
Go — extract the raw CII from an existing Factur-X
package main
import (
"net/http"
"os"
)
func main() {
f, _ := os.Open("invoice.pdf")
defer f.Close()
req, _ := http.NewRequest(http.MethodPost, "https://api.example/v1/convert?from=facturx&to=cii", f)
req.Header.Set("Authorization", "Bearer "+os.Getenv("FACTURX_API_KEY"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := os.Create("invoice.cii.xml")
defer out.Close()
_, _ = out.ReadFrom(resp.Body)
}
Data loss (X-Conversion-Warnings)
Any data loss during a conversion would be reported in the
X-Conversion-Warnings header (JSON), never silently (FR-7). To date,
this header is always []: CII and UBL share exactly the same core
set of fields modeled by core.Invoice — there is currently no field
specific to either format that would be lost during a conversion.
Errors
| Code | Cause |
|---|---|
| 400 | Unsupported from/to combination, or missing required parameter (variant/profile) |
| 422 | Invalid/malformed source document for the format declared by from |
| 413 | Document > 20 MB |