Sandbox
Symulator kupującego dla kluczy testowych (allee_sk_test_…): zamówienia, zwroty, wiadomości — bez prawdziwych klientów.
Konto demo (sandbox)
GET /allee/sandbox
tylko alleelimit: read
Przy pierwszym żądaniu klucza testowego powstaje konto demo: 20 aktywnych ofert, cennik, warunki, GPSR i kupujący demo. Tu dostajesz ich identyfikatory — gotowe do przykładów.
Działa wyłącznie kluczem testowym (allee_sk_test_…) — klucz produkcyjny dostaje 403 SANDBOX_ONLY. Dane są fikcyjne i oddzielone od produkcji (osobna baza); odpowiedzi mają nagłówek X-Allee-Mode: test.
Zgodność: tylko allee — static sandbox (wariant prosty).
Uprawnienie: dowolny ważny token lub klucz.
Grupa limitu: read.
Odpowiedzi
200 Konto demo. · SandboxSummary
mode string zawszetestseller IdRef zawszeOdwołanie po identyfikatorze.
Pola obiektu
id string zawszebuyer IdRef · null zawszeKupujący demo (fikcyjny).
Pola obiektu
id string zawszecreatedAt string · date-time · null zawszedataVersion integer zawszeWersja danych demo.
offers object zawszePola obiektu
active integer zawszetotal integer zawszesampleOfferId string · null zawszePrzykładowa aktywna oferta demo — do symulatora zamówień.
shippingRates object zawszeCennik demo.
Pola obiektu
id string · null zawszereturnPolicy object zawszePola obiektu
id string · null zawszeimpliedWarranty object zawszePola obiektu
id string · null zawszewarranty object zawszePola obiektu
id string · null zawszeresponsibleProducer object zawszePola obiektu
id string · null zawszeresponsiblePerson object zawszePola obiektu
id string · null zawszesimulator object zawszeTrasy symulatora.
Pola obiektu
orders string zawszereturns string zawszemessages string zawszeBłędy
| HTTP | Kod | Znaczenie |
|---|---|---|
| 401 | invalid_token | Brak, zły, wygasły albo odwołany token lub klucz (format OAuth, nagłówek WWW-Authenticate). |
| 403 | ACCOUNT_INACTIVE | Konto sprzedawcy jest nieaktywne. |
| 403 | AccessDenied | Brak zakresu albo zasób innego sprzedawcy. |
| 403 | KEY_QUARANTINED | Kwarantanna: działa tylko odczyt (wykryto nietypowe użycie). |
| 403 | KEY_SUSPENDED | Klucz albo dostęp aplikacji wstrzymany (przez sprzedawcę albo ochronę). |
| 403 | SANDBOX_ONLY | Symulator sandboxu wywołany kluczem produkcyjnym. |
| 429 | TOO_MANY_REQUESTS | Przekroczony limit (minutowy, grupy operacji albo IP). |
| 500 | INTERNAL_ERROR | Błąd serwera allee. |
| 503 | NOT_DEPLOYED | Funkcja jeszcze nie uruchomiona (np. sandbox, wsady). |
curl -sS -X GET "${ALLEE_API_URL:-https://api.allee.pl}/allee/sandbox" \
-H "Authorization: Bearer $ALLEE_API_KEY" \
-H "Accept: application/vnd.allegro.public.v1+json" \
-w '\nHTTP %{http_code}\n'<?php
// allee API: GET /allee/sandbox (PHP 8, rozszerzenie curl)
$base = getenv('ALLEE_API_URL') ?: 'https://api.allee.pl';
$ch = curl_init($base . '/allee/sandbox');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ALLEE_API_KEY'),
'Accept: application/vnd.allegro.public.v1+json',
],
CURLOPT_RETURNTRANSFER => true,
]);
$odp = curl_exec($ch);
echo 'HTTP ', curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $odp, "\n";# allee API: GET /allee/sandbox (Python 3, biblioteka requests)
import os
import requests
BASE = os.environ.get("ALLEE_API_URL", "https://api.allee.pl")
headers = {
"Authorization": "Bearer " + os.environ["ALLEE_API_KEY"],
"Accept": "application/vnd.allegro.public.v1+json",
}
r = requests.request("GET", BASE + "/allee/sandbox", headers=headers, timeout=60, allow_redirects=False)
print("HTTP", r.status_code)
print(r.text)// allee API: GET /allee/sandbox (Node.js 18+, wbudowany fetch; plik .mjs)
const BASE = process.env.ALLEE_API_URL ?? "https://api.allee.pl";
const res = await fetch(`${BASE}/allee/sandbox`, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.ALLEE_API_KEY}`,
"Accept": "application/vnd.allegro.public.v1+json",
},
redirect: "manual",
});
console.log("HTTP", res.status);
console.log(await res.text());// allee API: GET /allee/sandbox (C#, .NET 8+, HttpClient)
using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("ALLEE_API_URL") ?? "https://api.allee.pl";
using var http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
using var req = new HttpRequestMessage(new HttpMethod("GET"), baseUrl + "/allee/sandbox");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("ALLEE_API_KEY"));
req.Headers.Accept.ParseAdd("application/vnd.allegro.public.v1+json");
using var res = await http.SendAsync(req);
Console.WriteLine($"HTTP {(int)res.StatusCode}");
Console.WriteLine(await res.Content.ReadAsStringAsync());// allee API: GET /allee/sandbox (Java 11+, java.net.http; uruchom: java Main.java)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String base = System.getenv().getOrDefault("ALLEE_API_URL", "https://api.allee.pl");
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/allee/sandbox"))
.header("Authorization", "Bearer " + System.getenv("ALLEE_API_KEY"))
.header("Accept", "application/vnd.allegro.public.v1+json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
HttpResponse<String> res = http.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + res.statusCode());
System.out.println(res.body());
}
}// allee API: GET /allee/sandbox (Go 1.20+, net/http; uruchom: go run main.go)
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
base := os.Getenv("ALLEE_API_URL")
if base == "" {
base = "https://api.allee.pl"
}
req, err := http.NewRequest("GET", base+"/allee/sandbox", nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ALLEE_API_KEY"))
req.Header.Set("Accept", "application/vnd.allegro.public.v1+json")
klient := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
res, err := klient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
dane, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("HTTP", res.StatusCode)
fmt.Println(string(dane))
}application/vnd.allegro.public.v1+json{
"mode": "test",
"seller": {
"id": "980000001"
},
"buyer": {
"id": "4000000001"
},
"createdAt": "2026-11-10T11:10:02.000Z",
"dataVersion": 1,
"offers": {
"active": 20,
"total": 20,
"sampleOfferId": "900000000000001"
},
"shippingRates": {
"id": "154985df-0580-4e6e-91a3-7b23608beb41"
},
"returnPolicy": {
"id": "42133d83-0ba2-472e-9f21-25f2c35b69e4"
},
"impliedWarranty": {
"id": "eab748ba-c9ec-444f-8f18-eb3b4174ebca"
},
"warranty": {
"id": "e0b5c0de-c9d1-4be5-a5be-595e95db67ad"
},
"responsibleProducer": {
"id": "e157086a-a704-46a9-8922-770c82c9a7d6"
},
"responsiblePerson": {
"id": "30c5cc4a-ff63-4507-8c9c-e9410008b8f0"
},
"simulator": {
"orders": "POST /allee/sandbox/orders",
"returns": "POST /allee/sandbox/returns",
"messages": "POST /allee/sandbox/messages"
}
}Symulacja zamówienia kupującego
POST /allee/sandbox/orders
tylko alleeallegro:api:orders:writelimit: write
Kupujący demo kupuje Twoją ofertę z sandboxu. Zamówienie pojawia się w /order/checkout-forms, /order/events i w powiadomieniach ORDER_CHANGE. Zakres orders:write.
Działa wyłącznie kluczem testowym (allee_sk_test_…) — klucz produkcyjny dostaje 403 SANDBOX_ONLY. Dane są fikcyjne i oddzielone od produkcji (osobna baza); odpowiedzi mają nagłówek X-Allee-Mode: test.
Zgodność: tylko allee — Allegro sandbox: zamówienie testowe.
Uprawnienie: zakres allegro:api:orders:write.
Grupa limitu: write.
Nagłówki
Idempotency-Key stringOchrona przed podwójnym wykonaniem (jak Stripe/Amazon): powtórzony POST z tym samym kluczem i tą samą treścią w ciągu 24 h zwraca zapisaną odpowiedź z nagłówkiem Idempotent-Replayed: true i niczego nie wykonuje drugi raz. Inna treść → 422 IDEMPOTENCY_KEY_REUSED; żądanie jeszcze trwa → 409 IDEMPOTENCY_KEY_IN_USE. 1–100 znaków ASCII (np. UUID).
Treść żądania application/vnd.allegro.public.v1+json
offerId string wymaganeOferta konta demo (np. offers.sampleOfferId z GET /allee/sandbox).
quantity integer1–100.
paymentType stringONLINE, CASH_ON_DELIVERYstatus stringDo którego etapu doprowadzić zakup.
BOUGHT, FILLED_IN, READY_FOR_PROCESSINGdeliveryMethodId stringMetoda dostawy ze słownika.
invoice booleanKupujący chce faktury (NIP).
messageToSeller stringOdpowiedzi
201 Zamówienie (jak GET /order/checkout-forms/{id}). · CheckoutForm
id string · uuid zawszeIdentyfikator zamówienia (checkoutForm.id).
status string zawszeStatus zakupu. API pokazuje zamówienia od READY_FOR_PROCESSING.
BOUGHT, FILLED_IN, READY_FOR_PROCESSING, CANCELLEDupdatedAt string · date-time zawszerevision string zawszeRewizja (tekst) — rośnie przy każdej zmianie statusu; podaj w PUT …/fulfillment?checkoutForm.revision.
marketplace object zawszePola obiektu
id string zawszeallee-plmessageToSeller string · null zawszeWiadomość kupującego do sprzedawcy.
buyer object zawszePola obiektu
id string zawszeemail string · null zawszeE-mail kupującego (null bez zakresu allee:api:orders:pii dla nowych aplikacji).
login string zawszefirstName string · null zawszeZawsze null — imię i nazwisko odbiorcy są w delivery.address.
lastName string · null zawszecompanyName string · null zawszephoneNumber string · null zawszeguest boolean zawszepayment object zawszePola obiektu
id string · null zawszetype string zawszeONLINE, CASH_ON_DELIVERYprovider string · null zawszefinishedAt string · date-time · null zawszepaidAmount Money · null zawszeZapłacono (płatność online); null przy pobraniu.
Pola obiektu
amount string zawszeKwota z dwoma miejscami po przecinku, kropka dziesiętna.
currency string zawszeWaluta (allee.pl: tylko PLN).
PLNfulfillment object zawszePola obiektu
status FulfillmentStatus zawszeStatus realizacji (tylko do przodu).
NEW, PROCESSING, READY_FOR_SHIPMENT, READY_FOR_PICKUP, SENT, PICKED_UP, CANCELLED, SUSPENDED, RETURNEDshipmentSummary object zawszePola obiektu
lineItemsSent string zawszeNONE, SOME, ALLdelivery object zawszePola obiektu
method object zawszePola obiektu
id string · null zawszename string zawszeaddress object · null zawszeAdres dostawy (dane osobowe — patrz zakres orders:pii).
Pola obiektu
firstName string · null zawszelastName string · null zawszestreet string · null zawszecity string · null zawszezipCode string · null zawszecountryCode string · null zawszecompanyName string · null zawszephoneNumber string · null zawszepickupPoint object · null zawszePunkt odbioru (dziś zawsze null).
cost Money zawszeKoszt dostawy zapłacony przez kupującego.
Pola obiektu
amount string zawszeKwota z dwoma miejscami po przecinku, kropka dziesiętna.
currency string zawszeWaluta (allee.pl: tylko PLN).
PLNtime object · null zawszesmart boolean zawszecalculatedNumberOfPackages integer zawszeinvoice object zawszePola obiektu
required boolean zawszeCzy kupujący chce faktury (podał NIP).
address object · null zawszeDane do faktury (od 10.11 z adresem siedziby).
Pola obiektu
street string · nullUlica i numer (zerowane bez dostępu do danych kupujących).
city string · nullzipCode string · nullcountryCode string · nullcompany object zawszePola obiektu
name string · null zawszetaxId string · null zawszelineItems array<CheckoutFormLineItem> zawszePola obiektu
id string · uuid zawszeoffer object zawszePola obiektu
id string zawszename string zawszeexternal object · null zawszePola obiektu
id string zawszequantity integer zawszeoriginalPrice Money zawszeCena sprzed obniżki (Omnibus) albo równa price.
Pola obiektu
amount string zawszeKwota z dwoma miejscami po przecinku, kropka dziesiętna.
currency string zawszeWaluta (allee.pl: tylko PLN).
PLNprice Money zawszeCena jednostkowa zapłacona.
Pola obiektu
amount string zawszeKwota z dwoma miejscami po przecinku, kropka dziesiętna.
currency string zawszeWaluta (allee.pl: tylko PLN).
PLNtax object · null zawszeStawka VAT z oferty.
Pola obiektu
rate string · null zawszeboughtAt string · date-time zawszesummary object zawszePola obiektu
totalToPay Money zawszeDo zapłaty: produkty + dostawa.
Pola obiektu
amount string zawszeKwota z dwoma miejscami po przecinku, kropka dziesiętna.
currency string zawszeWaluta (allee.pl: tylko PLN).
PLNallee object zawszeRozszerzenia allee (10.11.2026).
Pola obiektu
test boolean zawszePłatność testowa (payment.provider TEST_BLIK) — nie księgować.
commission object zawszePola obiektu
amount string zawszeProwizja allee za zamówienie (dziś 0.00 — allee nie pobiera prowizji).
currency string zawszerate string zawszeStawka w procentach, np. „0.00”.
base string zawszePodstawa: cena × sztuki pozycji, bez kosztu dostawy.
PRODUCTSfinal boolean zawszetrue = kwota już się nie zmieni.
priceListVersion string zawszeWersja cennika allee użyta do wyliczenia.
Błędy
| HTTP | Kod | Znaczenie |
|---|---|---|
| 401 | invalid_token | Brak, zły, wygasły albo odwołany token lub klucz (format OAuth, nagłówek WWW-Authenticate). |
| 403 | ACCOUNT_INACTIVE | Konto sprzedawcy jest nieaktywne. |
| 403 | AccessDenied | Brak zakresu albo zasób innego sprzedawcy. |
| 403 | KEY_QUARANTINED | Kwarantanna: działa tylko odczyt (wykryto nietypowe użycie). |
| 403 | KEY_SUSPENDED | Klucz albo dostęp aplikacji wstrzymany (przez sprzedawcę albo ochronę). |
| 403 | SANDBOX_ONLY | Symulator sandboxu wywołany kluczem produkcyjnym. |
| 404 | NOT_FOUND | Nie ma takiego zasobu (albo należy do innego sprzedawcy — dla wątków, zwrotów i spraw odpowiedź jest ta sama). |
| 413 | PAYLOAD_TOO_LARGE | Treść żądania za duża (JSON 5 MB, faktura PDF 3 MB). |
| 415 | UNSUPPORTED_MEDIA_TYPE | Zły Content-Type treści. |
| 422 | DELIVERY_METHOD_NOT_FOUND | Metoda dostawy spoza słownika allee (path = pozycja). |
| 422 | JsonMappingException | Treść nie jest poprawnym JSON albo ma zły kształt (np. images jako obiekty). |
| 422 | VALIDATION_ERROR | Zła wartość parametru zapytania (400) albo pola treści (422); path wskazuje miejsce. |
| 429 | TOO_MANY_REQUESTS | Przekroczony limit (minutowy, grupy operacji albo IP). |
| 500 | INTERNAL_ERROR | Błąd serwera allee. |
| 503 | NOT_DEPLOYED | Funkcja jeszcze nie uruchomiona (np. sandbox, wsady). |
curl -sS -X POST "${ALLEE_API_URL:-https://api.allee.pl}/allee/sandbox/orders" \
-H "Authorization: Bearer $ALLEE_API_KEY" \
-H "Accept: application/vnd.allegro.public.v1+json" \
-H "Content-Type: application/vnd.allegro.public.v1+json" \
--data-binary @- \
-w '\nHTTP %{http_code}\n' <<'JSON'
{
"offerId": "900000000000021",
"quantity": 2,
"paymentType": "ONLINE",
"invoice": true,
"messageToSeller": "Proszę o staranne zapakowanie."
}
JSON<?php
// allee API: POST /allee/sandbox/orders (PHP 8, rozszerzenie curl)
$base = getenv('ALLEE_API_URL') ?: 'https://api.allee.pl';
$body = [
'offerId' => '900000000000021',
'quantity' => 2,
'paymentType' => 'ONLINE',
'invoice' => true,
'messageToSeller' => 'Proszę o staranne zapakowanie.',
];
$ch = curl_init($base . '/allee/sandbox/orders');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ALLEE_API_KEY'),
'Accept: application/vnd.allegro.public.v1+json',
'Content-Type: application/vnd.allegro.public.v1+json',
],
CURLOPT_POSTFIELDS => json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
CURLOPT_RETURNTRANSFER => true,
]);
$odp = curl_exec($ch);
echo 'HTTP ', curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $odp, "\n";# allee API: POST /allee/sandbox/orders (Python 3, biblioteka requests)
import os
import requests
BASE = os.environ.get("ALLEE_API_URL", "https://api.allee.pl")
headers = {
"Authorization": "Bearer " + os.environ["ALLEE_API_KEY"],
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
}
body = {
"offerId": "900000000000021",
"quantity": 2,
"paymentType": "ONLINE",
"invoice": True,
"messageToSeller": "Proszę o staranne zapakowanie.",
}
r = requests.request("POST", BASE + "/allee/sandbox/orders", headers=headers, json=body, timeout=60, allow_redirects=False)
print("HTTP", r.status_code)
print(r.text)// allee API: POST /allee/sandbox/orders (Node.js 18+, wbudowany fetch; plik .mjs)
const BASE = process.env.ALLEE_API_URL ?? "https://api.allee.pl";
const body = {
"offerId": "900000000000021",
"quantity": 2,
"paymentType": "ONLINE",
"invoice": true,
"messageToSeller": "Proszę o staranne zapakowanie."
};
const res = await fetch(`${BASE}/allee/sandbox/orders`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ALLEE_API_KEY}`,
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
},
body: JSON.stringify(body),
redirect: "manual",
});
console.log("HTTP", res.status);
console.log(await res.text());// allee API: POST /allee/sandbox/orders (C#, .NET 8+, HttpClient)
using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("ALLEE_API_URL") ?? "https://api.allee.pl";
using var http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
using var req = new HttpRequestMessage(new HttpMethod("POST"), baseUrl + "/allee/sandbox/orders");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("ALLEE_API_KEY"));
req.Headers.Accept.ParseAdd("application/vnd.allegro.public.v1+json");
var json = """
{
"offerId": "900000000000021",
"quantity": 2,
"paymentType": "ONLINE",
"invoice": true,
"messageToSeller": "Proszę o staranne zapakowanie."
}
""";
req.Content = new StringContent(json, Encoding.UTF8);
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.allegro.public.v1+json");
using var res = await http.SendAsync(req);
Console.WriteLine($"HTTP {(int)res.StatusCode}");
Console.WriteLine(await res.Content.ReadAsStringAsync());// allee API: POST /allee/sandbox/orders (Java 11+, java.net.http; uruchom: java Main.java)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String base = System.getenv().getOrDefault("ALLEE_API_URL", "https://api.allee.pl");
String body = """
{
"offerId": "900000000000021",
"quantity": 2,
"paymentType": "ONLINE",
"invoice": true,
"messageToSeller": "Proszę o staranne zapakowanie."
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/allee/sandbox/orders"))
.header("Authorization", "Bearer " + System.getenv("ALLEE_API_KEY"))
.header("Accept", "application/vnd.allegro.public.v1+json")
.header("Content-Type", "application/vnd.allegro.public.v1+json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
HttpResponse<String> res = http.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + res.statusCode());
System.out.println(res.body());
}
}// allee API: POST /allee/sandbox/orders (Go 1.20+, net/http; uruchom: go run main.go)
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
base := os.Getenv("ALLEE_API_URL")
if base == "" {
base = "https://api.allee.pl"
}
body := `{
"offerId": "900000000000021",
"quantity": 2,
"paymentType": "ONLINE",
"invoice": true,
"messageToSeller": "Proszę o staranne zapakowanie."
}`
req, err := http.NewRequest("POST", base+"/allee/sandbox/orders", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ALLEE_API_KEY"))
req.Header.Set("Accept", "application/vnd.allegro.public.v1+json")
req.Header.Set("Content-Type", "application/vnd.allegro.public.v1+json")
klient := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
res, err := klient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
dane, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("HTTP", res.StatusCode)
fmt.Println(string(dane))
}application/vnd.allegro.public.v1+json{
"id": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"status": "READY_FOR_PROCESSING",
"updatedAt": "2026-11-10T11:10:05.412Z",
"revision": "3",
"marketplace": {
"id": "allee-pl"
},
"messageToSeller": "Proszę o staranne zapakowanie.",
"buyer": {
"id": "4000000001",
"email": "[email protected]",
"login": "kupujacy_demo_4816f227",
"firstName": null,
"lastName": null,
"companyName": "Firma Przykładowa",
"phoneNumber": "+48 500 000 000",
"guest": false
},
"payment": {
"id": "sandbox-9ba7f15b-69a9-43f0-96dd-6fa7cfffc7cc",
"type": "ONLINE",
"provider": "SANDBOX",
"finishedAt": "2026-11-10T11:10:05.000Z",
"paidAmount": {
"amount": "98.79",
"currency": "PLN"
}
},
"fulfillment": {
"status": "NEW",
"shipmentSummary": {
"lineItemsSent": "NONE"
}
},
"delivery": {
"method": {
"id": "bd0e0bcb-10d1-4584-bf5b-ebd07a86e70f",
"name": "InPost Paczkomat 24/7"
},
"address": {
"firstName": "Jan",
"lastName": "Przykładowy",
"street": "ul. Przykładowa 1",
"city": "Warszawa",
"zipCode": "00-001",
"countryCode": "PL",
"companyName": "Firma Przykładowa",
"phoneNumber": "+48 500 000 000"
},
"pickupPoint": null,
"cost": {
"amount": "12.99",
"currency": "PLN"
},
"time": null,
"smart": false,
"calculatedNumberOfPackages": 1
},
"invoice": {
"required": true,
"address": {
"street": null,
"city": null,
"zipCode": null,
"countryCode": null,
"company": {
"name": "Firma Przykładowa",
"taxId": "1234563218"
}
}
},
"lineItems": [
{
"id": "2d9680b4-9cb7-4096-9428-8c1ceb2790c2",
"offer": {
"id": "900000000000021",
"name": "Podróż na Księżyc DVD wydanie kolekcjonerskie",
"external": {
"id": "FILM-21ef85-1"
}
},
"quantity": 2,
"originalPrice": {
"amount": "44.90",
"currency": "PLN"
},
"price": {
"amount": "42.90",
"currency": "PLN"
},
"tax": {
"rate": "23.00"
},
"boughtAt": "2026-11-10T11:10:05.411Z"
}
],
"summary": {
"totalToPay": {
"amount": "98.79",
"currency": "PLN"
}
},
"allee": {
"test": false,
"commission": {
"amount": "0.00",
"currency": "PLN",
"rate": "0.00",
"base": "PRODUCTS",
"final": true,
"priceListVersion": "2026-11-09"
}
}
}Przykład: Drugie zamówienie (pobranie)
curl -sS -X POST "${ALLEE_API_URL:-https://api.allee.pl}/allee/sandbox/orders" \
-H "Authorization: Bearer $ALLEE_API_KEY" \
-H "Accept: application/vnd.allegro.public.v1+json" \
-H "Content-Type: application/vnd.allegro.public.v1+json" \
--data-binary @- \
-w '\nHTTP %{http_code}\n' <<'JSON'
{
"offerId": "900000000000001",
"quantity": 1,
"paymentType": "CASH_ON_DELIVERY"
}
JSON<?php
// allee API: POST /allee/sandbox/orders (PHP 8, rozszerzenie curl)
$base = getenv('ALLEE_API_URL') ?: 'https://api.allee.pl';
$body = [
'offerId' => '900000000000001',
'quantity' => 1,
'paymentType' => 'CASH_ON_DELIVERY',
];
$ch = curl_init($base . '/allee/sandbox/orders');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ALLEE_API_KEY'),
'Accept: application/vnd.allegro.public.v1+json',
'Content-Type: application/vnd.allegro.public.v1+json',
],
CURLOPT_POSTFIELDS => json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
CURLOPT_RETURNTRANSFER => true,
]);
$odp = curl_exec($ch);
echo 'HTTP ', curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $odp, "\n";# allee API: POST /allee/sandbox/orders (Python 3, biblioteka requests)
import os
import requests
BASE = os.environ.get("ALLEE_API_URL", "https://api.allee.pl")
headers = {
"Authorization": "Bearer " + os.environ["ALLEE_API_KEY"],
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
}
body = {
"offerId": "900000000000001",
"quantity": 1,
"paymentType": "CASH_ON_DELIVERY",
}
r = requests.request("POST", BASE + "/allee/sandbox/orders", headers=headers, json=body, timeout=60, allow_redirects=False)
print("HTTP", r.status_code)
print(r.text)// allee API: POST /allee/sandbox/orders (Node.js 18+, wbudowany fetch; plik .mjs)
const BASE = process.env.ALLEE_API_URL ?? "https://api.allee.pl";
const body = {
"offerId": "900000000000001",
"quantity": 1,
"paymentType": "CASH_ON_DELIVERY"
};
const res = await fetch(`${BASE}/allee/sandbox/orders`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ALLEE_API_KEY}`,
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
},
body: JSON.stringify(body),
redirect: "manual",
});
console.log("HTTP", res.status);
console.log(await res.text());// allee API: POST /allee/sandbox/orders (C#, .NET 8+, HttpClient)
using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("ALLEE_API_URL") ?? "https://api.allee.pl";
using var http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
using var req = new HttpRequestMessage(new HttpMethod("POST"), baseUrl + "/allee/sandbox/orders");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("ALLEE_API_KEY"));
req.Headers.Accept.ParseAdd("application/vnd.allegro.public.v1+json");
var json = """
{
"offerId": "900000000000001",
"quantity": 1,
"paymentType": "CASH_ON_DELIVERY"
}
""";
req.Content = new StringContent(json, Encoding.UTF8);
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.allegro.public.v1+json");
using var res = await http.SendAsync(req);
Console.WriteLine($"HTTP {(int)res.StatusCode}");
Console.WriteLine(await res.Content.ReadAsStringAsync());// allee API: POST /allee/sandbox/orders (Java 11+, java.net.http; uruchom: java Main.java)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String base = System.getenv().getOrDefault("ALLEE_API_URL", "https://api.allee.pl");
String body = """
{
"offerId": "900000000000001",
"quantity": 1,
"paymentType": "CASH_ON_DELIVERY"
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/allee/sandbox/orders"))
.header("Authorization", "Bearer " + System.getenv("ALLEE_API_KEY"))
.header("Accept", "application/vnd.allegro.public.v1+json")
.header("Content-Type", "application/vnd.allegro.public.v1+json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
HttpResponse<String> res = http.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + res.statusCode());
System.out.println(res.body());
}
}// allee API: POST /allee/sandbox/orders (Go 1.20+, net/http; uruchom: go run main.go)
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
base := os.Getenv("ALLEE_API_URL")
if base == "" {
base = "https://api.allee.pl"
}
body := `{
"offerId": "900000000000001",
"quantity": 1,
"paymentType": "CASH_ON_DELIVERY"
}`
req, err := http.NewRequest("POST", base+"/allee/sandbox/orders", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ALLEE_API_KEY"))
req.Header.Set("Accept", "application/vnd.allegro.public.v1+json")
req.Header.Set("Content-Type", "application/vnd.allegro.public.v1+json")
klient := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
res, err := klient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
dane, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("HTTP", res.StatusCode)
fmt.Println(string(dane))
}application/vnd.allegro.public.v1+json{
"id": "718ce396-4940-431f-815e-7a51875c71df",
"status": "READY_FOR_PROCESSING",
"updatedAt": "2026-11-10T11:10:05.419Z",
"revision": "3",
"marketplace": {
"id": "allee-pl"
},
"messageToSeller": null,
"buyer": {
"id": "4000000001",
"email": "[email protected]",
"login": "kupujacy_demo_4816f227",
"firstName": null,
"lastName": null,
"companyName": null,
"phoneNumber": "+48 500 000 000",
"guest": false
},
"payment": {
"id": null,
"type": "CASH_ON_DELIVERY",
"provider": null,
"finishedAt": null,
"paidAmount": null
},
"fulfillment": {
"status": "NEW",
"shipmentSummary": {
"lineItemsSent": "NONE"
}
},
"delivery": {
"method": {
"id": "b79ba3f7-7782-4521-b863-eae15c6f58a4",
"name": "DHL POP (punkt odbioru)"
},
"address": {
"firstName": "Jan",
"lastName": "Przykładowy",
"street": "ul. Przykładowa 1",
"city": "Warszawa",
"zipCode": "00-001",
"countryCode": "PL",
"companyName": null,
"phoneNumber": "+48 500 000 000"
},
"pickupPoint": null,
"cost": {
"amount": "12.99",
"currency": "PLN"
},
"time": null,
"smart": false,
"calculatedNumberOfPackages": 1
},
"invoice": {
"required": false,
"address": null
},
"lineItems": [
{
"id": "3ce60978-f8b3-45de-9a31-6bf12fdc1417",
"offer": {
"id": "900000000000001",
"name": "Produkt demo 01 – Projekty wnętrz",
"external": {
"id": "DEMO-01"
}
},
"quantity": 1,
"originalPrice": {
"amount": "19.99",
"currency": "PLN"
},
"price": {
"amount": "19.99",
"currency": "PLN"
},
"tax": {
"rate": "23.00"
},
"boughtAt": "2026-11-10T11:10:05.418Z"
}
],
"summary": {
"totalToPay": {
"amount": "32.98",
"currency": "PLN"
}
},
"allee": {
"test": false,
"commission": {
"amount": "0.00",
"currency": "PLN",
"rate": "0.00",
"base": "PRODUCTS",
"final": true,
"priceListVersion": "2026-11-09"
}
}
}Symulacja zwrotu kupującego
POST /allee/sandbox/returns
tylko alleeallegro:api:orders:writelimit: write
Kupujący demo zgłasza zwrot zamówienia — wcześniej oznacz je jako wysłane (POST …/shipments + PUT …/fulfillment SENT), inaczej 422 ORDER_NOT_SENT.
Działa wyłącznie kluczem testowym (allee_sk_test_…) — klucz produkcyjny dostaje 403 SANDBOX_ONLY. Dane są fikcyjne i oddzielone od produkcji (osobna baza); odpowiedzi mają nagłówek X-Allee-Mode: test.
Zgodność: tylko allee — Allegro sandbox: zwrot testowy.
Uprawnienie: zakres allegro:api:orders:write.
Grupa limitu: write.
Nagłówki
Idempotency-Key stringOchrona przed podwójnym wykonaniem (jak Stripe/Amazon): powtórzony POST z tym samym kluczem i tą samą treścią w ciągu 24 h zwraca zapisaną odpowiedź z nagłówkiem Idempotent-Replayed: true i niczego nie wykonuje drugi raz. Inna treść → 422 IDEMPOTENCY_KEY_REUSED; żądanie jeszcze trwa → 409 IDEMPOTENCY_KEY_IN_USE. 1–100 znaków ASCII (np. UUID).
Treść żądania application/vnd.allegro.public.v1+json
checkoutFormId string wymaganeZamówienie wysłane (po SENT).
lineItems array<object>Pola obiektu
id string wymaganequantity integerreason stringPowód z listy formularza zwrotu allee.pl (inna wartość = „Bez podania przyczyny”).
Bez podania przyczyny, Nie spełnia oczekiwań, Zamówiłem przez pomyłkę, Znalazłem taniej, Inny wariant niż zamówiony, Inny powódOdpowiedzi
201 Zwrot. · SandboxReturnCreated
id string zawszereferenceNumber string zawszeorderId string zawszestatus string zawszeCREATEDBłędy
| HTTP | Kod | Znaczenie |
|---|---|---|
| 401 | invalid_token | Brak, zły, wygasły albo odwołany token lub klucz (format OAuth, nagłówek WWW-Authenticate). |
| 403 | ACCOUNT_INACTIVE | Konto sprzedawcy jest nieaktywne. |
| 403 | AccessDenied | Brak zakresu albo zasób innego sprzedawcy. |
| 403 | KEY_QUARANTINED | Kwarantanna: działa tylko odczyt (wykryto nietypowe użycie). |
| 403 | KEY_SUSPENDED | Klucz albo dostęp aplikacji wstrzymany (przez sprzedawcę albo ochronę). |
| 403 | SANDBOX_ONLY | Symulator sandboxu wywołany kluczem produkcyjnym. |
| 404 | NOT_FOUND | Nie ma takiego zasobu (albo należy do innego sprzedawcy — dla wątków, zwrotów i spraw odpowiedź jest ta sama). |
| 413 | PAYLOAD_TOO_LARGE | Treść żądania za duża (JSON 5 MB, faktura PDF 3 MB). |
| 415 | UNSUPPORTED_MEDIA_TYPE | Zły Content-Type treści. |
| 422 | JsonMappingException | Treść nie jest poprawnym JSON albo ma zły kształt (np. images jako obiekty). |
| 422 | ORDER_NOT_SENT | Sandbox: zwrot zamówienia, które nie było wysłane. |
| 422 | VALIDATION_ERROR | Zła wartość parametru zapytania (400) albo pola treści (422); path wskazuje miejsce. |
| 429 | TOO_MANY_REQUESTS | Przekroczony limit (minutowy, grupy operacji albo IP). |
| 500 | INTERNAL_ERROR | Błąd serwera allee. |
| 503 | NOT_DEPLOYED | Funkcja jeszcze nie uruchomiona (np. sandbox, wsady). |
curl -sS -X POST "${ALLEE_API_URL:-https://api.allee.pl}/allee/sandbox/returns" \
-H "Authorization: Bearer $ALLEE_API_KEY" \
-H "Accept: application/vnd.allegro.public.v1+json" \
-H "Content-Type: application/vnd.allegro.public.v1+json" \
--data-binary @- \
-w '\nHTTP %{http_code}\n' <<'JSON'
{
"checkoutFormId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"reason": "Nie spełnia oczekiwań"
}
JSON<?php
// allee API: POST /allee/sandbox/returns (PHP 8, rozszerzenie curl)
$base = getenv('ALLEE_API_URL') ?: 'https://api.allee.pl';
$body = [
'checkoutFormId' => '432810d0-4d26-4f39-ba5f-b89def4d4f92',
'reason' => 'Nie spełnia oczekiwań',
];
$ch = curl_init($base . '/allee/sandbox/returns');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ALLEE_API_KEY'),
'Accept: application/vnd.allegro.public.v1+json',
'Content-Type: application/vnd.allegro.public.v1+json',
],
CURLOPT_POSTFIELDS => json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
CURLOPT_RETURNTRANSFER => true,
]);
$odp = curl_exec($ch);
echo 'HTTP ', curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $odp, "\n";# allee API: POST /allee/sandbox/returns (Python 3, biblioteka requests)
import os
import requests
BASE = os.environ.get("ALLEE_API_URL", "https://api.allee.pl")
headers = {
"Authorization": "Bearer " + os.environ["ALLEE_API_KEY"],
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
}
body = {
"checkoutFormId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"reason": "Nie spełnia oczekiwań",
}
r = requests.request("POST", BASE + "/allee/sandbox/returns", headers=headers, json=body, timeout=60, allow_redirects=False)
print("HTTP", r.status_code)
print(r.text)// allee API: POST /allee/sandbox/returns (Node.js 18+, wbudowany fetch; plik .mjs)
const BASE = process.env.ALLEE_API_URL ?? "https://api.allee.pl";
const body = {
"checkoutFormId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"reason": "Nie spełnia oczekiwań"
};
const res = await fetch(`${BASE}/allee/sandbox/returns`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ALLEE_API_KEY}`,
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
},
body: JSON.stringify(body),
redirect: "manual",
});
console.log("HTTP", res.status);
console.log(await res.text());// allee API: POST /allee/sandbox/returns (C#, .NET 8+, HttpClient)
using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("ALLEE_API_URL") ?? "https://api.allee.pl";
using var http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
using var req = new HttpRequestMessage(new HttpMethod("POST"), baseUrl + "/allee/sandbox/returns");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("ALLEE_API_KEY"));
req.Headers.Accept.ParseAdd("application/vnd.allegro.public.v1+json");
var json = """
{
"checkoutFormId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"reason": "Nie spełnia oczekiwań"
}
""";
req.Content = new StringContent(json, Encoding.UTF8);
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.allegro.public.v1+json");
using var res = await http.SendAsync(req);
Console.WriteLine($"HTTP {(int)res.StatusCode}");
Console.WriteLine(await res.Content.ReadAsStringAsync());// allee API: POST /allee/sandbox/returns (Java 11+, java.net.http; uruchom: java Main.java)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String base = System.getenv().getOrDefault("ALLEE_API_URL", "https://api.allee.pl");
String body = """
{
"checkoutFormId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"reason": "Nie spełnia oczekiwań"
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/allee/sandbox/returns"))
.header("Authorization", "Bearer " + System.getenv("ALLEE_API_KEY"))
.header("Accept", "application/vnd.allegro.public.v1+json")
.header("Content-Type", "application/vnd.allegro.public.v1+json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
HttpResponse<String> res = http.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + res.statusCode());
System.out.println(res.body());
}
}// allee API: POST /allee/sandbox/returns (Go 1.20+, net/http; uruchom: go run main.go)
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
base := os.Getenv("ALLEE_API_URL")
if base == "" {
base = "https://api.allee.pl"
}
body := `{
"checkoutFormId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"reason": "Nie spełnia oczekiwań"
}`
req, err := http.NewRequest("POST", base+"/allee/sandbox/returns", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ALLEE_API_KEY"))
req.Header.Set("Accept", "application/vnd.allegro.public.v1+json")
req.Header.Set("Content-Type", "application/vnd.allegro.public.v1+json")
klient := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
res, err := klient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
dane, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("HTTP", res.StatusCode)
fmt.Println(string(dane))
}application/vnd.allegro.public.v1+json{
"id": "ZW-900000001",
"referenceNumber": "ZW-900000001",
"orderId": "432810d0-4d26-4f39-ba5f-b89def4d4f92",
"status": "CREATED"
}Przykład: wariant
curl -sS -X POST "${ALLEE_API_URL:-https://api.allee.pl}/allee/sandbox/returns" \
-H "Authorization: Bearer $ALLEE_API_KEY" \
-H "Accept: application/vnd.allegro.public.v1+json" \
-H "Content-Type: application/vnd.allegro.public.v1+json" \
--data-binary @- \
-w '\nHTTP %{http_code}\n' <<'JSON'
{
"checkoutFormId": "718ce396-4940-431f-815e-7a51875c71df",
"reason": "Inny wariant niż zamówiony"
}
JSON<?php
// allee API: POST /allee/sandbox/returns (PHP 8, rozszerzenie curl)
$base = getenv('ALLEE_API_URL') ?: 'https://api.allee.pl';
$body = [
'checkoutFormId' => '718ce396-4940-431f-815e-7a51875c71df',
'reason' => 'Inny wariant niż zamówiony',
];
$ch = curl_init($base . '/allee/sandbox/returns');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ALLEE_API_KEY'),
'Accept: application/vnd.allegro.public.v1+json',
'Content-Type: application/vnd.allegro.public.v1+json',
],
CURLOPT_POSTFIELDS => json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
CURLOPT_RETURNTRANSFER => true,
]);
$odp = curl_exec($ch);
echo 'HTTP ', curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $odp, "\n";# allee API: POST /allee/sandbox/returns (Python 3, biblioteka requests)
import os
import requests
BASE = os.environ.get("ALLEE_API_URL", "https://api.allee.pl")
headers = {
"Authorization": "Bearer " + os.environ["ALLEE_API_KEY"],
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
}
body = {
"checkoutFormId": "718ce396-4940-431f-815e-7a51875c71df",
"reason": "Inny wariant niż zamówiony",
}
r = requests.request("POST", BASE + "/allee/sandbox/returns", headers=headers, json=body, timeout=60, allow_redirects=False)
print("HTTP", r.status_code)
print(r.text)// allee API: POST /allee/sandbox/returns (Node.js 18+, wbudowany fetch; plik .mjs)
const BASE = process.env.ALLEE_API_URL ?? "https://api.allee.pl";
const body = {
"checkoutFormId": "718ce396-4940-431f-815e-7a51875c71df",
"reason": "Inny wariant niż zamówiony"
};
const res = await fetch(`${BASE}/allee/sandbox/returns`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ALLEE_API_KEY}`,
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
},
body: JSON.stringify(body),
redirect: "manual",
});
console.log("HTTP", res.status);
console.log(await res.text());// allee API: POST /allee/sandbox/returns (C#, .NET 8+, HttpClient)
using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("ALLEE_API_URL") ?? "https://api.allee.pl";
using var http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
using var req = new HttpRequestMessage(new HttpMethod("POST"), baseUrl + "/allee/sandbox/returns");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("ALLEE_API_KEY"));
req.Headers.Accept.ParseAdd("application/vnd.allegro.public.v1+json");
var json = """
{
"checkoutFormId": "718ce396-4940-431f-815e-7a51875c71df",
"reason": "Inny wariant niż zamówiony"
}
""";
req.Content = new StringContent(json, Encoding.UTF8);
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.allegro.public.v1+json");
using var res = await http.SendAsync(req);
Console.WriteLine($"HTTP {(int)res.StatusCode}");
Console.WriteLine(await res.Content.ReadAsStringAsync());// allee API: POST /allee/sandbox/returns (Java 11+, java.net.http; uruchom: java Main.java)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String base = System.getenv().getOrDefault("ALLEE_API_URL", "https://api.allee.pl");
String body = """
{
"checkoutFormId": "718ce396-4940-431f-815e-7a51875c71df",
"reason": "Inny wariant niż zamówiony"
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/allee/sandbox/returns"))
.header("Authorization", "Bearer " + System.getenv("ALLEE_API_KEY"))
.header("Accept", "application/vnd.allegro.public.v1+json")
.header("Content-Type", "application/vnd.allegro.public.v1+json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
HttpResponse<String> res = http.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + res.statusCode());
System.out.println(res.body());
}
}// allee API: POST /allee/sandbox/returns (Go 1.20+, net/http; uruchom: go run main.go)
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
base := os.Getenv("ALLEE_API_URL")
if base == "" {
base = "https://api.allee.pl"
}
body := `{
"checkoutFormId": "718ce396-4940-431f-815e-7a51875c71df",
"reason": "Inny wariant niż zamówiony"
}`
req, err := http.NewRequest("POST", base+"/allee/sandbox/returns", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ALLEE_API_KEY"))
req.Header.Set("Accept", "application/vnd.allegro.public.v1+json")
req.Header.Set("Content-Type", "application/vnd.allegro.public.v1+json")
klient := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
res, err := klient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
dane, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("HTTP", res.StatusCode)
fmt.Println(string(dane))
}application/vnd.allegro.public.v1+json{
"id": "ZW-900000002",
"referenceNumber": "ZW-900000002",
"orderId": "718ce396-4940-431f-815e-7a51875c71df",
"status": "CREATED"
}Symulacja wiadomości kupującego
POST /allee/sandbox/messages
tylko alleeallegro:api:messaginglimit: write
Pytanie kupującego demo o ofertę (offerId) albo wiadomość w sprawie zamówienia (checkoutFormId). Zakres messaging.
Działa wyłącznie kluczem testowym (allee_sk_test_…) — klucz produkcyjny dostaje 403 SANDBOX_ONLY. Dane są fikcyjne i oddzielone od produkcji (osobna baza); odpowiedzi mają nagłówek X-Allee-Mode: test.
Zgodność: tylko allee — Allegro sandbox: wiadomość testowa.
Uprawnienie: zakres allegro:api:messaging.
Grupa limitu: write.
Nagłówki
Idempotency-Key stringOchrona przed podwójnym wykonaniem (jak Stripe/Amazon): powtórzony POST z tym samym kluczem i tą samą treścią w ciągu 24 h zwraca zapisaną odpowiedź z nagłówkiem Idempotent-Replayed: true i niczego nie wykonuje drugi raz. Inna treść → 422 IDEMPOTENCY_KEY_REUSED; żądanie jeszcze trwa → 409 IDEMPOTENCY_KEY_IN_USE. 1–100 znaków ASCII (np. UUID).
Treść żądania application/vnd.allegro.public.v1+json
text string wymaganecheckoutFormId stringWiadomość w sprawie zamówienia…
offerId string…albo pytanie o ofertę.
Odpowiedzi
201 Wiadomość. · SandboxMessageCreated
thread IdRef zawszeOdwołanie po identyfikatorze.
Pola obiektu
id string zawszemessage IdRef zawszeOdwołanie po identyfikatorze.
Pola obiektu
id string zawszeBłędy
| HTTP | Kod | Znaczenie |
|---|---|---|
| 401 | invalid_token | Brak, zły, wygasły albo odwołany token lub klucz (format OAuth, nagłówek WWW-Authenticate). |
| 403 | ACCOUNT_INACTIVE | Konto sprzedawcy jest nieaktywne. |
| 403 | AccessDenied | Brak zakresu albo zasób innego sprzedawcy. |
| 403 | KEY_QUARANTINED | Kwarantanna: działa tylko odczyt (wykryto nietypowe użycie). |
| 403 | KEY_SUSPENDED | Klucz albo dostęp aplikacji wstrzymany (przez sprzedawcę albo ochronę). |
| 403 | SANDBOX_ONLY | Symulator sandboxu wywołany kluczem produkcyjnym. |
| 404 | NOT_FOUND | Nie ma takiego zasobu (albo należy do innego sprzedawcy — dla wątków, zwrotów i spraw odpowiedź jest ta sama). |
| 413 | PAYLOAD_TOO_LARGE | Treść żądania za duża (JSON 5 MB, faktura PDF 3 MB). |
| 415 | UNSUPPORTED_MEDIA_TYPE | Zły Content-Type treści. |
| 422 | JsonMappingException | Treść nie jest poprawnym JSON albo ma zły kształt (np. images jako obiekty). |
| 422 | VALIDATION_ERROR | Zła wartość parametru zapytania (400) albo pola treści (422); path wskazuje miejsce. |
| 429 | TOO_MANY_REQUESTS | Przekroczony limit (minutowy, grupy operacji albo IP). |
| 500 | INTERNAL_ERROR | Błąd serwera allee. |
| 503 | NOT_DEPLOYED | Funkcja jeszcze nie uruchomiona (np. sandbox, wsady). |
curl -sS -X POST "${ALLEE_API_URL:-https://api.allee.pl}/allee/sandbox/messages" \
-H "Authorization: Bearer $ALLEE_API_KEY" \
-H "Accept: application/vnd.allegro.public.v1+json" \
-H "Content-Type: application/vnd.allegro.public.v1+json" \
--data-binary @- \
-w '\nHTTP %{http_code}\n' <<'JSON'
{
"offerId": "900000000000021",
"text": "Czy płyta ma polski lektor?"
}
JSON<?php
// allee API: POST /allee/sandbox/messages (PHP 8, rozszerzenie curl)
$base = getenv('ALLEE_API_URL') ?: 'https://api.allee.pl';
$body = [
'offerId' => '900000000000021',
'text' => 'Czy płyta ma polski lektor?',
];
$ch = curl_init($base . '/allee/sandbox/messages');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ALLEE_API_KEY'),
'Accept: application/vnd.allegro.public.v1+json',
'Content-Type: application/vnd.allegro.public.v1+json',
],
CURLOPT_POSTFIELDS => json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
CURLOPT_RETURNTRANSFER => true,
]);
$odp = curl_exec($ch);
echo 'HTTP ', curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $odp, "\n";# allee API: POST /allee/sandbox/messages (Python 3, biblioteka requests)
import os
import requests
BASE = os.environ.get("ALLEE_API_URL", "https://api.allee.pl")
headers = {
"Authorization": "Bearer " + os.environ["ALLEE_API_KEY"],
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
}
body = {
"offerId": "900000000000021",
"text": "Czy płyta ma polski lektor?",
}
r = requests.request("POST", BASE + "/allee/sandbox/messages", headers=headers, json=body, timeout=60, allow_redirects=False)
print("HTTP", r.status_code)
print(r.text)// allee API: POST /allee/sandbox/messages (Node.js 18+, wbudowany fetch; plik .mjs)
const BASE = process.env.ALLEE_API_URL ?? "https://api.allee.pl";
const body = {
"offerId": "900000000000021",
"text": "Czy płyta ma polski lektor?"
};
const res = await fetch(`${BASE}/allee/sandbox/messages`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ALLEE_API_KEY}`,
"Accept": "application/vnd.allegro.public.v1+json",
"Content-Type": "application/vnd.allegro.public.v1+json",
},
body: JSON.stringify(body),
redirect: "manual",
});
console.log("HTTP", res.status);
console.log(await res.text());// allee API: POST /allee/sandbox/messages (C#, .NET 8+, HttpClient)
using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("ALLEE_API_URL") ?? "https://api.allee.pl";
using var http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
using var req = new HttpRequestMessage(new HttpMethod("POST"), baseUrl + "/allee/sandbox/messages");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("ALLEE_API_KEY"));
req.Headers.Accept.ParseAdd("application/vnd.allegro.public.v1+json");
var json = """
{
"offerId": "900000000000021",
"text": "Czy płyta ma polski lektor?"
}
""";
req.Content = new StringContent(json, Encoding.UTF8);
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.allegro.public.v1+json");
using var res = await http.SendAsync(req);
Console.WriteLine($"HTTP {(int)res.StatusCode}");
Console.WriteLine(await res.Content.ReadAsStringAsync());// allee API: POST /allee/sandbox/messages (Java 11+, java.net.http; uruchom: java Main.java)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String base = System.getenv().getOrDefault("ALLEE_API_URL", "https://api.allee.pl");
String body = """
{
"offerId": "900000000000021",
"text": "Czy płyta ma polski lektor?"
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/allee/sandbox/messages"))
.header("Authorization", "Bearer " + System.getenv("ALLEE_API_KEY"))
.header("Accept", "application/vnd.allegro.public.v1+json")
.header("Content-Type", "application/vnd.allegro.public.v1+json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
HttpResponse<String> res = http.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + res.statusCode());
System.out.println(res.body());
}
}// allee API: POST /allee/sandbox/messages (Go 1.20+, net/http; uruchom: go run main.go)
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
base := os.Getenv("ALLEE_API_URL")
if base == "" {
base = "https://api.allee.pl"
}
body := `{
"offerId": "900000000000021",
"text": "Czy płyta ma polski lektor?"
}`
req, err := http.NewRequest("POST", base+"/allee/sandbox/messages", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ALLEE_API_KEY"))
req.Header.Set("Accept", "application/vnd.allegro.public.v1+json")
req.Header.Set("Content-Type", "application/vnd.allegro.public.v1+json")
klient := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
res, err := klient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
dane, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("HTTP", res.StatusCode)
fmt.Println(string(dane))
}application/vnd.allegro.public.v1+json{
"thread": {
"id": "900000001"
},
"message": {
"id": "900000001"
}
}