> ## Documentation Index
> Fetch the complete documentation index at: https://docs.altude.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Account

> Create a new account using a signed transaction

Create a new Solana account by submitting a signed transaction.

## headers

<ParamField header="X-API-Key" type="string" required>
  The API key created from [Altude](https://altude.so)
</ParamField>

## Request Body

<ParamField body="signedTransaction" type="string" required>
  The base64-encoded signed transaction to create the account
</ParamField>

## Build `signedTransaction` (minimum)

Use this right before calling `POST /Account/create`.

<Warning>
  Demo flow only. Never put fee payer private keys in frontend/client code. Keep signer keys on a trusted server-side signer.
</Warning>

```ts theme={null}
import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js';
import {
  AuthorityType,
  TOKEN_PROGRAM_ID,
  createAssociatedTokenAccountInstruction,
  createSetAuthorityInstruction,
  getAssociatedTokenAddress
} from '@solana/spl-token';

const apiKey = 'your-api-key';
const owner = new PublicKey('OWNER_PUBLIC_KEY');
const mint = new PublicKey('MINT_PUBLIC_KEY');
const feePayerSecret = [/* Solana secret key: array of 64 numbers (0-255) */];

function toBase64(bytes: Uint8Array) {
  let binary = '';
  const chunkSize = 0x8000;
  for (let i = 0; i < bytes.length; i += chunkSize) {
    binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
  }
  return btoa(binary);
}

const cfg = await fetch('https://api.altude.so/api/Transaction/config', {
  headers: { 'X-API-Key': apiKey }
}).then((r) => r.json());

const connection = new Connection(cfg.RpcUrl, 'confirmed');
const feePayer = new PublicKey(cfg.FeePayer);
const ata = await getAssociatedTokenAddress(mint, owner);

const tx = new Transaction();
tx.feePayer = feePayer;
tx.add(createAssociatedTokenAccountInstruction(feePayer, ata, owner, mint));
tx.add(
  createSetAuthorityInstruction(
    ata,
    owner,
    AuthorityType.CloseAccount,
    feePayer,
    [],
    TOKEN_PROGRAM_ID
  )
);
tx.recentBlockhash = (await connection.getLatestBlockhash('finalized')).blockhash;
tx.partialSign(Keypair.fromSecretKey(Uint8Array.from(feePayerSecret)));

const signedTransaction = toBase64(
  tx.serialize({ requireAllSignatures: false })
);

await fetch('https://api.altude.so/api/Account/create', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': apiKey
  },
  body: JSON.stringify({ signedTransaction })
});
```

## Response

<ResponseField name="status" type="string">
  The current state of the account creation request
</ResponseField>

<ResponseField name="message" type="string">
  A message describing the result of queuing the account creation transaction
</ResponseField>

<ResponseField name="signature" type="string">
  The transaction signature
</ResponseField>

<ResponseExample>
  ```json Response theme={null}
  {
    "status": "Queued",
    "message": "Account creation transaction queued successfully.",
    "signature": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
  }
  ```
</ResponseExample>
