Order Invoice
Attach an external invoice URL to an order, or remove it. File upload via Web API is not supported — only a public URL.
Set invoice URL
POST /api/v1/orders/{id}/invoice
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Public invoice URL (PDF/image) |
name | string | No | Display name |
Remove invoice
DELETE /api/v1/orders/{id}/invoice
PHP
<?php
$baseUrl = 'https://example.com/api/v1';
$apiKey = 'YOUR_API_KEY';
$orderId = 15;
function apiRequest(string $method, string $url, string $apiKey, ?array $data = null): array
{
$ch = curl_init();
$headers = [
'X-API-Key: ' . trim($apiKey),
'Accept: application/json',
];
if ($data !== null) {
$headers[] = 'Content-Type: application/json';
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => true,
]);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
}
$response = curl_exec($ch);
$httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
$decoded = json_decode((string) $response, true);
return [
'http_code' => $httpCode,
'curl_error' => $error,
'response' => is_array($decoded) ? $decoded : $response,
];
}
// Attach invoice URL
$result = apiRequest('POST', $baseUrl . '/orders/' . $orderId . '/invoice', $apiKey, [
'url' => 'https://example.com/fatura.pdf',
'name' => 'Fatura',
]);
print_r($result);
// Remove invoice
// $result = apiRequest('DELETE', $baseUrl . '/orders/' . $orderId . '/invoice', $apiKey);
cURL
# Attach invoice URL
curl -s -X POST \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/fatura.pdf","name":"Fatura"}' \
"https://example.com/api/v1/orders/15/invoice"
# Remove invoice
curl -s -X DELETE \
-H "X-API-Key: YOUR_API_KEY" \
"https://example.com/api/v1/orders/15/invoice"
Sample Response (JSON)
{
"success": true,
"message": "Fatura kaydedildi",
"content": {
"id": 15,
"orderNumber": "FS-20260617-0015",
"invoice": {
"type": "url",
"url": "https://example.com/fatura.pdf",
"name": "Fatura"
}
}
}