Skip to content

API keys ​

An organization API key connects a maker to flint-server without a keypair. Use one when the quoting key lives in a remote signer, HSM or custody service: the process that runs the SDK holds the API key, builds quotes and submits them, and only the signer ever touches the private key.

The same key works for spot and perps. For perps, see Quoting with an API key in the perps docs.

Create a key ​

Sign in to the maker dashboard and open Developer → API keys. Create a key with a label, copy the secret and store it with your other server secrets. It starts with flint_ and is shown once; the list shows only its prefix. An organization holds at most 20 keys.

To rotate, create the new key, deploy it, then revoke the old one. A revoked key stops working within about a minute, and open streams that use it end with an UNAUTHENTICATED error.

The TypeScript EmailAuthFlow manages keys with the same organization login:

ts
const keys = await auth.listApiKeys();
const { apiKey, key } = await auth.createApiKey("prod quoter");
console.log(key.prefix, key.createdAt);
await auth.revokeApiKey(keys[0].id);

createApiKey returns the secret in apiKey; the SDK never logs it. A key cannot create or revoke keys.

What a key can do ​

Keypair sessionAPI key
Maker reads and streams (balances, fills, stats, quotes)YesYes
Chain tip, transaction status, spread protect, session heartbeatYesYes
Maker.submit of a signed transactionYesYes, see below
start_quoting (the SDK signs)YesNo: use start_quoting_external
Create or revoke keysNoNo: use the dashboard or EmailAuthFlow

An API key proves no key possession, so flint-server checks every transaction it relays for one:

  • Every signature must verify. A missing or forged signature is INVALID_ARGUMENT.
  • A required signer must be a registered quoting authority of your spot maker, and no signer may be on the deny list. Otherwise the call is PERMISSION_DENIED.

The key shares your maker's rate limits with its keypair sessions.

Connect ​

Pass the key instead of a signer. No handshake runs, so nothing resolves your maker ID: pass it explicitly. Set your own Solana RPC endpoint too; the SDK reads the chain tip from it if flint-server's streams are unavailable.

rust
let quoter_pubkey: solana_sdk::pubkey::Pubkey = std::env::var("FLINT_QUOTER_PUBKEY")?.parse()?;
let maker = Maker::builder()
    .cluster(Cluster::mainnet())
    .api_key(std::env::var("FLINT_API_KEY")?)
    .maker_id(std::env::var("FLINT_MAKER_ID")?.parse()?)
    .quoter_pubkey(quoter_pubkey)
    .solana_rpc([std::env::var("SOLANA_RPC_URL")?])
    .build()
    .await?;
python
import os

import flint
from flint import spot

maker = await spot.Maker.connect(
    flint.ApiKey(os.environ["FLINT_API_KEY"]),
    flint.Cluster.mainnet(),
    maker_id=int(os.environ["FLINT_MAKER_ID"]),
    solana_rpc=[os.environ["SOLANA_RPC_URL"]],
)
ts
import { ApiKey } from "@superis-labs/flint";
import { Maker } from "@superis-labs/flint/spot";

const keyMaker = await Maker.connect({
  cluster: "mainnet",
  apiKey: new ApiKey(process.env.FLINT_API_KEY!),
});

In Rust, quoter_pubkey is the public key the quotes are signed with; it pays the transaction fees.

Quote with a remote signer ​

start_quoting_external starts a quoting core that holds only the quoter's public key. Build quotes as usual and commit them with commit_externally: the SDK packs each transaction and hands it to your submitter unsigned. The submitter signs tx.message with the remote signer and submits the signed transaction through flint-server with Maker.submit.

rust
use flint_sdk::spot::quoting::PendingTx;
use solana_sdk::signature::Signature;

async fn remote_sign(_message: &[u8]) -> flint_sdk::Result<Signature> {
    todo!("ask your signer to sign the message")
}

let mut core = maker.start_quoting_external().await?;
let submitter = {
    let maker = maker.clone();
    move |tx: PendingTx| {
        let maker = maker.clone();
        async move {
            let signature = remote_sign(&tx.message).await?;
            maker.submit(tx.signed_transaction(signature)?).await
        }
    }
};
let quote = QuoteBuilder::new().order_list("SOL", |m| {
    m.submit(Side::Buy, dec!(150.0), dec!(1.0))
        .submit(Side::Sell, dec!(160.0), dec!(1.0))
});
let mut receipt = quote.commit_externally(&mut core, &submitter).await?;
let outcome = tokio::time::timeout(Duration::from_secs(60), receipt.settled()).await??;
python
import os

from solders.pubkey import Pubkey
from solders.signature import Signature

import flint
from flint.spot.quoting import PendingTx


async def remote_sign(message: bytes) -> Signature:
    raise NotImplementedError("ask your signer to sign the message")


async def submit(tx: PendingTx) -> Signature:
    signature = await remote_sign(tx.message)
    return await maker.submit(tx.with_signature(signature))


core = await maker.start_quoting_external(
    quoter_pubkey=Pubkey.from_string(os.environ["FLINT_QUOTER_PUBKEY"]),
    program_id=flint.Cluster.mainnet().spot_program_id,
)
builder = core.builder()
builder.order_list(core.market("SOL")).submit("buy", price="150", size="1").submit(
    "sell", price="160", size="1"
)
receipt = await core.commit_externally(builder, submit)
outcome = await receipt.settled()

tx.with_signature(signature) (signed_transaction in Rust) checks that the signature signs the message for the quoter and returns the signed transaction; a wrong signature fails before anything is sent. The receipt settles from flint-server's transaction-status stream. For the submitter's return values, retries and receipts, see External submission.

The TypeScript SDK has no spot quoting core. Sign transactions with your own code and submit the bytes:

ts
declare const signedTransaction: Uint8Array;

const signature = await maker.submit(signedTransaction);
const receipt = await maker.submitAndConfirm(signedTransaction);

When the server refuses the key ​

  • A revoked key. Streams end with an AuthError of kind invalidated instead of reconnecting, and calls fail with UNAUTHENTICATED. Create a new key and reconnect.
  • A key created before dashboard keys. Keys whose secret doesn't start with flint_ only authorize maker reads. Submissions are refused, and the SDK reads the chain tip and confirms receipts over your Solana RPC instead. Create a dashboard key to submit through flint-server.
  • An older flint-server. The same RPC fallback applies to a server that predates API-key relay access.

Keep the key on a server ​

An API key acts for the whole organization. Don't put one in browser JavaScript or a mobile app, where anyone can read it; use EmailAuthFlow for user-facing apps. In the SDKs the key is redacted from logs and repr/Debug output.

Built on Solana