client.projects.create
Create a new platform project via the SDK.
Signature
class Client {
projects: {
create(input: CreateProjectInput): Promise<Project>
}
}
interface CreateProjectInput {
name: string
plan?: 'free' | 'starter' | 'pro' | 'team'
region?: 'eu' | 'sea' | 'us'
}
interface Project {
id: string
name: string
slug: string
status: 'provisioning' | 'ready' | 'error'
plan: string
created_at: string
}
Throws
| Error | Condition |
|---|---|
| missing or empty |
| >100 req/min |
| Invalid or expired API key |
| Project name already exists |
Examples
Basic:
import { Client } from "@blueforge/client"
const client = new Client({ apiKey: process.env.BF_API_KEY! })
const project = await client.projects.create({ name: "my-project" })
console.log(project.id) // "prj_xxxxx"
With plan + region + error handling:
import { Client, RateLimitError, ValidationError } from "@blueforge/client"
try {
const project = await client.projects.create({
name: "my-project",
plan: "pro",
region: "eu",
})
} catch (e) {
if (e instanceof ValidationError) throw new Error(`bad input: ${e.message}`)
if (e instanceof RateLimitError) await sleep(e.retryAfter * 1000)
throw e
}
Poll until ready:
const project = await client.projects.create({ name: "my-project" })
while (project.status === 'provisioning') {
await sleep(2000)
project = await client.projects.get(project.id)
}
console.log(`Project ready: ${project.id}`)
Pitfalls
- Credentials not returned — unlike the REST API, the SDK create response does NOT include connection strings. Use
for status.client.projects.get(id) - Async provisioning — the
field will bestatus
initially. Pollprovisioning
untilclient.projects.get(id)
.ready - Rate limits apply — 100 req/min per API key. The SDK auto-retries on 429 with exponential backoff when configured.
See also
{auto-injected}
Tested against
{auto-injected}