API Connection
SkillSecurityConfigure and use Backoffice API connections. Use when creating outbound HTTP API integrations, configuring OAuth or bearer authentication, starting API OAuth flows, checking auth status, or executing authenticated API requests from automations.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the API Connection skill
What this skill tells your AI
The instructions your AI receives, as published by rejot-dev/fragno in apps/backoffice/content/static/skills/api-connection/SKILL.md and read by ahel’s review.
Use this skill for scope-aware outbound HTTP API connections, OAuth PKCE authentication, bearer tokens, client credentials, and API requests through Backoffice runtimes.
API configuration
The API capability is available automatically for the current scope. Create each external API connection with a stable lowercase slug and a base URL.
- Use
api.*methods for API connections. - Register the public OAuth callback route
/api/http/:scope/oauth/callbackfor scoped OAuth connections. - Use relative request paths, for example
/v1/customers. If the user giveshttps://example.com/v1/customersand the connection base URL ishttps://example.com, callapi.requestwithpath: "/v1/customers". - Let stored connection auth replace caller-provided
Authorizationheaders. - If the user supplies a client secret in the session and asks you to configure the connection, pass
it to
api.createConnectionand keep the final response secret-free.
Rules:
- When configuring a new OAuth connection, ALWAYS immediately start OAuth and give the user the
returned
authorizationUrlin a clickable way. - When the user says anything after you've presented them with the link, ALWAYS check status of the connection and report back to the user.
Typical OAuth setup flow:
- Create the API connection with the requested auth configuration.
- For OAuth connections, immediately start OAuth after creating the connection and give the returned authorization URL to the user:
const connection = await api.createConnection({
slug: "example-api",
name: "Example API",
baseUrl: "https://api.example.com",
auth: {
type: "oauth",
authorizationEndpoint: "https://api.example.com/oauth/authorize",
tokenEndpoint: "https://api.example.com/oauth/token",
clientId: "example-client",
clientSecret: "example-client-secret",
scopes: ["profile", "email", "read"],
tokenEndpointAuthMethod: "client_secret_post",
},
});
const oauth = await api.startOAuth({ slug: connection.slug });
return { connection, authorizationUrl: oauth.authorizationUrl };
- When the user responds after opening the OAuth URL, always check authentication status:
const status = await api.getAuthStatus({ slug: "example-api" });
return status;
- If authentication is successful, tell the user the connection is authenticated and ask whether they want to try an API call.
- When the user wants to test an API call, call
api.requestwith a relative path and includeAccept: "application/json"for JSON APIs.
Bearer setup example:
await api.createConnection({
slug: "stripe",
name: "Stripe",
baseUrl: "https://api.stripe.com",
auth: { type: "bearer", token: process.env.STRIPE_TOKEN },
});
OAuth setup example for a confidential server-side client:
await api.createConnection({
slug: "example-api",
name: "Example API",
baseUrl: "https://api.example.com",
auth: {
type: "oauth",
authorizationEndpoint: "https://api.example.com/oauth/authorize",
tokenEndpoint: "https://api.example.com/oauth/token",
clientId: "example-client",
clientSecret: "example-client-secret",
scopes: ["profile", "email", "read"],
tokenEndpointAuthMethod: "client_secret_post",
},
});
const auth = await api.startOAuth({ slug: "example-api" });
return auth.authorizationUrl;
OAuth connections run server-side in Backoffice. Use the token endpoint auth method configured for
the provider's OAuth app registration. Confidential clients usually use
tokenEndpointAuthMethod: "client_secret_post" or "client_secret_basic" with clientSecret.
Public PKCE client registrations use tokenEndpointAuthMethod: "none" with client id and scopes.
OAuth restart and troubleshooting notes:
- To restart OAuth with unchanged settings, call
api.startOAuth({ slug })and give the user the newestauthorizationUrl. - To restart OAuth after auth settings were removed or the connection shows
authMode: "none", recreate the connection with the full OAuth config and then callapi.startOAuth({ slug }). - After changing
tokenEndpointAuthMethod, client secret, scopes, endpoints, or redirect route, start OAuth again and tell the user to use the newest OAuth tab. Old authorization URLs contain old state, redirect URI, and PKCE challenge data. - If the callback reports
The client cannot authenticate with methods: [...], the authorization step succeeded and the token exchange failed. Align the configuredtokenEndpointAuthMethodwith the provider-side OAuth app registration. Use"client_secret_post"or"client_secret_basic"for confidential client registrations, and use"none"for public PKCE client registrations. - If a previously failing client starts working after provider-side changes, recreate or update the connection and generate a fresh authorization URL before retesting.
API events
Cataloged automation events:
source:api,eventType:connection.changed— fires when an API connection is created or its configuration changes.source:api,eventType:connection.deleted— fires when an API connection is deleted.source:api,eventType:connection.available— fires when auth becomes usable after bearer setup, OAuth callback, or client-credentials token acquisition. Connection hook payloads includeconnectionIdand a connection snapshot withslug,name,baseUrl,authMode, andstatus.
API tools
API tools can:
- list configured API connections;
- create and delete outbound HTTP API connections;
- inspect auth status;
- store bearer tokens;
- start OAuth login;
- delete stored auth;
- execute authenticated HTTP requests through a configured connection.
Use codemode first. The api provider methods are listConnections, createConnection,
deleteConnection, getAuthStatus, setToken, startOAuth, deleteAuth, and request.
Examples:
await api.listConnections();
await api.getAuthStatus({ slug: "example-api" });
await api.request({
slug: "example-api",
method: "GET",
path: "/v1/resources",
headers: { Accept: "application/json" },
timeoutMs: 30_000,
});
For JSON request bodies, use api.request --json '{"key":"value"}'. For text bodies, use --body.
Request debugging notes:
- Always check
api.getAuthStatus({ slug })before debugging an API request.authenticated: truemeans OAuth credentials are stored; returned HTTP404,405, or500statuses are upstream API responses. - Treat upstream 4xx and 5xx responses from
api.requestas response data withstatus,statusText,headers, andbody. - If a user provides a full URL, convert it to a relative path for the configured connection base URL.
- For endpoints like token introspection, inspect the upstream
AllowandWWW-Authenticateheaders. A405withAllow: OPTIONS, POSTmeans retry with POST; a401 invalid_clientmeans that endpoint requires its own client authentication and often a form body such as atokenparameter. - If you see a runtime validation error about missing
statusText, rebuild or restart the API fragment/runtime; current API responses includestatusText.
Signals
- GitHub stars
- 61
- Forks
- 6
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
api-connection- Source
- github.com/rejot-dev/fragno