Get API key

Authentication

How to authenticate with the Magma API using API keys, and how to accept the Terms before buying. Covers buyer and seller flows.

Magma authenticates requests in two ways depending on what you're trying to do:

  • API keys - required for any authenticated operation (buying with account.liquidity.*, managing offers, accepting orders as a seller, reading your own purchases or sales). To buy, the account must also have accepted the Amboss Terms of Service.
  • Session keys - issued when someone calls the deprecated root liquidity.buy or liquidity.create_subscription without an API key. They work as Bearer tokens for tracking that buyer's own orders.

The endpoint is the same for both:

https://magma.amboss.tech/graphql

1. API Keys

API keys are tied to your Amboss account and authorise every authenticated query and mutation.

Create a key

Generate one at account.amboss.tech/settings/api-keys. Treat it like a password - store it in your secret manager and never commit it to source control.

image

Send the key

Pass it as a Bearer token on every authenticated request.

Authorization: Bearer YOUR_API_KEY
curl -X POST https://magma.amboss.tech/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AMBOSS_API_KEY" \
  -d '{"query":"query { user { id email } }"}'
import { GraphQLClient } from "graphql-request";

const magma = new GraphQLClient("https://magma.amboss.tech/graphql", {
  headers: {
    Authorization: `Bearer ${process.env.AMBOSS_API_KEY}`,
  },
});

An API key with no Authorization header is treated as unauthenticated. Authenticated operations (user.*, market.offer.create, market.order.seller.*, etc.) will return an "Unauthorized token" error.


2. Accepting the Terms

account.liquidity.buy and account.liquidity.create_subscription need an API key from an account that has accepted the Amboss Terms of Service. Calls from an account that hasn't accepted fail with an error asking you to accept them. See Errors.

Accepting is a one-time step per account. Log in at magma.amboss.tech/settings/account and accept them there, or send this mutation with the account's API key:

mutation AcceptTerms {
  legal {
    accept(input: { terms_of_service: true }) {
      id
      terms_of_service
    }
  }
}

Only send legal.accept after the account owner has read and agreed to the Terms. Never accept them on someone else's behalf.

Check the current state with user.legal_acceptance:

query LegalAcceptance {
  user {
    legal_acceptance {
      terms_of_service
    }
  }
}

If Amboss publishes a new version of the Terms of Service, terms_of_service turns false and the account must accept again before the next order.


3. Session keys

The root liquidity.buy and liquidity.create_subscription mutations are deprecated and will be removed. Until then they work as before: called without an API key, they create a session account and return its key in account.session_key. They don't check the Terms. Use account.liquidity.buy and account.liquidity.create_subscription with an API key instead.

Session keys work as Bearer tokens, so those buyers can keep tracking their own orders:

Authorization: Bearer b65b867c345468a0a2e07b3b86aa3078

The Magma web app has no guest checkout. To buy there, log in first with an Amboss account (email) or a session key, both at account.amboss.tech. Before the first order, the web app asks you to accept the Terms of Service once.


4. What needs which credential

OperationAPI keySession keyAnonymous
market.liquidity.liquidity_per_usd (pricing)✅✅✅
market.offer.offers (browse listings)✅✅✅
market.offer.get_offer✅✅✅
node.node_info✅✅✅
account.liquidity.buy✅ (Terms accepted)✅ (Terms accepted)❌
account.liquidity.create_subscription✅ (Terms accepted)✅ (Terms accepted)❌
legal.accept✅✅❌
liquidity.buy / liquidity.create_subscription (deprecated)✅✅✅
user.market.orders.get_order✅✅ (own orders)❌
market.order.cancel✅✅ (own orders)❌
market.offer.create / update / toggle✅❌❌
market.order.seller.accept / reject / add_transaction✅❌❌
account.subscriptions.toggle✅✅ (own subs)❌
account.node.connect✅❌❌

5. Rotating a key

Revoke and recreate keys at account.amboss.tech/settings/api-keys. Revocation takes effect immediately. There's no live-rotation grace period, so deploy the new key first, then revoke the old one.


Next steps