{"openapi":"3.1.0","info":{"title":"LongStories Partner API","version":"1","description":"Sell LongStories videos and pay in US dollars. Guide and examples: https://longstories.ai/resources/api.md (section Partner API).\n\nFor partners who resell LongStories videos and pay in US dollars. LongStories gives you a partner key; a normal API key is refused (`not_a_partner_key`).\n\nBase URL: `https://longstories.ai/api/partner/v1`. Send the key in the `x-api-key` header, from your server only.\n\nEvery answer is `{ data, requestId }`; an error is `{ error }`, with the same shape as the main API.\n\nPrices come from `GET /prices` and `POST /quotes`. Both need your key.\n\nA music video uses a song uploaded with `POST /api/v1/voiceover/upload` and your partner key.\n\nTest key: LongStories can give you a second key: a test key. With it, `POST /videos` checks and prices the request like a live key, with the same errors (`price_above_max` too). It charges nothing and makes no video. The test video is at once `completed` with a fixed sample MP4 and `charged_usd: 0`. Send `\"test_result\": \"failed\"` to get a `failed` video. Its webhook comes within a minute. With the test key, `GET /videos/{id}` reads test videos only, for 30 days. Prices, balance and quotes answer as with the live key."},"servers":[{"url":"https://longstories.ai/api/partner/v1"}],"security":[{"partnerKey":[]}],"paths":{"/prices":{"get":{"operationId":"partnerPrices","summary":"Prices","description":"The current price of each tier, resolution and video type, in USD a second.\n\nRate limit: 1,200 per minute per key, shared with balance and video reads.\n\nPrice = USD a second × seconds, rounded up to whole seconds, with `minimum_billing_seconds` as the minimum.\n\nPrices can change. Read them from your code (for example every 10 minutes); do not copy them by hand.","responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Prices"},"requestId":{"type":"string"}},"required":["data","requestId"]}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/balance":{"get":{"operationId":"partnerBalance","summary":"Balance","description":"Your prepaid balance in USD. A video's price leaves it when the video starts.\n\nRate limit: 1,200 per minute per key, shared with price and video reads.","responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Balance"},"requestId":{"type":"string"}},"required":["data","requestId"]}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/quotes":{"post":{"operationId":"partnerQuotes","summary":"Quote a video","description":"The exact price of one video. Free; nothing is charged.\n\nRate limit: 120 per minute per key, shared with new videos.\n\nA quote checks every field, the script or the song, and computes the price. The content rules and your balance are checked when you make the video.\n\nFor a script or a song, ask a quote: the length is measured first.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteRequest"}}}},"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Quote"},"requestId":{"type":"string"}},"required":["data","requestId"]}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/videos":{"post":{"operationId":"partnerVideosCreate","summary":"Make a video","description":"Starts a video and holds its price from your balance. Same body as the quote, plus `max_price_usd`.\n\nRate limit: 120 per minute per key, shared with quotes.\n\nThe answer has HTTP status `202`. Save `id`.\n\nThe call takes a few seconds, up to about 15 with many `characters`. Use a client timeout of 60 seconds.\n\nWhen the video is done, the held price is charged. When it fails, the price is given back.","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","maxLength":256},"description":"A unique id for this video, for example your order id, up to 256 characters. Send the same key and body again to retry: you get the same video and pay once. The same key with a different body is refused (`idempotency_key_reused`)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoRequest"}}}},"responses":{"202":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/VideoCreated"},"requestId":{"type":"string"}},"required":["data","requestId"]}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/videos/{id}":{"get":{"operationId":"partnerVideosStatus","summary":"Check a video","description":"Status, charge and the video link. Without a webhook, ask every 30 seconds until `completed` or `failed`.\n\nRate limit: 1,200 per minute per key, shared with price and balance reads.\n\n`status` is one of `queued`, `processing`, `completed`, `failed`. 10 of your videos are made at the same time; more wait as `queued`.\n\nA video usually takes 20 to 40 minutes. A long Pro video or a music video can take an hour.\n\n`charged_usd` is `null` while the video is made, the price when it is done, and `0` when it failed.\n\nThe `video_url` does not expire. Download the MP4 once and serve it from your own storage.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"The `id` that `POST /videos` returned."}],"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Video"},"requestId":{"type":"string"}},"required":["data","requestId"]}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{"videoEnded":{"post":{"operationId":"partnerVideoEnded","summary":"A video ended","security":[],"description":"Send `webhook_url` with `POST /videos`. When the video ends and its charge or refund is settled, LongStories POSTs JSON to that URL. Polling `GET /videos/{id}` still works.\n\nAnswer with any 2xx within 10 seconds. Otherwise LongStories tries again for about 10 hours.\n\nA call can come more than once. Use the event id to do the work once.\n\nCheck the signature on the raw body, before you parse it, and refuse a `t` older than 5 minutes.","parameters":[{"name":"LongStories-Event-Id","in":"header","required":true,"schema":{"type":"string"},"description":"The `id` of the body."},{"name":"LongStories-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<signature>`. The signature is the hex HMAC-SHA256 of `<t>.<raw body>` with your webhook secret, which LongStories gives you with your key."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Received. Answer within 10 seconds."}}}}},"components":{"securitySchemes":{"partnerKey":{"type":"apiKey","in":"header","name":"x-api-key"}},"schemas":{"QuoteRequest":{"type":"object","properties":{"end_user":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,64}$","description":"Your id for the user who orders the video: 1 to 64 letters, digits, `.` `_` `:` `-`. Send your internal id, not an email or a name."},"type":{"type":"string","enum":["story","music_video"],"description":"`story`: a video from an idea or a script. `music_video`: a video that follows an uploaded song."},"tier":{"type":"string","enum":["fast","pro","ultra"],"description":"The quality. `ultra` is for stories only."},"resolution":{"default":"480p","type":"string","enum":["480p","720p","1080p","4k"],"description":"The quality of the animated clips. `GET /prices` lists what each tier and type sells."},"aspect_ratio":{"default":"16:9","type":"string","enum":["9:16","16:9"],"description":"Horizontal (`16:9`) or vertical (`9:16`)."},"prompt":{"type":"string","minLength":1,"maxLength":5000,"description":"The idea, up to 5,000 characters. For a music video, it is optional and guides the look."},"script":{"type":"string","minLength":1,"maxLength":100000,"description":"A script in the [LongStories format](https://longstories.ai/resources/scripting-guide). The script sets the length. Do not send `duration_seconds` with it."},"duration_seconds":{"type":"integer","enum":[15,30,60,180,300,600],"description":"The length of a video from an idea, in seconds."},"song_upload_key":{"type":"string","minLength":1,"maxLength":512,"description":"The `voiceoverKey` of a song uploaded with `POST /api/v1/voiceover/upload` and the same key. The video is as long as the song."},"characters":{"maxItems":15,"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"description":{"type":"string","minLength":1,"maxLength":1000}},"required":["name","description"],"additionalProperties":false},"description":"With a `prompt`: up to 10 `{ \"name\", \"description\" }` that must be in the video. `name` up to 60 characters, `description` up to 1,000. Characters are not saved between videos."},"language":{"type":"string","minLength":2,"maxLength":5,"description":"The language of the narration and the dialogue, for example `en` or `es`. Recommended: without it, the language is detected first."}},"required":["end_user","type","tier"],"additionalProperties":false},"VideoRequest":{"type":"object","properties":{"end_user":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,64}$","description":"Your id for the user who orders the video: 1 to 64 letters, digits, `.` `_` `:` `-`. Send your internal id, not an email or a name."},"type":{"type":"string","enum":["story","music_video"],"description":"`story`: a video from an idea or a script. `music_video`: a video that follows an uploaded song."},"tier":{"type":"string","enum":["fast","pro","ultra"],"description":"The quality. `ultra` is for stories only."},"resolution":{"default":"480p","type":"string","enum":["480p","720p","1080p","4k"],"description":"The quality of the animated clips. `GET /prices` lists what each tier and type sells."},"aspect_ratio":{"default":"16:9","type":"string","enum":["9:16","16:9"],"description":"Horizontal (`16:9`) or vertical (`9:16`)."},"prompt":{"type":"string","minLength":1,"maxLength":5000,"description":"The idea, up to 5,000 characters. For a music video, it is optional and guides the look."},"script":{"type":"string","minLength":1,"maxLength":100000,"description":"A script in the [LongStories format](https://longstories.ai/resources/scripting-guide). The script sets the length. Do not send `duration_seconds` with it."},"duration_seconds":{"type":"integer","enum":[15,30,60,180,300,600],"description":"The length of a video from an idea, in seconds."},"song_upload_key":{"type":"string","minLength":1,"maxLength":512,"description":"The `voiceoverKey` of a song uploaded with `POST /api/v1/voiceover/upload` and the same key. The video is as long as the song."},"characters":{"maxItems":15,"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"description":{"type":"string","minLength":1,"maxLength":1000}},"required":["name","description"],"additionalProperties":false},"description":"With a `prompt`: up to 10 `{ \"name\", \"description\" }` that must be in the video. `name` up to 60 characters, `description` up to 1,000. Characters are not saved between videos."},"language":{"type":"string","minLength":2,"maxLength":5,"description":"The language of the narration and the dialogue, for example `en` or `es`. Recommended: without it, the language is detected first."},"max_price_usd":{"type":"number","exclusiveMinimum":0,"description":"The most your user agreed to pay, normally the quoted `price_usd`. A higher price is refused with `price_above_max` and charges nothing."},"webhook_url":{"type":"string","maxLength":2048,"format":"uri","description":"An https URL, up to 2,048 characters. It gets a signed call when the video ends (see Webhooks)."},"test_result":{"type":"string","enum":["completed","failed"],"description":"Test keys only: how the free sample video ends. Default: `completed`. A live key that sends it gets a 400."}},"required":["end_user","type","tier","max_price_usd"],"additionalProperties":false},"Prices":{"type":"object","properties":{"version":{"type":"string","description":"The price version. When it changes, the prices changed."},"minimum_billing_seconds":{"type":"integer","description":"A shorter video is billed as this many seconds."},"max_video_seconds":{"type":"integer","description":"The longest video you can order."},"prices":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["story","music_video"]},"tier":{"type":"string"},"resolution":{"type":"string"},"usd_per_second":{"type":"number","description":"USD a second of finished video."}},"required":["type","tier","resolution","usd_per_second"]}}},"required":["version","minimum_billing_seconds","max_video_seconds","prices"]},"Balance":{"type":"object","properties":{"balance_usd":{"type":"number","description":"What you can still spend, in USD."}},"required":["balance_usd"]},"Quote":{"type":"object","properties":{"price_usd":{"type":"number","description":"The exact price of the video."},"usd_per_second":{"type":"number","description":"The price of one second."},"billing_seconds":{"type":"integer","description":"The seconds billed (at least `minimum_billing_seconds`)."}},"required":["price_usd","usd_per_second","billing_seconds"]},"VideoCreated":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"The video id for every later call."},"status":{"type":"string","enum":["queued","processing","completed","failed"]},"end_user":{"type":"string"},"price_usd":{"type":"number","description":"The price held from your balance."}},"required":["id","status","end_user","price_usd"]},"Video":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["queued","processing","completed","failed"]},"end_user":{"type":["string","null"]},"price_usd":{"type":"number","description":"The price of the video."},"charged_usd":{"type":["number","null"],"description":"`null` while the video is made, the price when it is done, `0` when it failed."},"video_url":{"type":["string","null"],"description":"The MP4, when `completed`."},"duration_seconds":{"type":["number","null"],"description":"The film's length, when `completed`."},"error":{"type":["object","null"],"description":"When `failed`: `code` is `generation_failed`.","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","status","end_user","price_usd","charged_usd","video_url","duration_seconds","error","created_at","updated_at"]},"WebhookEvent":{"type":"object","properties":{"id":{"type":"string","description":"`<video id>:<type>`. Use it to find a call that came twice."},"type":{"type":"string","enum":["video.completed","video.failed"]},"created_at":{"type":"string","format":"date-time"},"data":{"$ref":"#/components/schemas/Video"}},"required":["id","type","created_at","data"]},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"details":{"type":"object"},"docs":{"type":"string"}},"required":["code","message"]}}}}}}