{"openapi":"3.1.0","info":{"title":"Dearest Song order API","version":"1.0.0","summary":"Create a personal-song order on behalf of a person; they hear a 60-second preview on the confirmation page and pay only if they love it. Check GET /api/catalog launch_state first: preview_not_open means drafts/test only.","description":"The person hears a 60-second preview on the confirmation page before paying; the full song unlocks for download immediately after payment. Audio and length checks are automated, not a human listening review. Agents never pay on a person's behalf: the person opens checkout_url.","contact":{"name":"Спаркнес ЕООД","email":"hello@dearestsong.com","url":"https://dearestsong.com"},"termsOfService":"https://dearestsong.com/terms"},"servers":[{"url":"https://dearestsong.com"}],"paths":{"/api/catalog":{"get":{"operationId":"getCatalog","summary":"Products, add-ons, prices, delivery promise, and the allowed answer values.","responses":{"200":{"description":"Catalog","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/orders":{"post":{"operationId":"createOrder","summary":"Create an order and receive a checkout URL for the person to pay.","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":1,"maxLength":128},"description":"REQUIRED for agent orders (source=agent) and sent by our own form too: one unique key per intended order; a retry with the same key returns the existing order (200 + deduplicated) instead of creating a duplicate; the same key with a different body is a 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderInput"}}}},"responses":{"201":{"description":"Order created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCreated"}}}},"409":{"description":"Idempotency-Key reused with a different order body."},"422":{"description":"Validation failed; `issues` lists field paths and messages."},"503":{"description":"Ordering not open on this server (launch_state preview_not_open, or payments unconfigured)."}}}},"/api/orders/{id}/preview":{"get":{"operationId":"getPreviewState","summary":"Preview generation state; when ready, preview_audio_url plays the 60-second clip and lyrics carries the draft text.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Preview state","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["none","generating","ready","failed"]},"simulated":{"type":"boolean"},"preview_audio_url":{"type":["string","null"]},"lyrics":{"type":["string","null"]}}}}}},"404":{"description":"No such order"}}}},"/api/orders/{id}":{"get":{"operationId":"getOrderStatus","summary":"Status of an order (never the private answers).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Order status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderStatus"}}}},"404":{"description":"No such order"}}}}},"components":{"schemas":{"Answers":{"type":"object","required":["occasion","recipientName","relationship","fromName","threeWords","stories","message","style","voice"],"properties":{"occasion":{"type":"string","enum":["wedding","birthday","anniversary","memorial","retirement","other"]},"occasionDetails":{"type":"string","maxLength":160,"description":"Optional occasion in the buyer's own words; use occasion other for a custom occasion."},"recipientName":{"type":"string","maxLength":80,"description":"Who the song is for."},"pronunciation":{"type":"string","maxLength":500,"description":"Optional name pronunciation guidance, not words to sing."},"relationship":{"type":"string","maxLength":80,"description":"How the buyer knows them, e.g. 'my daughter'."},"fromName":{"type":"string","maxLength":120,"description":"Who the song is from, as it should appear in the lyrics."},"threeWords":{"type":"string","minLength":3,"maxLength":200,"description":"A few words that describe the person; exactly three words are not required."},"loves":{"type":"string","maxLength":600,"description":"What they love — hobbies, places, people, pets."},"stories":{"type":"string","minLength":20,"maxLength":4000,"description":"One specific memory or detail is enough; the buyer can add more."},"message":{"type":"string","minLength":5,"maxLength":1000,"description":"What the buyer wants the person to hear."},"avoid":{"type":"string","maxLength":500,"description":"Things the song must NOT mention (a person, a year, an illness)."},"style":{"type":"string","enum":["acoustic","piano","country","classic_pop","folk","gospel","swing","waltz","rocknroll","jazz"]},"voice":{"type":"string","enum":["female","male","duet"]},"language":{"type":"string","enum":["en"],"default":"en"},"neededBy":{"type":"string","format":"date","description":"YYYY-MM-DD, optional."},"notes":{"type":"string","maxLength":1500}}},"OrderInput":{"type":"object","required":["productId","email","answers","consent"],"properties":{"productId":{"type":"string","enum":["song"]},"addons":{"type":"array","maxItems":0,"items":{"type":"string"},"description":"No add-ons in the current offer."},"email":{"type":"string","format":"email","description":"The person's own email — receipt and human contact; the song is downloaded from the order page."},"phone":{"type":"string","maxLength":40},"answers":{"$ref":"#/components/schemas/Answers"},"source":{"type":"string","enum":["web","agent"],"default":"web"},"adCode":{"type":"string","pattern":"^(ad|xmas|reel|vid|post)_[a-z0-9]{1,8}$","description":"Optional first-party ad label for web orders. Invalid values are ignored; never send personal data. First order creation fixes this label; retries do not change it."},"agentName":{"type":"string","maxLength":120,"description":"Your assistant's name/version when source is 'agent'."},"consent":{"type":"boolean","const":true,"description":"The person asked you to place this order. The binding agreement itself happens when the person presses Agree on the confirmation page (checkout_url)."}}},"OrderCreated":{"type":"object","properties":{"order_id":{"type":"string"},"status":{"type":"string"},"amount_cents":{"type":"integer"},"currency":{"type":"string"},"checkout_url":{"type":"string","format":"uri","description":"The confirmation page (seller, price, deliverable, AI involvement, refund terms in plain words). The person reads it, presses Agree, and pays on Stripe Checkout themselves. Every order passes through it; unpaid orders expire after 48 hours."},"checkout_mode":{"type":"string","enum":["live","test","mock"]},"status_url":{"type":"string","format":"uri"},"preview_url":{"type":"string","format":"uri","description":"Poll for the 60-second preview state."},"next_step":{"type":"string"}}},"OrderStatus":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["pending_payment","paid","in_production","delivered","refunded","cancelled","disputed","disputed_lost","expired","test-only"],"description":"disputed: a payment dispute is open and the full download is paused until it closes. disputed_lost: the dispute closed in the card holder's favour and the download is closed."},"product_id":{"type":"string"},"addons":{"type":"array","items":{"type":"string"}},"amount_cents":{"type":"integer"},"currency":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"paid_at":{"type":["string","null"],"format":"date-time"},"full_ready":{"type":"boolean","description":"True once the full song file is rendered (post-payment)."},"delivery_promise":{"type":"string"}}}}}}