{"openapi":"3.1.0","info":{"title":"The Bulk API","version":"0.1.0","description":"Internal API behind thebulkexchange.com, written for its own front end. It is\nnot a stable public contract: routes and fields change without notice.\nVocabulary (Wantlist, Bulk, Collection, Deck, Incoming, Reservation, Exchange,\nMatch...) is defined in `/llms.txt`.\n\n**Authentication.** Scripts send an API key as `Authorization: Bearer tbx_...`. Keys are created in Settings, with read or read and write access. The website itself uses a NextAuth session cookie.\n\n**Four kinds of route.** `security: []` works signed out. `[{}, {session: []}, {apiKey: []}]` works signed out and personalises for a known caller. The default takes a session or a key. `[{session: []}]` takes a session only: a key is refused with 403.\n\n**Limits.** Rate limits count per client IP, per key, or per user on\n`/api/reservations/notify` and `/request`, and live in each server instance, so they are\napproximate. Over a limit a route answers 429. A user holds at most 10,000\nCards across their lists, and a batch carries at most 500.\n\n**CORS.** No CORS headers are set: browsers on other origins cannot call this\nAPI. Server-to-server callers are not affected.\n"},"servers":[{"url":"https://www.thebulkexchange.com"}],"security":[{"session":[]},{"apiKey":[]}],"tags":[{"name":"Cards","description":"The signed-in user's own Cards."},{"name":"Lists"},{"name":"Decks"},{"name":"Reservations and Exchanges"},{"name":"Users"},{"name":"API keys","description":"Managing keys needs a signed-in session."},{"name":"Connected apps","description":"OAuth for MCP clients such as Claude. Tokens work at `/api/mcp` and nowhere else. See `/llms.txt`."},{"name":"Public","description":"Profiles, the Directory and Communities."},{"name":"Card data","description":"Scryfall-backed card lookups, art and images."},{"name":"Auth"}],"paths":{"/api/cards":{"post":{"tags":["Cards"],"summary":"Add a Card to one of the user's lists","description":"Adding a Card with the same name, Printing, language, Quality and foil adds to its `qty`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CardInput"}}}},"responses":{"201":{"description":"The Card.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Card"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Cards"],"summary":"Delete a Card","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Deleted."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}},"patch":{"tags":["Cards"],"summary":"Edit a Card","description":"`deck_name` is refused on Bulk, and `incoming` outside the Collection.\nEither can merge the Card with an identical one, in which case the answer is\n`{ id, merged: true }` and the client should refetch.\n`reserved_for_user_id` takes a user id or a username.\n","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"card_name":{"type":"string"},"set_code":{"type":["string","null"]},"collector_number":{"type":["string","null"]},"image_uri":{"type":["string","null"]},"language":{"$ref":"#/components/schemas/Language"},"quality":{"$ref":"#/components/schemas/Quality"},"qty":{"type":"integer","minimum":1},"foil":{"type":"boolean"},"reserved_for_user_id":{"type":["string","null"]},"deck_name":{"type":["string","null"],"description":"Blank or null clears it."},"no_ub":{"type":"boolean"},"incoming":{"type":"boolean","description":"Collection only."},"tags":{"type":"array","items":{"type":"string"},"description":"Wantlist only. Replaces the Card's Tags; trimmed, one of each regardless of case, at most 20 of 40 characters."}}}}}},"responses":{"200":{"description":"The Card, or a merge notice.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Card"},{"type":"object","required":["id","merged"],"properties":{"id":{"type":"string"},"merged":{"const":true}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/batch":{"post":{"tags":["Cards"],"summary":"Add up to 500 Cards to a list","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["cards"],"properties":{"cards":{"type":"array","maxItems":500,"items":{"allOf":[{"$ref":"#/components/schemas/CardInput"},{"type":"object","properties":{"incoming":{"type":"boolean","description":"Collection only, and needs a Printing."}}}]}}}}}}},"responses":{"200":{"description":"Empty input: `{ created: 0, cards: [] }`."},"201":{"description":"`{ created, cards }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/batch-edit":{"post":{"tags":["Cards"],"summary":"Apply the same edit to up to 500 Cards","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids","changes"],"properties":{"ids":{"type":"array","maxItems":500,"items":{"type":"string","format":"uuid"}},"changes":{"type":"object","properties":{"language":{"$ref":"#/components/schemas/Language"},"quality":{"$ref":"#/components/schemas/Quality"},"foil":{"type":"boolean"},"qty":{"type":"integer","minimum":1},"deck_name":{"type":["string","null"],"description":"Absent leaves the Deck alone and null clears it."},"incoming":{"type":"boolean","description":"Collection only."},"add_tags":{"type":"array","items":{"type":"string"},"description":"Wantlist only. Added to each Card's own Tags."},"remove_tags":{"type":"array","items":{"type":"string"},"description":"Wantlist only. Taken from each Card's own Tags, regardless of case."}}}}}}}},"responses":{"200":{"description":"`{ updated }`. Ids the user does not own are skipped."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Cards"],"summary":"Delete up to 500 Cards","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","maxItems":500,"items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"`{ deleted }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/batch-update":{"post":{"tags":["Cards"],"summary":"Move up to 500 Cards to another Printing","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["updates"],"properties":{"updates":{"type":"array","maxItems":500,"items":{"type":"object","required":["id","set_code","collector_number","image_uri"],"properties":{"id":{"type":"string","format":"uuid"},"set_code":{"type":"string"},"collector_number":{"type":"string"},"image_uri":{"type":["string","null"]}}}}}}}}},"responses":{"200":{"description":"`{ updated }`. Ids the user does not own are skipped."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/binder":{"get":{"tags":["Cards"],"summary":"The sets the Collection holds, or one set's Binder","parameters":[{"name":"set","in":"query","schema":{"type":"string"},"description":"Absent: every set with its count. Present: that set's Cards."}],"responses":{"200":{"description":"`{ sets: { set_code, count }[] }` or `{ cards: Card[] }`."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/binder-slots":{"post":{"tags":["Card data"],"summary":"Art and names for slots of a set","description":"Slots missing from the printing cache are left out.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["set","collector_numbers"],"properties":{"set":{"type":"string"},"collector_numbers":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"`{ data: { name, collector_number, image_uri, scryfall_uri }[] }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/cards/clear":{"delete":{"tags":["Cards"],"summary":"Delete every Card of a list","parameters":[{"name":"type","in":"query","required":true,"schema":{"$ref":"#/components/schemas/ListType"}}],"responses":{"200":{"description":"`{ success: true, deleted }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}},"security":[{"session":[]}]}},"/api/cards/decks":{"get":{"tags":["Decks"],"summary":"The user's Decks as name suggestions","responses":{"200":{"description":"`{ name, url, status }[]`, most recently updated first."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/first-print-art":{"post":{"tags":["Card data"],"summary":"Art of each name's oldest Printing","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["names"],"properties":{"names":{"type":"array","maxItems":500,"items":{"type":"string"}}}}}}},"responses":{"200":{"description":"`{ art: Record<lower-case name, url> }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/incoming":{"post":{"tags":["Cards"],"summary":"Mark wants as ordered","description":"Each want leaves the Wantlist and joins the Collection as Incoming, keeping its Deck. Every want needs a Printing.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","minItems":1,"maxItems":500,"items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"`{ ordered }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/lookup":{"get":{"tags":["Card data"],"summary":"Printings by name, name and set, or set and collector number","description":"Reads the printing cache, then Scryfall on a miss.","parameters":[{"name":"name","in":"query","schema":{"type":"string"}},{"name":"set","in":"query","schema":{"type":"string"}},{"name":"cn","in":"query","schema":{"type":"string"},"description":"Collector number."}],"responses":{"200":{"description":"The matching Printings.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Printing"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/cards/random":{"get":{"tags":["Cards"],"summary":"Up to 4 random Collection Cards with art","responses":{"200":{"description":"`{ id, card_name, set_code, collector_number, image_uri }[]`."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/resolve":{"post":{"tags":["Card data"],"summary":"All Printings of up to 2,000 names","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["names"],"properties":{"names":{"type":"array","maxItems":2000,"items":{"type":"string"}}}}}}},"responses":{"200":{"description":"`{ results: { name, printings: Printing[] }[] }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/cards/search":{"get":{"tags":["Card data"],"summary":"Name autocomplete, or the Printings of an exact name","description":"Understands `set collector` queries such as `lea 161`. 30 requests a minute per IP. Under two characters answers empty lists.","security":[],"parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string"}},{"name":"exact","in":"query","schema":{"const":"true"},"description":"Return `printings` rather than `suggestions`."},{"name":"lang","in":"query","schema":{"const":"any"},"description":"Search every language."}],"responses":{"200":{"description":"`{ suggestions }` and/or `{ printings }`."},"429":{"$ref":"#/components/responses/TooMany"}}}},"/api/cards/sync":{"post":{"tags":["Cards"],"summary":"Make a list match an account of what the user holds","description":"Never touches a Card that is In a deck or Incoming. `removeMissing` deletes what the account omits.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["list_id","cards"],"properties":{"list_id":{"type":"string","format":"uuid"},"cards":{"type":"array","maxItems":500,"items":{"$ref":"#/components/schemas/CardInput"}},"settings":{"type":"object","properties":{"addNew":{"type":"boolean"},"removeMissing":{"type":"boolean"},"qtyStrategy":{"enum":["replace","accumulate","keep"]}}}}}}}},"responses":{"200":{"description":"`{ added, updated, removed }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/check":{"post":{"tags":["Decks"],"summary":"Check a Reference list against Bulk and Collection","description":"Writes no Card. Counts copies, not lines. Basic lands always count as held.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","maxLength":200000}}}}}},"responses":{"200":{"description":"One line per name, and where shortfalls would go.","content":{"application/json":{"schema":{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"needed":{"type":"integer"},"owned":{"type":"integer","description":"Capped at `needed`."},"short":{"type":"integer"},"holdings":{"type":"array","items":{"type":"object","properties":{"source":{"enum":["bulk","collection"]},"qty":{"type":"integer"},"deckName":{"type":["string","null"]}}}},"imageUri":{"type":["string","null"]},"isBasic":{"type":"boolean"}}}},"wantlist":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"alreadyWanted":{"type":"array","items":{"type":"string"}}}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks":{"get":{"tags":["Decks"],"summary":"The user's Decks with their progress","responses":{"200":{"description":"Most recently updated first.","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"url":{"type":["string","null"]},"refreshed_at":{"type":["string","null"],"format":"date-time"},"cover":{"type":["string","null"],"description":"The chosen cover image, else the art of a held copy of the list's first card."},"coverName":{"type":["string","null"],"description":"The list's first card, to look up its art when cover is null."},"progress":{"$ref":"#/components/schemas/DeckProgress"},"totals":{"$ref":"#/components/schemas/DeckTotals"},"surplus":{"type":"integer"},"listEmpty":{"type":"boolean"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"post":{"tags":["Decks"],"summary":"Keep a list as a Deck","description":"An Archidekt `url` with no `text` is Refreshed first.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","maxLength":100},"text":{"type":"string"},"url":{"type":["string","null"]}}}}}},"responses":{"201":{"description":"The Deck.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deck"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}":{"parameters":[{"$ref":"#/components/parameters/DeckId"}],"get":{"tags":["Decks"],"summary":"A Deck with where each of its cards sits","responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}},"patch":{"tags":["Decks"],"summary":"Rename a Deck, or change its link, list or cover","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":100},"text":{"type":"string"},"url":{"type":["string","null"]},"cover_uri":{"type":["string","null"],"description":"A Scryfall card image (cards.scryfall.io). null goes back to the first card's art."}}}}}},"responses":{"200":{"description":"The Deck.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deck"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Decks"],"summary":"Delete a Deck","responses":{"200":{"description":"`{ success: true }`."},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/build":{"post":{"tags":["Decks"],"summary":"Put copies into a Deck","parameters":[{"$ref":"#/components/parameters/DeckId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["assignments"],"properties":{"assignments":{"type":"array","items":{"type":"object","required":["cardId","qty"],"properties":{"cardId":{"type":"string","format":"uuid"},"qty":{"type":"integer","minimum":1},"receive":{"type":"boolean","description":"Mark the Incoming copies taken as received, even ones already in this Deck."}}}}}}}}},"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/shares":{"post":{"tags":["Decks"],"summary":"Share a card with another Deck","description":"Both Decks then count a received copy of the card sleeved in the other as held. With `cardId`, `qty` copies of that Card (default 1) are first put in the other Deck.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","withDeckId"],"properties":{"name":{"type":"string","description":"The card's English name, as on the Deck's list."},"withDeckId":{"type":"string","format":"uuid"},"cardId":{"type":"string","format":"uuid"},"qty":{"type":"integer","minimum":1}}}}}},"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Decks"],"summary":"Stop sharing a card","description":"This Deck stops counting copies held in other Decks. The other Decks keep their own share.","parameters":[{"$ref":"#/components/parameters/DeckId"},{"name":"name","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/traders":{"get":{"tags":["Decks"],"summary":"Who holds each card of a Deck's list in Bulk","description":"Same rules as the Directory: Visible Profiles only, and a reserved Bulk Card counts only for the Trader it is held for. Traders in your Community come first.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"responses":{"200":{"description":"Usernames by lowercased card name; a card nobody holds is absent.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/pins":{"put":{"tags":["Decks"],"summary":"Pin a card to one Printing","description":"Only copies of that Printing then count toward the card in this Deck, and wanting it wants that Printing. Pinning again replaces the pin.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","set_code","collector_number"],"properties":{"name":{"type":"string","description":"The card's English name, as on the Deck's list."},"set_code":{"type":"string"},"collector_number":{"type":"string"}}}}}},"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Decks"],"summary":"Unpin a card","description":"Any printing of the card counts toward this Deck again.","parameters":[{"$ref":"#/components/parameters/DeckId"},{"name":"name","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/copies":{"post":{"tags":["Decks"],"summary":"Record copies received or ordered for a Deck","description":"The copies join the Collection, in this Deck when `inDeck`, and wants For this Deck shrink by what arrived.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PrintingInput"},{"type":"object","properties":{"inDeck":{"type":"boolean"},"incoming":{"type":"boolean"}}}]}}}},"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/refresh":{"post":{"tags":["Decks"],"summary":"Replace a linked Deck's list from Archidekt","description":"A failed fetch forwards Archidekt's status and leaves the list as it was.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"responses":{"200":{"description":"`{ deck, view }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeckWithView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/unbuild":{"post":{"tags":["Decks"],"summary":"Take cards out of a Deck","description":"With neither field, every Card leaves the Deck. `cardIds` takes whole Cards, and `items` takes `qty` copies, splitting a Card if some stay.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"cardIds":{"type":"array","items":{"type":"string"}},"items":{"type":"array","items":{"type":"object","required":["cardId","qty"],"properties":{"cardId":{"type":"string"},"qty":{"type":"integer","minimum":1}}}}}}}}},"responses":{"200":{"description":"The Deck.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deck"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/decks/{id}/wantlist":{"post":{"tags":["Decks"],"summary":"Want what a Deck is missing","description":"With no `name`, every line for the copies held nowhere. With `name`, that card for everything it lacks. `board` narrows `name` to its line on the main deck (`main`) or Sideboard (`side`); `maybe` wants an Idea, the copies the Maybeboard names that are owned nowhere.","parameters":[{"$ref":"#/components/parameters/DeckId"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"board":{"type":"string","enum":["main","side","maybe"]}}}}}},"responses":{"200":{"description":"`{ added }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/lists":{"get":{"tags":["Lists"],"summary":"The user's lists with their Cards","description":"Creates the three lists on first read. Each Wantlist Card carries `available_count_*` and each Bulk Card `interested_count_*`.","parameters":[{"name":"type","in":"query","explode":true,"schema":{"type":"array","items":{"$ref":"#/components/schemas/ListType"}},"description":"Repeatable. Absent means all three."},{"name":"cards","in":"query","schema":{"const":"none"},"description":"Return `card_count` and an empty `cards`."}],"responses":{"200":{"description":"`List[]`, each with `cards` and `card_count`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/reservations":{"get":{"tags":["Reservations and Exchanges"],"summary":"Reservations by and for the user, grouped by person","responses":{"200":{"description":"`{ reserved_by_me, reserved_for_me }`, each `{ user_id, username, avatar_url, cards, exchange }[]`."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/reservations/notify":{"post":{"tags":["Reservations and Exchanges"],"summary":"Send a Trader a Notice that Cards are Reserved for them","description":"3 an hour per pair and 10 an hour per sender.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"One of the two.","properties":{"user_id":{"type":"string"},"username":{"type":"string"}}}}}},"responses":{"200":{"description":"`{ sent: true }` or `{ sent: false, reason: opted_out }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/reservations/request":{"post":{"tags":["Reservations and Exchanges"],"summary":"Ask a Trader to Reserve some of their Bulk Cards for you","description":"Emails the owner a list of the Cards; reserves nothing. At most 50 Cards. 3 an hour per pair and 10 an hour per sender.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["username","card_ids"],"properties":{"username":{"type":"string"},"card_ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":50}}}}}},"responses":{"200":{"description":"`{ sent: true }` or `{ sent: false, reason: opted_out }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/exchanges":{"post":{"tags":["Reservations and Exchanges"],"summary":"Confirm the caller's side of an Exchange","description":"When both sides have confirmed, the Exchange completes and the giver's Cards leave their Bulk.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["other_user_id","role"],"properties":{"other_user_id":{"type":"string","format":"uuid"},"role":{"enum":["giver","receiver"]},"card_ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"`{ id, giver_user_id, receiver_user_id, card_ids, giver_done, receiver_done, status }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Reservations and Exchanges"],"summary":"Withdraw the caller's confirmation","parameters":[{"name":"other_user_id","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"role","in":"query","required":true,"schema":{"enum":["giver","receiver"]}}],"responses":{"200":{"description":"`{ withdrawn: true, exchange }`, with `exchange` null once nothing is left."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/users":{"get":{"tags":["Users"],"summary":"The signed-in user","responses":{"200":{"description":"Their own record, contact details and settings included, never the password hash."},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}},"post":{"tags":["Users"],"summary":"Register","description":"5 attempts an hour per IP.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","password","email"],"properties":{"name":{"type":"string","minLength":3,"maxLength":30,"pattern":"^[a-zA-Z0-9_-]+$"},"password":{"type":"string","minLength":8,"maxLength":72},"discord_handle":{"type":"string","maxLength":100},"phone":{"type":"string","maxLength":30},"email":{"type":"string"},"contact_info_public":{"type":"boolean"},"community":{"type":"string","maxLength":100}}}}}},"responses":{"201":{"description":"`{ success: true, user }`."},"400":{"$ref":"#/components/responses/BadRequest"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}},"patch":{"tags":["Users"],"summary":"Update the signed-in user's Settings","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"discord_handle":{"type":["string","null"],"maxLength":100},"phone":{"type":["string","null"],"maxLength":30},"email":{"type":["string","null"]},"profile_public":{"type":"boolean"},"contact_info_public":{"type":"boolean"},"reservation_emails":{"type":"boolean"},"binder_sets":{"type":["array","null"],"maxItems":1000,"items":{"type":"string"}},"card_names":{"enum":["printed","fr"]},"show_prices":{"type":"boolean"},"cardmarket_prices_only":{"type":"boolean","description":"Cardmarket's EUR prices only, never TCGplayer's USD."},"community":{"type":["string","null"],"maxLength":100}}}}}},"responses":{"200":{"description":"The updated user."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}},"security":[{"session":[]}]},"delete":{"tags":["Users"],"summary":"Delete the account and everything in it","responses":{"200":{"description":"`{ success: true, message }`."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}},"security":[{"session":[]}]}},"/api/users/basic-lands":{"get":{"tags":["Users"],"summary":"List your basic land Printings","description":"The Printing each basic land shows in your Decks. A Deck's own pin still wins.","responses":{"200":{"description":"The chosen Printings.","content":{"application/json":{"schema":{"type":"object","description":"By lowercased basic land name. A basic with no entry shows its oldest printing.","additionalProperties":{"type":"object","properties":{"set_code":{"type":"string"},"collector_number":{"type":"string"},"image_uri":{"type":["string","null"]}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"put":{"tags":["Users"],"summary":"Choose a basic land's Printing","description":"Every Deck then shows this Printing for that basic land, unless the Deck pins its own. Choosing again replaces the choice.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","set_code","collector_number"],"properties":{"name":{"type":"string","enum":["Plains","Island","Swamp","Mountain","Forest","Wastes"]},"set_code":{"type":"string"},"collector_number":{"type":"string"}}}}}},"responses":{"200":{"description":"The chosen Printings.","content":{"application/json":{"schema":{"type":"object","description":"By lowercased basic land name. A basic with no entry shows its oldest printing.","additionalProperties":{"type":"object","properties":{"set_code":{"type":"string"},"collector_number":{"type":"string"},"image_uri":{"type":["string","null"]}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Users"],"summary":"Reset a basic land's Printing","description":"The basic land shows its oldest printing again.","parameters":[{"name":"name","in":"query","required":true,"schema":{"type":"string","enum":["Plains","Island","Swamp","Mountain","Forest","Wastes"]}}],"responses":{"200":{"description":"The chosen Printings.","content":{"application/json":{"schema":{"type":"object","description":"By lowercased basic land name. A basic with no entry shows its oldest printing.","additionalProperties":{"type":"object","properties":{"set_code":{"type":"string"},"collector_number":{"type":"string"},"image_uri":{"type":["string","null"]}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/avatar":{"post":{"tags":["Users"],"summary":"Upload an avatar","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["avatar"],"properties":{"avatar":{"type":"string","format":"binary","description":"JPEG, PNG, WebP or GIF, 2 MB at most."}}}}}},"responses":{"200":{"description":"`{ avatar_url }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}},"security":[{"session":[]}]},"delete":{"tags":["Users"],"summary":"Remove the avatar","responses":{"200":{"description":"`{ success: true }`."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}},"security":[{"session":[]}]}},"/api/users/export/{type}":{"get":{"tags":["Users"],"summary":"Export a list, or all of them, as CSV","parameters":[{"name":"type","in":"path","required":true,"schema":{"type":"string","enum":["wantlist","bulk","collection","all"]}}],"responses":{"200":{"description":"`card_name,set_code,collector_number,language,quality,qty,foil`. `all` exports every card the user owns (Bulk and Collection, no Wantlist), with a leading `list` column naming the list each row comes from.","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/password":{"patch":{"tags":["Users"],"summary":"Change the password","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["current_password","new_password"],"properties":{"current_password":{"type":"string"},"new_password":{"type":"string","minLength":8,"maxLength":72}}}}}},"responses":{"200":{"description":"`{ success: true }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}},"security":[{"session":[]}]}},"/api/users/search":{"get":{"tags":["Users"],"summary":"Find Traders by name","description":"Up to 10, the caller excluded. Searches every Trader, those whose Profile is not Visible included.","parameters":[{"name":"q","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"`{ id, name, avatar_url }[]`."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/public":{"get":{"tags":["Public"],"summary":"The Directory of Visible Profiles","description":"Each with list counts and their Match with the caller, both ways. Needs a session, despite the name.","responses":{"200":{"description":"Profiles with `name`, `community`, `contact_info_public`, list counts and match counts."},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/public/{username}":{"get":{"tags":["Public"],"summary":"A Trader's Profile with their Wantlist and Bulk","description":"Readable signed out. Signed in, Cards carry `matches_me`, and contact\ndetails appear when the owner opted in and both name the same Community.\n","security":[{},{"session":[]},{"apiKey":[]}],"parameters":[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"deck","in":"query","schema":{"type":"string"},"description":"Narrows the Wantlist to one Deck. A filter, not a gate."},{"name":"tag","in":"query","schema":{"type":"string"},"description":"Narrows the Wantlist to the Cards carrying one Tag and leaves Bulk out. A filter, not a gate."},{"name":"sets","in":"query","schema":{"type":"string"},"description":"Comma-separated set codes (`usg,ulg,uds`). Narrows the Wantlist to Cards pinned to one of them; Any set wants are left out. A filter, not a gate."}],"responses":{"200":{"description":"`{ user, lists, deck, tag, sets }`."},"403":{"description":"Profile not Visible: `{ error, private: true }`."},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/communities":{"get":{"tags":["Public"],"summary":"Communities with their Trader counts","description":"The 20 largest, or those starting with `q`.","security":[],"parameters":[{"name":"q","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"`{ name, trader_count }[]`. Empty on any failure."}}}},"/api/stats":{"get":{"tags":["Public"],"summary":"Site totals","description":"Cached for an hour.","security":[],"responses":{"200":{"description":"`{ user_count, card_count, community_count }`, all null on failure."}}}},"/api/search":{"get":{"tags":["Card data"],"summary":"Card search with the caller's copies","description":"120 requests a minute per IP. Signed in, the best result carries `myCards` and others carry `owned`.","security":[{},{"session":[]},{"apiKey":[]}],"parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"`{ best: { card, printings, hasMorePrintings, myCards } | null, others }`."},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooMany"}}}},"/api/scryfall":{"get":{"tags":["Card data"],"summary":"Cached Scryfall read, by intent","description":"1,000 requests a minute per IP. `batch=true` paces the call to Scryfall's 10 requests a second.","security":[],"parameters":[{"name":"intent","in":"query","required":true,"schema":{"enum":["printing","printed-name","printings","sets"]}},{"name":"set","in":"query","schema":{"type":"string"}},{"name":"cn","in":"query","schema":{"type":"string"}},{"name":"lang","in":"query","schema":{"type":"string"}},{"name":"name","in":"query","schema":{"type":"string"}},{"name":"page","in":"query","schema":{"type":"string"}},{"name":"batch","in":"query","schema":{"const":"true"}}],"responses":{"200":{"description":"Scryfall's own JSON."},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooMany"},"502":{"description":"Scryfall failed."}}},"post":{"tags":["Card data"],"summary":"Scryfall collection lookup","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["identifiers"],"properties":{"identifiers":{"type":"array","maxItems":75,"items":{"type":"object"}}}}}}},"responses":{"200":{"description":"Scryfall's own JSON."},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooMany"},"502":{"description":"Scryfall failed."}}}},"/api/archidekt":{"get":{"tags":["Card data"],"summary":"An Archidekt deck as list text","parameters":[{"name":"deck","in":"query","required":true,"schema":{"type":"string","pattern":"^\\d+$"}}],"responses":{"200":{"description":"`{ text }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/image-proxy":{"get":{"tags":["Card data"],"summary":"A cached Scryfall image","security":[],"parameters":[{"name":"url","in":"query","required":true,"schema":{"type":"string","format":"uri"},"description":"An https URL on a Scryfall image host."}],"responses":{"200":{"description":"The image.","content":{"image/*":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"403":{"description":"Not a Scryfall image URL."},"502":{"description":"The image could not be fetched."}}}},"/api/og":{"get":{"tags":["Public"],"summary":"A generated Open Graph image","security":[],"parameters":[{"name":"page","in":"query","schema":{"type":"string"}},{"name":"art","in":"query","schema":{"type":"string"}},{"name":"label","in":"query","schema":{"type":"string"}},{"name":"v","in":"query","schema":{"type":"string"}},{"name":"format","in":"query","schema":{"type":"string"}},{"name":"q","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"The image.","content":{"image/*":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/feedback":{"post":{"tags":["Public"],"summary":"Send feedback, which opens a GitHub issue","description":"3 an hour per IP. Signed in, the issue names the user.","security":[{},{"session":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type","description"],"properties":{"type":{"enum":["feedback","bug","feature"]},"description":{"type":"string","minLength":10,"maxLength":5000}}}}}},"responses":{"200":{"description":"`{ success: true, message, issueUrl? }`."},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooMany"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/auth/{nextauth}":{"parameters":[{"name":"nextauth","in":"path","required":true,"schema":{"type":"string"},"description":"NextAuth's own catch-all: session, csrf, signin, signout, callback."}],"get":{"tags":["Auth"],"summary":"NextAuth reads","security":[],"responses":{"200":{"description":"Depends on the NextAuth action."}}},"post":{"tags":["Auth"],"summary":"NextAuth writes","description":"Credentials sign-in is limited to 10 attempts a minute per IP.","security":[],"responses":{"200":{"description":"Depends on the NextAuth action."},"429":{"$ref":"#/components/responses/TooMany"}}}},"/api/auth/forgot-password":{"post":{"tags":["Auth"],"summary":"Email a reset link","description":"Answers the same whether or not the email exists. The link lasts 15 minutes.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string"}}}}}},"responses":{"200":{"description":"`{ ok: true }`."},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooMany"}}}},"/api/auth/reset-password":{"post":{"tags":["Auth"],"summary":"Set a new password from a reset link","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token","newPassword"],"properties":{"token":{"type":"string"},"newPassword":{"type":"string","minLength":8}}}}}},"responses":{"200":{"description":"`{ ok: true }`."},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooMany"}}}},"/api/keys":{"get":{"tags":["API keys"],"summary":"The user's API keys","description":"Newest first. Never returns a key itself.","security":[{"session":[]}],"responses":{"200":{"description":"`ApiKey[]`.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"500":{"$ref":"#/components/responses/ServerError"}}},"post":{"tags":["API keys"],"summary":"Create an API key","description":"The `secret` in the answer is never shown again. A user keeps at most 10 keys.","security":[{"session":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","scope"],"properties":{"name":{"type":"string","minLength":1,"maxLength":60},"scope":{"enum":["read","write"]},"expires_in_days":{"enum":[30,90,365,null],"default":90,"description":"Null lasts until revoked."}}}}}},"responses":{"201":{"description":"`{ key: ApiKey, secret }`."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/keys/{id}":{"delete":{"tags":["API keys"],"summary":"Revoke an API key","description":"It stops working at once.","security":[{"session":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"`{ success: true }`."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/mcp":{"get":{"tags":["Connected apps"],"summary":"The MCP server","description":"Takes an OAuth access token, not an API key. Speaks MCP over Streamable HTTP. Answers 401 with a `WWW-Authenticate` challenge naming `/.well-known/oauth-protected-resource/api/mcp`.","security":[],"responses":{"200":{"description":"An MCP response."},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Connected apps"],"summary":"The MCP server","description":"Takes an OAuth access token, not an API key. Speaks MCP over Streamable HTTP. Answers 401 with a `WWW-Authenticate` challenge naming `/.well-known/oauth-protected-resource/api/mcp`.","security":[],"responses":{"200":{"description":"An MCP response."},"401":{"$ref":"#/components/responses/Unauthorized"}}},"delete":{"tags":["Connected apps"],"summary":"The MCP server","description":"Takes an OAuth access token, not an API key. Speaks MCP over Streamable HTTP. Answers 401 with a `WWW-Authenticate` challenge naming `/.well-known/oauth-protected-resource/api/mcp`.","security":[],"responses":{"200":{"description":"An MCP response."},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/oauth/register":{"post":{"tags":["Connected apps"],"summary":"Register an OAuth client","description":"RFC 7591. Clients are public: PKCE stands in for a secret.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["redirect_uris"],"properties":{"client_name":{"type":"string","maxLength":100},"redirect_uris":{"type":"array","minItems":1,"maxItems":5,"items":{"type":"string"}}}}}}},"responses":{"201":{"description":"The client."},"400":{"$ref":"#/components/responses/BadRequest"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/oauth/token":{"post":{"tags":["Connected apps"],"summary":"Trade a code or a refresh token for tokens","security":[],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["grant_type","client_id"],"properties":{"grant_type":{"enum":["authorization_code","refresh_token"]},"client_id":{"type":"string"},"code":{"type":"string"},"redirect_uri":{"type":"string"},"code_verifier":{"type":"string"},"resource":{"type":"string"},"refresh_token":{"type":"string"}}}}}},"responses":{"200":{"description":"`{ access_token, token_type, expires_in, refresh_token, scope }`."},"400":{"description":"An OAuth error."},"401":{"description":"`invalid_client`: register again."},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/oauth/authorize":{"post":{"tags":["Connected apps"],"summary":"The consent screen's answer","description":"Posted by the form at `/oauth/authorize`, from this site only.","security":[{"session":[]}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["decision"],"properties":{"decision":{"enum":["read","write","deny"]}}}}}},"responses":{"303":{"description":"Back to the client, with a code or an error."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/api/oauth/connections":{"get":{"tags":["Connected apps"],"summary":"The apps connected to this account","security":[{"session":[]}],"responses":{"200":{"description":"`OAuthConnection[]`, newest first."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Connected apps"],"summary":"Disconnect an app","description":"Ends its tokens at once.","security":[{"session":[]}],"parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"`{ success: true }`."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}}},"components":{"securitySchemes":{"session":{"type":"apiKey","in":"cookie","name":"authjs.session-token","description":"NextAuth JWT cookie, `__Secure-authjs.session-token` over HTTPS."},"apiKey":{"type":"http","scheme":"bearer","description":"An API key from Settings. Read keys reach GET routes only."}},"parameters":{"DeckId":{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}},"responses":{"BadRequest":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"No valid session.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Not found or not the caller's.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Conflict":{"description":"Conflict with what exists.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"TooMany":{"description":"Rate or card limit reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"ServerError":{"description":"Unexpected failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"The key may not do this.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"ListType":{"enum":["wantlist","bulk","collection"]},"Language":{"enum":["fr","en"]},"Quality":{"enum":["Mint","Ex","Good","Played","Poor"]},"PrintingInput":{"type":"object","required":["card_name"],"properties":{"card_name":{"type":"string"},"set_code":{"type":["string","null"]},"collector_number":{"type":["string","null"]},"image_uri":{"type":["string","null"]},"language":{"$ref":"#/components/schemas/Language"},"quality":{"$ref":"#/components/schemas/Quality"},"qty":{"type":"integer","minimum":1},"foil":{"type":"boolean"}}},"CardInput":{"allOf":[{"$ref":"#/components/schemas/PrintingInput"},{"type":"object","required":["list_id"],"properties":{"list_id":{"type":"string","format":"uuid"},"no_ub":{"type":"boolean"}}}]},"Card":{"type":"object","required":["id","list_id","card_name","qty","foil"],"properties":{"id":{"type":"string","format":"uuid"},"list_id":{"type":"string","format":"uuid"},"card_name":{"type":"string"},"set_code":{"type":["string","null"],"description":"Null on an Any set want."},"collector_number":{"type":["string","null"]},"image_uri":{"type":["string","null"]},"language":{"$ref":"#/components/schemas/Language"},"quality":{"$ref":"#/components/schemas/Quality"},"qty":{"type":"integer"},"foil":{"type":"boolean"},"incoming":{"type":"boolean","description":"Collection only."},"no_ub":{"type":"boolean"},"deck_name":{"type":["string","null"],"description":"In a deck on the Collection and For a deck on the Wantlist."},"deck_url":{"type":["string","null"]},"reserved_for_user_id":{"type":["string","null"]},"reserved_for_username":{"type":["string","null"]},"available_count_exact":{"type":"integer","description":"Wantlist: Traders with this exact Printing in Bulk."},"available_count_any":{"type":"integer","description":"Wantlist: Traders with any Printing in Bulk."},"interested_count_exact":{"type":"integer","description":"Bulk: Traders wanting this exact Printing."},"interested_count_any":{"type":"integer","description":"Bulk: Traders wanting any Printing."},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"},"tags":{"type":"array","items":{"type":"string"},"description":"Wantlist only: free-text labels, independent of the Deck."}}},"Printing":{"type":"object","properties":{"name":{"type":"string"},"set":{"type":"string"},"set_name":{"type":"string"},"set_type":{"type":"string"},"collector_number":{"type":"string"},"image_uri":{"type":["string","null"]},"scryfall_uri":{"type":"string"},"released_at":{"type":"string"}}},"Deck":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"user_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"status":{"enum":["built","planned"],"description":"Legacy. Read `DeckProgress.stage`."},"list_text":{"type":"string"},"url":{"type":["string","null"]},"cover_uri":{"type":["string","null"],"description":"The cover chosen for the Decks page; null uses the first card's art."},"refreshed_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"DeckProgress":{"type":"object","properties":{"held":{"type":"integer","description":"Received and in the Deck. Basic lands always count."},"shared":{"type":"integer","description":"Part of held: copies sleeved in another Deck that this one shares."},"incoming":{"type":"integer"},"needed":{"type":"integer"},"stage":{"enum":["planned","in-progress","built"]}}},"DeckTotals":{"type":"object","properties":{"needed":{"type":"integer"},"inThisDeck":{"type":"integer"},"incoming":{"type":"integer"},"shared":{"type":"integer","description":"Received copies in other Decks that shared lines count as held."},"free":{"type":"integer"},"inOtherDecks":{"type":"integer"},"missing":{"type":"integer"}}},"DeckView":{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","description":"One card of the list, with every copy held.","properties":{"name":{"type":"string"},"displayName":{"type":"string"},"needed":{"type":"integer"},"isBasic":{"type":"boolean"},"imageUri":{"type":["string","null"]},"inThisDeck":{"type":"integer"},"incoming":{"type":"integer"},"isShared":{"type":"boolean","description":"Whether this Deck shares the card with the user's other Decks."},"shared":{"type":"array","description":"Received copies in other Decks counted as held here.","items":{"type":"object","properties":{"deck":{"type":"string"},"qty":{"type":"integer"}}}},"free":{"type":"integer"},"inOtherDecks":{"type":"array","items":{"type":"object","properties":{"deck":{"type":"string"},"qty":{"type":"integer"}}}},"missing":{"type":"integer"},"short":{"type":"integer"},"wantedQty":{"type":"integer"},"candidates":{"type":"array","items":{"type":"object"}},"copies":{"type":"array","items":{"type":"object"}}}}},"surplus":{"type":"array","items":{"type":"object"}},"totals":{"$ref":"#/components/schemas/DeckTotals"}}},"DeckWithView":{"type":"object","properties":{"deck":{"$ref":"#/components/schemas/Deck"},"view":{"$ref":"#/components/schemas/DeckView"}}},"ApiKey":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"key_prefix":{"type":"string"},"scope":{"enum":["read","write"]},"last_used_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"}}}}}}