There was an error while loading. Please reload this page.
The endpoint /api/decks/submit accepts POST data in the form of a JSON document. If a new deck is being submitted, the deck ID is omitted.
/api/decks/submit
POST
{ "name": "Jawa X-Wings of DOOM", "description": "This deck has never lost... because I never use it.", "strategy": "Deploy Jawas into X-wings. What else?", "is_light_side": true, "is_public": true, "cards": [ { "id": 15, "deck_count": 1, "start_count": 0 }, { "id": 200, "deck_count": 1, "start_count": 0 }, { "id": 438, "deck_count": 2, "start_count": 0 }, { "id": 505, "deck_count": 1, "start_count": 0 } ] }
If an existing deck is being edited, the deck ID is included.
{ "deck_id": 78, "name": "Jawa X-Wings of DOOM", "description": "This deck has never lost... because I never use it.", "strategy": "Deploy Jawas into X-wings. What else?", "is_light_side": true, "is_public": true, "cards": [ { "id": 15, "deck_count": 1, "start_count": 0 }, { "id": 200, "deck_count": 1, "start_count": 0 }, { "id": 438, "deck_count": 1, "start_count": 0 }, { "id": 679, "deck_count": 2, "start_count": 0 } ] }
Deck updates use SQL transactions to simplify the process and ensure that the entire update succeeds or fails as a whole.
BEGIN TRANSACTION UPDATE decks SET ... WHERE deck_id = 78; DELETE FROM deck_cards WHERE deck_id = 78; INSERT INTO deck_cards ...; COMMIT
If the transaction succeeds, it returns status 200; otherwise it returns status 500 and performs a rollback.
200
500