JavaScript Quickstart
Use @apito-io/js-admin-sdk from Node, Astro, Vite, and Workers-friendly ESM. It talks to project secured GraphQL — not /system/graphql.

Install
npm install @apito-io/js-admin-sdk
For Astro / Cloudflare Workers, import ESM only (dist/index.mjs). Do not put the package in vite.ssr.noExternal. Details: JS SDK reference.
Configure
import { ApitoClient } from '@apito-io/js-admin-sdk';
const client = new ApitoClient({
baseURL: process.env.APITO_GRAPHQL_ENDPOINT!, // project GraphQL URL
apiKey: process.env.APITO_API_KEY!, // project key → X-Apito-Key
// accessToken: process.env.APITO_ACCESS_TOKEN, // apt_… → Authorization: Bearer
timeout: 30000,
});
| Config | Use |
|---|---|
baseURL |
Project secured GraphQL endpoint (never system GraphQL) |
apiKey |
Legacy project key → X-Apito-Key |
accessToken |
Unified apt_… token → Authorization: Bearer |
tenantId / projectId |
Optional defaults for SaaS / system-scoped helpers |
Retired cli- / sdk- / mcp- key prefixes throw immediately (TOKEN_FORMAT_RETIRED).
First ops
Core document methods (model name = published model id, e.g. post, ad_slot):
const results = await client.searchResources('post', {
limit: 10,
page: 1,
where: { /* field filters from published schema */ },
});
const one = await client.getSingleResource('post', results.results[0].id);
const created = await client.createNewResource({
model: 'post',
payload: { title: 'Hello from the SDK' },
});
Also available: updateResource, deleteResource, relation helpers, media, users/tenants (edition-dependent). After schema Publish, regenerate typed docs if you use the SDK codegen CLI.
SaaS tenants
Pass tenantId on the client or per call. Empty SaaS lists are usually a missing tenant filter — see Filters & relations.
Blueprints
newspaper-cms and mcp-saas ship Astro + JS SDK examples under apito-io/examples.
Honest limits
- No Python Admin SDK — use raw GraphQL.
- Workers-hosted Engine (
cloudflare_full) has gaps (e.g. some tenant catalog mutations) — see SDKCONTRACT.md. - System GraphQL stays Console / CLI / MCP only.