Skip to main content

Client Configuration

Configure the Scaffald SDK client for your application.

Creating a Client

new Scaffald(config)

Creates a new Scaffald API client.

const client = new Scaffald({
apiKey?: string
accessToken?: string
baseUrl?: string
maxRetries?: number
timeout?: number
headers?: Record<string, string>
})

Parameters:

ParameterTypeRequiredDefaultDescription
apiKeystringYes*-API key for server-side authentication
accessTokenstringYes*-OAuth access token for client-side auth
baseUrlstringNohttps://api.scaffald.comBase API URL
maxRetriesnumberNo3Max retry attempts (0-10)
timeoutnumberNo30000Request timeout in ms (1000-300000)
headersobjectNo{}Additional HTTP headers

* Either apiKey or accessToken is required

Example:

const client = new Scaffald({
apiKey: process.env.SCAFFALD_API_KEY,
maxRetries: 5,
timeout: 60000
})

Authentication Methods

Server-Side (API Key)

For Node.js applications and server-side usage:

const client = new Scaffald({
apiKey: process.env.SCAFFALD_API_KEY
})

Client-Side (OAuth)

For browser applications and user authentication:

const client = new Scaffald({
accessToken: userAccessToken
})

See the OAuth Guide for complete OAuth flow documentation.

Configuration Options

Base URL

Override the default API endpoint:

const client = new Scaffald({
apiKey: 'your-key',
baseUrl: 'https://api-staging.scaffald.com'
})

Retry Configuration

Control automatic retry behavior:

const client = new Scaffald({
apiKey: 'your-key',
maxRetries: 5 // Retry up to 5 times on network errors
})

Timeout

Set request timeout in milliseconds:

const client = new Scaffald({
apiKey: 'your-key',
timeout: 60000 // 60 seconds
})

Custom Headers

Add custom HTTP headers to all requests:

const client = new Scaffald({
apiKey: 'your-key',
headers: {
'X-Custom-Header': 'value',
'X-App-Version': '1.0.0'
}
})

Next Steps