Error Handling¶
The Gestix API reports failures through HTTP status codes. From 7.2.03, every error also has a JSON body with the message.
HTTP Status Codes¶
| Code | Meaning | When it occurs |
|---|---|---|
200 |
OK | Successful GET request |
201 |
Created | Customer or supplier created (no ID in the response) |
202 |
Accepted | Document created without print (for example POST /invoices); update accepted |
400 |
Bad Request | Missing or invalid parameters or request body |
403 |
Forbidden | Invalid, expired, or missing session token |
405 |
Method Not Allowed | From 7.2.03: a method the endpoint does not support, for example PUT, PATCH or DELETE on /invoices/ |
409 |
Conflict | Duplicate entry (e.g., document or entity already exists) |
Error Response Format¶
From 7.2.03: JSON body¶
Every error, and every write answer, has a JSON body:
{"status": 400, "error": true, "message": "Gestix: document data not valid | line 1 - invalid input data (dit_up: invalid number '4,50' ...)"}
| Field | Type | Description |
|---|---|---|
status |
integer | The HTTP status code |
error |
boolean | true for an error, false for success (for example {"status":202,"error":false,"message":"Gestix document accepted"}) |
message |
string | The reason, as text |
Before 7.2.03: empty body¶
A 400 has an empty body; the reason is only in the HTTP status line (for example 400 Gestix: document data not valid | ...). Many clients cannot read it (Google Apps Script UrlFetchApp, any HTTP/2 connection). To read the reason, call GET /status right after the failed request: its errors array lists the session's recent errors, newest first.
In both cases, handle empty and non-JSON bodies.
Third-party identification errors¶
Customer/supplier creation requires sufficient identifying data according to the applicable entity/tenant rules. In a workflow accepting either identifier, supply vat_id or email. Email is not universally mandatory; an email-required error from one validation path does not establish a requirement for every customer or supplier.
Name alone is not a reliable unique identifier because different real entities may share the same name. New third parties still require country_iso; resolving an identification error does not remove the country requirement. Check the available status reason/error information and the third-party creation requirements for missing or conflicting data.
Handling Errors in Code¶
Python example¶
import requests
response = requests.post(
f"{BASE_URL}/invoices",
params={"nonce": nonce},
headers={"Authorization": f"Bearer {token}"},
json=document_data
)
if response.status_code == 202:
print("Invoice accepted") # no id or number: search by reference
elif response.status_code in (400, 409):
try:
error = response.json()
except ValueError:
error = response.text or None
print(f"HTTP {response.status_code}: {response.reason or ''}")
if error:
print(error)
elif response.status_code == 403:
print("Session expired — re-authenticating...")
token = get_session_token(api_token)
# retry...
JavaScript example¶
const response = await fetch(`${BASE_URL}/invoices?nonce=${nonce}`, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify(documentData)
});
if (!response.ok) {
const body = await response.text();
let error = body;
try {
error = JSON.parse(body);
} catch {
// Before 7.2.03 the body is empty: call GET /status/ for the reason.
}
console.error(`HTTP ${response.status}: ${response.statusText}`, error);
}
403 — Session Expiry¶
A 403 response means your session token has expired or is invalid. Re-authenticate by calling GET /helo again to get a new xa-token.
Proactive health checks
Use GET /status to check session health and inspect any recent errors before making write operations.
Support¶
If an error persists, record the HTTP status, the request and the error message, and contact support@gestix.com — these values help trace the issue in server logs.