Authentication & Tokens

Generate API Token

Select a method to generate a new secure token.

Expiration Policy
If you are generating a token via the Dashboard interface, you do not need to use these. They are alternative methods for specific programmatic use cases.
javascript
const response = await fetch('https://i-love-surreal.aws-euw1.surreal.cloud/', {
  method: 'POST',
  body: JSON.stringify({
    ns: 'main',
    db: 'main',
    user: 'yourDatabaseUsername',
    pass: 'yourDatabasePassword!'
  })
});
const data = await response.json();
console.log(data);
Ensure your namespace (ns) and database (db) parameters match your environment.
If you are generating a token via the Dashboard interface, you do not need to use these. They are alternative methods for specific programmatic use cases.
bash
curl -X POST https://i-love-surreal.aws-euw1.surreal.cloud/ \
  -H "Content-Type: application/json" \
  -d '{
    "ns": "main",
    "db": "main",
    "user": "yourDatabaseUsername",
    "pass": "yourDatabasePassword!"
  }'
Ensure your namespace (ns) and database (db) parameters match your environment.
Active Keys
Token Name User Created Status
production_key_xyz user1 4/14/2026 Active
SDK Integration

Choose your architecture type to see the connection implementation.

JS / TS
Rust
Python
.NET
PHP
Java
1. Install the SDK
npm install --save surrealdb
2. Initialize Connection
javascript
import { Surreal } from 'surrealdb';

let dbInstance = null;

export async function getDb() {
  if (dbInstance && dbInstance.status === 'connected') {
    return dbInstance;
  }

  const db = new Surreal();
  await db.connect('https://i-love-surreal.aws-euw1.surreal.cloud/', {
    namespace: 'main',
    database: 'main',
    authentication: {
      username: 'yourDatabaseUsername',
      password: 'yourDatabasePassword!'
    }
  });

  dbInstance = db;
  return dbInstance;
}
Best for long-running processes where a single connection is kept alive. Recommended for Node.js Backends, Dedicated Docker Services, and VPS Deployments. Ensure namespace and database match your setup.
1. Install the SDK
npm install --save surrealdb
2. Initialize Connection
javascript
import { Surreal } from 'surrealdb';

const db = new Surreal();

await db.connect('https://i-love-surreal.aws-euw1.surreal.cloud/', {
  namespace: 'main',
  database: 'main',
  authentication: 'YOUR_TOKEN_HERE'
});
Ideal for stateless environments. Connecting directly with a token saves an average of 100ms. Required for platforms like Vercel Edge, AWS Lambda, and Cloudflare Workers.