# Quick Start

Register a user, create a wallet, then send a first transaction and follow it to a final status.

## Before You Start

You need your tenant's **API key** and **API secret**. `POST /v1/auth/register` and `POST /v1/auth/login` must be signed with HMAC; they return an `accessToken` that every other call in this guide sends as `Authorization: Bearer <accessToken>`. The API secret produces the signatures, so keep it on your server. Details: [Authentication](https://docs.aureahub.com/docs/authentication.md).

| Header | Value |
| --- | --- |
| x-tenant-api-key | Your tenant API key. |
| x-timestamp | Current Unix time in seconds. Requests more than 300 seconds away from the server clock are rejected. |
| x-signature | Hex-encoded HMAC-SHA256 of the signing string, keyed with your API secret. Each signature is accepted only once. |

The signing string is the HTTP method, the request path as sent (for example `/v1/auth/login`), the timestamp and the hex SHA-256 of the raw request body, joined with newlines:

```javascript
import { createHash, createHmac } from 'node:crypto';

function hmacHeaders(method, path, rawBody, apiKey, apiSecret) {
  const timestamp = Math.floor(Date.now() / 1000).toString();
  const bodyHash = createHash('sha256').update(rawBody || '').digest('hex');
  const signingString = [method, path, timestamp, bodyHash].join('\n');
  const signature = createHmac('sha256', apiSecret).update(signingString).digest('hex');
  return {
    'x-tenant-api-key': apiKey,
    'x-timestamp': timestamp,
    'x-signature': signature,
  };
}
```

## Step 1: Register

`username` (3–100 characters: letters, digits, `_`, `-`), `email` and `password` (at least 8 characters, with upper-case, lower-case and a digit) are required. Add `wallet: { option: "create", chain }` to create a wallet in the same call; `chain` is required with `option: "create"`.

```javascript
const API = 'https://api.aureahub.com';

const body = JSON.stringify({
  username: 'alice',
  email: 'alice@example.com',
  password: 'SecurePass123',
  wallet: { option: 'create', chain: 'gnosis' }, // use a chain enabled for your tenant
});

const res = await fetch(API + '/v1/auth/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    ...hmacHeaders('POST', '/v1/auth/register', body, API_KEY, API_SECRET),
  },
  body, // send exactly the bytes you signed
});

// 201 Created
const { accessToken, refreshToken, expiresIn, user, wallet } = await res.json();
```

