Skip to main content
import Airstore from '@airstore/sdk'

const airstore = new Airstore({
  apiKey: 'org_...',
  timeout: 30_000,
  maxRetries: 3,
})
The Airstore class is the entry point for all SDK operations. It exposes resource namespaces (workspaces, connections, smartFolders, tokens, members, oauth, fs) that map to the Airstore REST API.

Constructor

new Airstore(options?: ClientOptions)
Creates a new SDK client. Throws AirstoreError if no API key is provided.

ClientOptions

OptionTypeDefaultDescription
apiKeystringprocess.env.AIRSTORE_API_KEYAPI key for authentication. Organization tokens start with org_, workspace tokens with tok_.
baseURLstringhttps://api.airstore.ai/api/v1Base URL for the API. Also reads AIRSTORE_BASE_URL env var.
timeoutnumber60000Request timeout in milliseconds.
maxRetriesnumber2Maximum retries for 429 and 5xx errors. Uses exponential backoff with jitter.
defaultHeadersRecord<string, string>{}Extra headers added to every request.

RequestOptions

Every resource method accepts RequestOptions as the last argument to override client-level settings for a single call:
const workspaces = await airstore.workspaces.list({
  timeout: 10_000,
  maxRetries: 5,
})
OptionTypeDescription
timeoutnumberOverride the client-level timeout for this request.
maxRetriesnumberOverride the client-level retry count.
signalAbortSignalAbort signal for cancellation.
headersRecord<string, string>Extra headers merged with client defaults.

ResponseMeta

Every response object has a non-enumerable lastResponse property with HTTP metadata:
const workspace = await airstore.workspaces.create({ name: 'test' })

console.log(workspace.lastResponse.statusCode) // 200
console.log(workspace.lastResponse.requestId)  // "req_abc123"
console.log(workspace.lastResponse.headers)    // Headers object
FieldTypeDescription
statusCodenumberHTTP status code.
headersHeadersResponse headers.
requestIdstring | undefinedValue of the x-request-id header, if present.

rawRequest()

Escape hatch for endpoints not yet covered by the SDK:
const response = await airstore.rawRequest('GET', '/some/endpoint', {
  params: { key: 'value' },
  timeout: 5_000,
})

const data = await response.json()
Parameters
ParameterTypeRequiredDescription
methodstringYesHTTP method (GET, POST, etc.)
pathstringYesAPI path (appended to baseURL)
opts.bodyunknownNoRequest body (JSON-serialized automatically)
opts.paramsRecord<string, string>NoQuery parameters
opts.timeoutnumberNoRequest timeout
opts.signalAbortSignalNoAbort signal
opts.headersRecord<string, string>NoExtra headers
Returns Promise<Response> — the raw Fetch API response.

Resource namespaces

NamespaceDescriptionReference
airstore.workspacesCreate and manage workspacesWorkspaces
airstore.connectionsManage integration connectionsConnections
airstore.smartFoldersCreate and manage smart foldersSmart Folders
airstore.tokensManage workspace tokensTokens
airstore.membersManage workspace membersMembers
airstore.oauthOAuth session managementOAuth
airstore.fsRead from the virtual filesystemFilesystem

Retry behavior

The client automatically retries on status codes 408, 409, 429, 500, 502, 503, and 504. Retries use exponential backoff starting at 500ms, capped at 8 seconds, with jitter. If the response includes a Retry-After or retry-after-ms header, the client respects that instead. Set maxRetries: 0 to disable retries entirely.