{"openapi":"3.1.0","info":{"title":"Hermes Label Service","version":"2.0.0","description":"Creates Hermes Austria (myhermes.at) parcel labels. Authenticate with `X-API-Key: <key>` or `Authorization: Bearer <key>`."},"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"X-API-Key"}},"schemas":{"CountryRates":{"type":"object","properties":{"country":{"type":"string"},"currency":{"type":"string","enum":["EUR"]},"vat_included":{"type":"boolean","enum":[true]},"prices_cents":{"type":"object","properties":{"S":{"type":"integer"},"M":{"type":"integer"},"L":{"type":"integer"}},"required":["S","M","L"]},"class_limits_cm":{"type":"object","properties":{"S":{"type":"number"},"M":{"type":"number"},"L":{"type":"number"}},"required":["S","M","L"]},"max_weight_kg":{"type":"number"},"effective_from":{"type":"string"},"checked_at":{"type":"string"},"stale":{"type":"boolean"},"source_url":{"type":"string"},"restrictions":{"type":"array","items":{"type":"string"}}},"required":["country","currency","vat_included","prices_cents","class_limits_cm","max_weight_kg","effective_from","checked_at","stale","source_url","restrictions"]},"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}},"required":["error","message"]},"ParcelCalculation":{"type":"object","properties":{"parcel_class":{"type":"string","enum":["S","M","L"],"description":"Hermes parcel class: S (longest + shortest side up to 50 cm), M (80 cm), L (120 cm)","example":"S"},"longest_plus_shortest_cm":{"type":"number"},"weight_validated":{"type":"boolean"},"country":{"type":"string","nullable":true},"price_cents":{"type":"integer","nullable":true},"tariff":{"allOf":[{"$ref":"#/components/schemas/CountryRates"},{"nullable":true}]}},"required":["parcel_class","longest_plus_shortest_cm","weight_validated","country","price_cents","tariff"]},"CalculateParcelRequest":{"type":"object","properties":{"length_cm":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":120},"width_cm":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":120},"height_cm":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":120},"weight_kg":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":31.5},"country":{"type":"string"}},"required":["length_cm","width_cm","height_cm"]},"Health":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded"]},"version":{"type":"string"},"dry_run":{"type":"boolean"},"browser":{"type":"string","enum":["ok","error"]},"queue":{"type":"object","properties":{"queued":{"type":"number"},"running":{"type":"number"}},"required":["queued","running"]},"time":{"type":"string"}},"required":["status","version","dry_run","browser","queue","time"]},"Job":{"type":"object","properties":{"id":{"type":"string"},"batch_id":{"type":"string","nullable":true},"status":{"type":"string","enum":["queued","running","done","failed","cancelled"]},"reference":{"type":"string","nullable":true},"parcel_class":{"type":"string","enum":["S","M","L"],"description":"Hermes parcel class: S (longest + shortest side up to 50 cm), M (80 cm), L (120 cm)","example":"S"},"recipient_name":{"type":"string"},"dry_run":{"type":"boolean","description":"True if the service ran in DRY_RUN mode: form filled, nothing bought, no PDF"},"crop":{"type":"boolean","description":"Whether the label was laid out on 100×150 mm (request option). If cropping fails after checkout, the job fails but pdf_url serves the uncropped Hermes sheet."},"tracking_number":{"type":"string","nullable":true},"pdf_url":{"type":"string","nullable":true,"description":"Download link containing a per-label secret; no API key needed. Present when status is done, and on a failed job whose crop failed after checkout (then it serves the uncropped Hermes sheet)."},"error":{"type":"string","nullable":true},"error_stage":{"type":"string","nullable":true},"purchased":{"type":"boolean","description":"Conservative legacy flag: true if a label exists OR may exist. Use creation_state to distinguish confirmed and unknown results. Never automatically resubmit unknown results."},"creation_state":{"type":"string","enum":["not_created","unknown","created"]},"callback_url":{"type":"string","nullable":true},"callback_status":{"type":"string","nullable":true},"created_at":{"type":"string"},"started_at":{"type":"string","nullable":true},"finished_at":{"type":"string","nullable":true}},"required":["id","batch_id","status","reference","parcel_class","recipient_name","dry_run","crop","tracking_number","pdf_url","error","error_stage","purchased","creation_state","callback_url","callback_status","created_at","started_at","finished_at"]},"CreateLabelRequest":{"type":"object","properties":{"recipient":{"$ref":"#/components/schemas/Address"},"sender":{"type":"object","properties":{"firstname":{"type":"string","minLength":1,"maxLength":50,"example":"Max"},"lastname":{"type":"string","minLength":1,"maxLength":50,"example":"Mustermann"},"company":{"type":"string","maxLength":50,"example":"Example GmbH","description":"With a company, Hermes gets \"<firstname> <lastname>\" as first name: max 50 characters combined"},"street":{"type":"string","minLength":1,"maxLength":50,"example":"Hauptstraße"},"housenumber":{"type":"string","minLength":1,"maxLength":10,"example":"1"},"address_extra":{"type":"string","maxLength":50,"example":"Stiege 2, Tür 5"},"zipcode":{"type":"string","minLength":1,"maxLength":10,"example":"1010"},"city":{"type":"string","minLength":1,"maxLength":50,"example":"Wien"},"phone":{"type":"string","maxLength":20,"example":"+43 1 2345678"},"email":{"type":"string","maxLength":80,"format":"email","example":"max@example.com"}},"required":["firstname","lastname","street","housenumber","zipcode","city"],"description":"Optional sender override. Defaults to the SENDER_* configuration. Sender country is always AT."},"parcel_class":{"type":"string","enum":["S","M","L"],"default":"S","description":"Hermes parcel class: S (longest + shortest side up to 50 cm), M (80 cm), L (120 cm)","example":"S"},"weight_kg":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":31.5,"default":1,"example":1},"crop":{"type":"boolean","default":true,"description":"true (default): lay the label out on a 100×150 mm portrait page (AT/DE layouts, other countries fitted). false: keep the original Hermes PDF."},"reference":{"type":"string","maxLength":30,"example":"ORDER-12345","description":"Your own reference (max 30 chars). Sent to Hermes as reference number and echoed back."},"callback_url":{"type":"string","format":"uri","example":"https://shop.example.com/webhooks/hermes","description":"If set, the finished job (same JSON as GET /labels/{id}) is POSTed to this URL"}},"required":["recipient"]},"Address":{"type":"object","properties":{"country":{"type":"string","example":"AT","description":"ISO-2 country code supported by myhermes.at"},"firstname":{"type":"string","minLength":1,"maxLength":50,"example":"Max"},"lastname":{"type":"string","minLength":1,"maxLength":50,"example":"Mustermann"},"company":{"type":"string","maxLength":50,"example":"Example GmbH","description":"With a company, Hermes gets \"<firstname> <lastname>\" as first name: max 50 characters combined"},"street":{"type":"string","minLength":1,"maxLength":50,"example":"Hauptstraße"},"housenumber":{"type":"string","minLength":1,"maxLength":10,"example":"1"},"address_extra":{"type":"string","maxLength":50,"example":"Stiege 2, Tür 5"},"zipcode":{"type":"string","minLength":1,"maxLength":10,"example":"1010"},"city":{"type":"string","minLength":1,"maxLength":50,"example":"Wien"},"phone":{"type":"string","maxLength":20,"example":"+43 1 2345678"},"email":{"type":"string","maxLength":80,"format":"email","example":"max@example.com"}},"required":["country","firstname","lastname","street","housenumber","zipcode","city"]},"Batch":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["pending","done","failed","partially_done"]},"total":{"type":"number"},"done":{"type":"number"},"failed":{"type":"number"},"pdf_url":{"type":"string","nullable":true,"description":"Merged PDF of all finished labels; present once no job is queued or running"},"jobs":{"type":"array","items":{"$ref":"#/components/schemas/Job"}},"created_at":{"type":"string"}},"required":["id","status","total","done","failed","pdf_url","jobs","created_at"]},"CreateBatchRequest":{"type":"object","properties":{"labels":{"type":"array","items":{"$ref":"#/components/schemas/CreateLabelRequest"},"minItems":1,"maxItems":50}},"required":["labels"]}},"parameters":{}},"paths":{"/api/v1/rates":{"get":{"tags":["rates"],"summary":"Public cached online tariffs for all destinations","responses":{"200":{"description":"Rates in EUR cents, including VAT","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CountryRates"}}}}}}}},"/api/v1/rates/{country}":{"get":{"tags":["rates"],"summary":"Public cached tariffs for a destination","parameters":[{"schema":{"type":"string"},"required":true,"name":"country","in":"path"}],"responses":{"200":{"description":"Country rates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CountryRates"}}}},"400":{"description":"Unsupported country","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/rates/refresh":{"post":{"tags":["rates"],"security":[{"ApiKey":[]}],"summary":"Refresh tariffs from the public Hermes price page","responses":{"200":{"description":"Refreshed tariffs","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CountryRates"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Refresh failed; previous tariffs retained","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/parcels/calculate":{"post":{"tags":["rates"],"summary":"Calculate parcel class and optional destination price (public)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalculateParcelRequest"}}}},"responses":{"200":{"description":"Class and optional price; weight validated only if supplied with a country","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ParcelCalculation"}}}},"400":{"description":"Unsupported dimensions or weight","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/health":{"get":{"tags":["system"],"summary":"Service health (public)","responses":{"200":{"description":"Ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}},"503":{"description":"Browser unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/api/v1/labels":{"post":{"tags":["labels"],"summary":"Queue a label","description":"Returns immediately with the queued job. Poll GET /api/v1/labels/{id}, pass callback_url, or use ?wait=<seconds> (max 120) to block until the job finishes.","security":[{"ApiKey":[]}],"parameters":[{"schema":{"type":"integer","nullable":true,"minimum":0,"maximum":120,"default":0},"required":false,"name":"wait","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\x21-\\x7e]+$","description":"Required stable shipment/order key. Reuse on retries. Different payload with the same key returns 409; expired jobs return 410."},"required":true,"description":"Required stable shipment/order key. Reuse on retries. Different payload with the same key returns 409; expired jobs return 410.","name":"idempotency-key","in":"header"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateLabelRequest"}}}},"responses":{"200":{"description":"Job finished within the wait time","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"202":{"description":"Job queued (or still running after wait)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency key conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"Original job expired; no new label created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["labels"],"summary":"List recent jobs","security":[{"ApiKey":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":500,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Jobs, newest first","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Job"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/labels/{id}":{"get":{"tags":["labels"],"summary":"Get a job","security":[{"ApiKey":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Job","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["labels"],"summary":"Cancel a queued job","description":"Only jobs that have not started can be cancelled; a running job is never interrupted because a label may already have been created.","security":[{"ApiKey":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Cancelled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Job already started or finished","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/labels/{id}/pdf":{"get":{"tags":["labels"],"summary":"Download the label PDF","description":"Accepts either the API key or the per-item ?token=… contained in pdf_url.","security":[{"ApiKey":[]},{}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":false,"name":"token","in":"query"}],"responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found or no PDF yet","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/batches":{"post":{"tags":["batches"],"summary":"Queue several labels","description":"Jobs run one after another. GET /api/v1/batches/{id} reports progress and a merged PDF once all jobs finished.","security":[{"ApiKey":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\x21-\\x7e]+$","description":"Required stable shipment/order key. Reuse on retries. Different payload with the same key returns 409; expired jobs return 410."},"required":true,"description":"Required stable shipment/order key. Reuse on retries. Different payload with the same key returns 409; expired jobs return 410.","name":"idempotency-key","in":"header"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateBatchRequest"}}}},"responses":{"202":{"description":"Batch queued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Batch"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency key conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"Original batch expired; no labels created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/batches/{id}":{"get":{"tags":["batches"],"summary":"Get a batch","security":[{"ApiKey":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Batch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Batch"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/batches/{id}/pdf":{"get":{"tags":["batches"],"summary":"Download all finished labels of a batch as one PDF","description":"Accepts either the API key or the per-item ?token=… contained in pdf_url.","security":[{"ApiKey":[]},{}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":false,"name":"token","in":"query"}],"responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found or no PDF yet","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}