The response includes a `wallet` only when one was created. On tenants that use MPC wallets, registration never creates one. Existing users sign in with `POST /v1/auth/login` (`username` and `password`, same three headers), which returns the same token fields. See [Register](https://docs.aureahub.com/docs/auth-register.md) and [Login](https://docs.aureahub.com/docs/auth-login.md).

## Step 2: Create a Wallet

Skip this step if registration returned a wallet. List the chains your tenant can use, then create a wallet on one of them.

```javascript
const auth = { Authorization: 'Bearer ' + accessToken };

// Chains with an enabled configuration and at least one active token for your tenant
const { chains } = await fetch(API + '/v1/tokens/meta/chains', { headers: auth })
  .then(r => r.json());
// chains: [{ id, name, chainId, nativeToken: { symbol, name, decimals } }, ...]

const created = await fetch(API + '/v1/wallets/', {
  method: 'POST',
  headers: { ...auth, 'Content-Type': 'application/json' },
  body: JSON.stringify({ chain: chains[0].id, name: 'Main wallet' }),
});

// 201 Created
const myWallet = await created.json();
// { id, chain, address, walletType, isPrimary, isTestnet, label, isWatchOnly, keyManagementScheme, createdAt, updatedAt }
```

The custody model comes from your tenant's configuration, not from this request. Check `keyManagementScheme`:

- `aes_single`, `sss_2of2_akv` — custodial: Aurea signs and submits sends.
- `client_side`, `client_side_pending`, `mpc_tss` — non-custodial: sends must be signed by the client.

Tenants that use MPC wallets get `400` from this endpoint and create wallets through the MPC key-generation flow instead. See [Create Wallet](https://docs.aureahub.com/docs/wallets-create.md).

## Step 3: Check Balance

```javascript
const balance = await fetch(API + '/v1/wallets/' + myWallet.id + '/balance', { headers: auth })
  .then(r => r.json());
// { walletId, address, chain, nativeBalance: { balance, symbol, decimals }, tokens: [...], lastUpdated }
```

> ⚠️ Balance values are formatted with the token's decimals, but transaction amounts must be integer strings in the smallest unit. Convert with `decimals` before sending — see [Amount Units](https://docs.aureahub.com/docs/amounts.md).

## Step 4: Send a Transaction

```javascript
const tx = await fetch(API + '/v1/transactions/', {
  method: 'POST',
  headers: { ...auth, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    walletId: myWallet.id,
    chain: myWallet.chain,
    toAddress: '0x52908400098527886E0F7030069857D2E4169EE7',
    amount: '10000000000000000', // 0.01 of an 18-decimal coin, in the smallest unit
  }),
}).then(r => r.json());
```

- **Custodial wallet:** `201` with `status: "pending"` and the on-chain `txHash` (EVM chains).
- **Non-custodial wallet:** `201` with `requiresClientSigning: true` and `txHash: null`. Sign the returned hash and broadcast it — follow [Sending a Transaction](https://docs.aureahub.com/docs/guide-send-transaction.md).

A decimal amount such as `"0.01"` is rejected with `400`. Full reference: [Create Transaction](https://docs.aureahub.com/docs/tx-create.md).

## Step 5: Track Status

```javascript
async function waitForFinalStatus(txId, { intervalMs = 5000, maxAttempts = 60 } = {}) {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    const s = await fetch(API + '/v1/transactions/' + txId + '/status', { headers: auth })
      .then(r => r.json());
    if (s.status === 'confirmed' || s.status === 'failed') return s;
    await new Promise(resolve => setTimeout(resolve, intervalMs));
  }
  throw new Error('Transaction still pending');
}

const final = await waitForFinalStatus(tx.id);
// { id, txHash, status, confirmations, blockNumber, blockTimestamp }
```

The status endpoint checks the chain and saves any change. See [Get Tx Status](https://docs.aureahub.com/docs/tx-status.md).

## Next Steps

- [Sending a Transaction](https://docs.aureahub.com/docs/guide-send-transaction.md) — Custodial, non-custodial and gasless token sends.
- [Supported Blockchains](https://docs.aureahub.com/docs/supported-blockchains.md) — How chains are enabled per tenant, and what each family supports.
- [Amount Units](https://docs.aureahub.com/docs/amounts.md) — Smallest-unit amounts and conversion helpers.
- [Unified Transaction Feed](https://docs.aureahub.com/docs/agg-tx-list.md) — Blockchain and the bank ramp activity in one list.
- [User Onboarding](https://docs.aureahub.com/docs/guide-user-onboarding.md) — Guide to onboarding users.
- [Non-Custodial Keys](https://docs.aureahub.com/docs/guide-non-custodial-keys.md) — Guide to client-held keys.
- [Token Swaps](https://docs.aureahub.com/docs/guide-swap.md) — Guide to the swap endpoints.
- [Fiat Pay-In](https://docs.aureahub.com/docs/guide-fiat-payin.md) — Guide to the bank ramp pay-ins.
- [Fiat Pay-Out](https://docs.aureahub.com/docs/guide-fiat-payout.md) — Guide to the bank ramp payouts.
- [DApps Browser](https://docs.aureahub.com/docs/guide-dapps.md) — Guide to the dApp endpoints.
- [Sandbox Playbook](https://docs.aureahub.com/docs/guide-sandbox-playbook.md) — Test run before production.

---

Web version: https://docs.aureahub.com/#quickstart
