{"openapi":"3.1.0","info":{"title":"SELTENLABS wallet API","version":"0.2.0","description":"Seamless wallet for game providers and webhooks of vendors. Base address `https://api.seltenlabs.com`.\n\nEvery wallet request is signed: header `X-Signature` is the hex HMAC-SHA256 of the raw request body with the secret of the provider. Amounts are integers in minor units of the currency. The idempotency key is the provider and `transaction_id`: a repeat with the same parameters returns the first result with `replay: true`, the same key with other parameters is `409 idempotency_conflict`.\n\nErrors are JSON `{\"error\": \"<code>\"}` with a stable code. Demo, no real money.\n\nReference with examples: https://api.seltenlabs.com/"},"servers":[{"url":"https://api.seltenlabs.com","description":"SELTENLABS API"}],"tags":[{"name":"system","description":"Service endpoints."},{"name":"kyc","description":"KYC cases and documents; the webhook of the KYC vendor."},{"name":"provider","description":"Seamless wallet of the built-in provider. Header `X-Signature`: hex HMAC-SHA256 of the raw body."}],"paths":{"/api/health":{"get":{"summary":"Health","operationId":"systemHealth","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"tags":["system"],"security":[]}},"/api/hooks/kyc/{code}":{"post":{"tags":["kyc"],"summary":"Webhook","description":"Vendor callback. Signed by the vendor; unsigned calls are refused and recorded.","operationId":"kycWebhook","parameters":[{"name":"code","in":"path","required":true,"schema":{"type":"string","title":"Code"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}},"security":[]}},"/api/provider/{provider}/balance":{"post":{"tags":["provider"],"summary":"Balance of the player","operationId":"providerBalance","parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string","title":"Provider"}}],"responses":{"200":{"description":"Done, or the stored answer to a repeat.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WalletBalance"},"example":{"balance":9500,"currency":"EUR","balance_version":7}}}},"400":{"description":"`error`: bad_request, currency_mismatch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_request"}}}},"401":{"description":"`error`: bad_signature.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_signature"}}}},"404":{"description":"`error`: unknown_provider, player_not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"unknown_provider"}}}}},"security":[{"providerSignature":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["player_id","currency"],"properties":{"player_id":{"type":"integer","description":"Player id on the platform."},"currency":{"type":"string","description":"ISO code; must be the currency of the player.","examples":["EUR"]}}},"example":{"player_id":42,"currency":"EUR"}}}}}},"/api/provider/{provider}/bet":{"post":{"tags":["provider"],"summary":"Bet: debit the amount","operationId":"providerBet","parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string","title":"Provider"}}],"responses":{"200":{"description":"Done, or the stored answer to a repeat.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WalletResult"},"example":{"transaction_id":318,"balance":9500,"balance_version":7,"currency":"EUR","replay":false,"status":"posted","round_id":12}}}},"400":{"description":"`error`: bad_request, bad_amount, currency_mismatch, bet_out_of_range.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_request"}}}},"401":{"description":"`error`: bad_signature.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_signature"}}}},"402":{"description":"`error`: insufficient_funds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"insufficient_funds"}}}},"403":{"description":"`error`: player_blocked, provider_disabled, ip_not_allowed, game_disabled, game_restricted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"player_blocked"}}}},"404":{"description":"`error`: unknown_provider, player_not_found, game_not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"unknown_provider"}}}},"409":{"description":"`error`: idempotency_conflict, transaction_rolled_back, round_closed, round_mismatch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"idempotency_conflict"}}}}},"security":[{"providerSignature":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["player_id","currency","amount","transaction_id","round_id","game_code"],"properties":{"player_id":{"type":"integer","description":"Player id on the platform."},"currency":{"type":"string","description":"ISO code; must be the currency of the player.","examples":["EUR"]},"amount":{"type":"integer","description":"Minor units of the currency."},"transaction_id":{"type":"string","description":"Id of this operation at the provider; the idempotency key."},"round_id":{"type":"string","description":"Id of the game round at the provider."},"game_code":{"type":"string","description":"Code of the game in the catalogue."}}},"example":{"player_id":42,"currency":"EUR","amount":500,"transaction_id":"tx-1001","round_id":"r-77","game_code":"demo-game-1"}}}}}},"/api/provider/{provider}/win":{"post":{"tags":["provider"],"summary":"Win: credit the amount","operationId":"providerWin","parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string","title":"Provider"}}],"responses":{"200":{"description":"Done, or the stored answer to a repeat.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WalletResult"},"example":{"transaction_id":320,"balance":10700,"balance_version":8,"currency":"EUR","replay":false,"status":"posted","round_id":12}}}},"400":{"description":"`error`: bad_request, bad_amount, currency_mismatch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_request"}}}},"401":{"description":"`error`: bad_signature.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_signature"}}}},"404":{"description":"`error`: unknown_provider, player_not_found, round_not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"unknown_provider"}}}},"409":{"description":"`error`: idempotency_conflict, round_closed, round_mismatch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"idempotency_conflict"}}}}},"security":[{"providerSignature":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["player_id","currency","amount","transaction_id","round_id"],"properties":{"player_id":{"type":"integer","description":"Player id on the platform."},"currency":{"type":"string","description":"ISO code; must be the currency of the player.","examples":["EUR"]},"amount":{"type":"integer","description":"Minor units of the currency."},"transaction_id":{"type":"string","description":"Id of this operation at the provider; the idempotency key."},"round_id":{"type":"string","description":"Id of the game round at the provider."},"finished":{"type":"boolean","default":true,"description":"The round is over: it is closed after this win."}}},"example":{"player_id":42,"currency":"EUR","amount":1200,"transaction_id":"tx-1002","round_id":"r-77","finished":true}}}}}},"/api/provider/{provider}/rollback":{"post":{"tags":["provider"],"summary":"Rollback of a bet","operationId":"providerRollback","parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string","title":"Provider"}}],"responses":{"200":{"description":"Done, or the stored answer to a repeat.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WalletResult"},"example":{"transaction_id":319,"balance":10000,"balance_version":8,"currency":"EUR","replay":false,"status":"posted"}}}},"400":{"description":"`error`: bad_request, currency_mismatch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_request"}}}},"401":{"description":"`error`: bad_signature.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_signature"}}}},"404":{"description":"`error`: unknown_provider, player_not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"unknown_provider"}}}},"409":{"description":"`error`: idempotency_conflict, rollback_not_allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"idempotency_conflict"}}}}},"security":[{"providerSignature":[]}],"description":"`status` is `posted`, `tombstone` (the bet is unknown: it will be refused if it arrives later) or `already_rolled_back`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["player_id","currency","transaction_id","ref_transaction_id"],"properties":{"player_id":{"type":"integer","description":"Player id on the platform."},"currency":{"type":"string","description":"ISO code; must be the currency of the player.","examples":["EUR"]},"transaction_id":{"type":"string","description":"Id of this operation at the provider; the idempotency key."},"ref_transaction_id":{"type":"string","description":"`transaction_id` of the bet to roll back."},"round_id":{"type":"string","description":"Id of the game round at the provider."}}},"example":{"player_id":42,"currency":"EUR","transaction_id":"tx-1003","ref_transaction_id":"tx-1001","round_id":"r-77"}}}}}}},"components":{"schemas":{"Error":{"type":"object","required":["error"],"additionalProperties":true,"properties":{"error":{"type":"string","description":"Stable machine code, the client translates it."},"fields":{"type":"array","items":{"type":"string"},"description":"With `bad_request`: fields that failed validation."},"permission":{"type":"string","description":"With `forbidden`: the missing permission."}},"example":{"error":"forbidden","permission":"players:edit"}},"WalletBalance":{"type":"object","required":["balance","currency","balance_version"],"properties":{"balance":{"type":"integer","description":"Minor units."},"currency":{"type":"string"},"balance_version":{"type":"integer","description":"Grows by one with every change of the balance."}}},"WalletResult":{"type":"object","required":["transaction_id","balance","balance_version","currency","replay","status"],"additionalProperties":true,"properties":{"transaction_id":{"type":"integer","description":"Id of the ledger transaction on the platform."},"balance":{"type":"integer","description":"Balance after the operation, minor units."},"balance_version":{"type":"integer"},"currency":{"type":"string"},"replay":{"type":"boolean","description":"True when this is the stored answer to a repeated request."},"status":{"type":"string"},"round_id":{"type":"integer","description":"Id of the round on the platform, when the operation belongs to one."}}}},"responses":{"BadRequest":{"description":"Validation or business rule failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"bad_request","fields":["amount"]}}}},"Unauthorized":{"description":"No session, the session has ended, or the signature is wrong.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"unauthorized"}}}},"Forbidden":{"description":"No permission, a wrong CSRF token, or the password must be changed first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"forbidden","permission":"players:edit"}}}}},"securitySchemes":{"providerSignature":{"type":"apiKey","in":"header","name":"X-Signature","description":"hex(hmac_sha256(secret, raw body))."}}}}