Download Order File
Streams the binary file deliverable for a purchased order item whose deliveryType is FILE. Strictly enforces that the parent order belongs to the authenticated API key user and is in PAID or DELIVERED state.
- cURL
- JavaScript (fetch)
- Python (requests)
- PHP
curl -sS -X GET "https://api.example.com/api/v1/orders/ord_mock_file/items/item_mock_file_1/file" \
-H "x-api-key: YOUR_API_KEY" \
-H "Accept: application/json" \
--output deliverable.bin
const res = await fetch("https://api.example.com/api/v1/orders/ord_mock_file/items/item_mock_file_1/file", {
method: "GET",
headers: {
"x-api-key": process.env.GPKEYS_API_KEY ?? "YOUR_API_KEY",
Accept: "application/json",
},
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(`HTTP ${res.status}: ${JSON.stringify(err)}`);
}
const buffer = Buffer.from(await res.arrayBuffer());
console.log("Downloaded bytes:", buffer.length);
import os
import requests
headers = {
"x-api-key": os.environ.get("GPKEYS_API_KEY", "YOUR_API_KEY"),
"Accept": "application/json",
}
resp = requests.get("https://api.example.com/api/v1/orders/ord_mock_file/items/item_mock_file_1/file", headers=headers, timeout=15)
resp.raise_for_status()
with open("deliverable.bin", "wb") as f:
f.write(resp.content)
print("Downloaded bytes:", len(resp.content))
<?php
$apiKey = getenv('GPKEYS_API_KEY') ?: 'YOUR_API_KEY';
$ch = curl_init('https://api.example.com/api/v1/orders/ord_mock_file/items/item_mock_file_1/file');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'x-api-key: ' . $apiKey,
'Accept: application/json',
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP {$status}\n" . ("Received " . strlen((string)$body) . " bytes") . "\n";
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
orderId | string | Yes | Owned order ID containing the file item. |
itemId | string | Yes | Specific OrderItem ID whose deliveryType is FILE. |
Success Response (200 OK)
Streams raw file bytes with response headers:
content-type: Stored MIME type (for exampleapplication/ziportext/plain)content-length: Exact byte lengthcontent-disposition:attachment; filename="<encoded-filename>"
Error Responses
| HTTP | error.code | Cause |
|---|---|---|
400 | VALIDATION_ERROR | Specified item is not a FILE delivery type |
401 | UNAUTHORIZED | Invalid, revoked, or expired key |
403 | FORBIDDEN / FRAUD_DETECTED | Disabled key, suspended user, or fraud block |
404 | NOT_FOUND | Order/item missing, belongs to another user, or stored file missing |
429 | RATE_LIMITED | Rate limit exceeded |
500 | INTERNAL_ERROR | Unexpected server error |