import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.auth.apiKey.getJwtFromKey({
audience: "https://my-awesome-website.com",
externalUserId: "the-user-id-in-your-system",
permissions: [
"agent:create",
"agent:read",
],
});
console.log(result);
}
run();{
"token": "the-jwt-token"
}Exchange an API key for a JWT token
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.auth.apiKey.getJwtFromKey({
audience: "https://my-awesome-website.com",
externalUserId: "the-user-id-in-your-system",
permissions: [
"agent:create",
"agent:read",
],
});
console.log(result);
}
run();{
"token": "the-jwt-token"
}Authenticate with your MKA1 API key at the API gateway: Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, also send X-On-Behalf-Of to identify the end user making the request.
JWT audience (aud) claim for the exchanged token. Set this to the target API/service URL that should accept the token.
Your external user identifier to place in the JWT subject (sub) claim.
1Token lifetime in seconds. Must be between 300 (5 minutes) and 2592000 (30 days). Defaults to 3600 (1 hour).
300 <= x <= 2592000Optional subset of API key permissions to embed in the token. If omitted, all API key permissions are used.
Successfully exchanged API key for a JWT token
Signed JWT exchange token to use when calling downstream services.
Was this page helpful?