Skip to content
SwapWalletDocs
فارسیGet an API key

Authentication

Authenticate every request with your SwapWallet API key: how to create it, send it, replace it and keep it safe.

Every request is authenticated with your API key in the Authorization header. The key acts as your SwapWallet account, so anything it does is done by you.

Create a key

In the SwapWallet app, open Profile › API key and choose Create new key. Your key starts with apikey-. Copy it into your server’s secrets right away.

Send the key

Put the key after Bearer in the Authorization header of every request. Requests go over HTTPS to https://swapwallet.app/api.

HTTP
GET /api/v2/user/balance
Authorization: Bearer apikey-…

To confirm a key without touching anything, call Check your API key. A request with a missing, wrong or replaced key gets 401 with API_KEY_AUTHENTICATION_FAILED.

One endpoint needs no key at all: List market prices is public.

If you protect the app with a PIN code, requests made with your API key are refused with 400 PIN_CODE_REQUIRED. Use the API from an account without an app PIN.

Keys skip two-step confirmation

In the app, a withdrawal asks for an email, SMS or Google Authenticator code. A request made with an API key doesn’t, because a program can’t answer those prompts. That is what makes the key powerful, and why it must be treated like the password to your money.

Need a key that only works from your server’s IP, or that can read but not withdraw? Ask support for a key with custom limits.

Replace a key

Replace your key whenever someone who had it leaves, or if you think it leaked: in the app, Profile › API key › Replace with a new key. The old key stops working the moment you confirm, so deploy the new one right away.

Keep keys safe

  • Keep keys on the server. Never put one in a website, a mobile app or a Telegram mini app, where anyone can read it.
  • Read the key from an environment variable or a secrets manager, not from code, and keep it out of Git.
  • Don’t paste keys into chats, tickets or screenshots. SwapWallet support will never ask for one.
  • Anything done with your key is done by your account. If it leaks, replace it first and investigate after.