Resource Authorization
Grant permission to a user or make public
Grant a role to a user for a resource, or grant public access by using ”*” as userId. Only owners can grant permissions. Public access is allowed only for writer and reader roles.
POST
/
api
/
v1
/
authorization
/
llm
/
grant
Typescript (SDK)
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
await sdk.permissions.llm.grant({
grantPermissionRequest: {
resourceType: "completion",
resourceId: "my-completion-123",
userId: "user-abc456",
role: "writer",
},
});
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New(
mka1.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
res, err := s.Permissions.Llm.Grant(ctx, components.GrantPermissionRequest{
ResourceType: components.LlmResourceTypeCompletion,
ResourceID: "my-completion-123",
UserID: "user-abc456",
Role: components.ResourceRoleWriter,
}, nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Permissions.Llm.GrantAsync(body: new GrantPermissionRequest() {
ResourceType = LlmResourceType.Completion,
ResourceId = "my-completion-123",
UserId = "user-abc456",
Role = ResourceRole.Writer,
});
// handle responsefrom meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
sdk.permissions.llm.grant(resource_type="completion", resource_id="my-completion-123", user_id="user-abc456", role="writer")
# Use the SDK ...curl --request POST \
--url https://apigw.mka1.com/api/v1/authorization/llm/grant \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"resourceType": "completion",
"resourceId": "my-completion-123",
"userId": "user-abc456",
"role": "writer"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resourceType: 'completion',
resourceId: 'my-completion-123',
userId: 'user-abc456',
role: 'writer'
})
};
fetch('https://apigw.mka1.com/api/v1/authorization/llm/grant', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/authorization/llm/grant",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resourceType' => 'completion',
'resourceId' => 'my-completion-123',
'userId' => 'user-abc456',
'role' => 'writer'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authorization/llm/grant")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"resourceType\": \"completion\",\n \"resourceId\": \"my-completion-123\",\n \"userId\": \"user-abc456\",\n \"role\": \"writer\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authorization/llm/grant")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resourceType\": \"completion\",\n \"resourceId\": \"my-completion-123\",\n \"userId\": \"user-abc456\",\n \"role\": \"writer\"\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Send Authorization: Bearer , using an MKA1 API key for automation or an OAuth API access token for a signed-in application. Use a dynamic security callback to refresh OAuth access tokens. Browser session-only operations still require their declared cookie.
Headers
Optional external end-user identifier forwarded by the API gateway.
Body
application/json
Type of LLM resource
Available options:
completion, file, vector_store, conversation, response, skill Unique identifier for the resource
Required string length:
1 - 79Unique identifier for the user, or "*" to grant/revoke public access
Required string length:
1 - 169Permission role for the resource (owner > writer > reader)
Available options:
owner, writer, reader Response
Permission granted successfully
Was this page helpful?
⌘I
Typescript (SDK)
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
await sdk.permissions.llm.grant({
grantPermissionRequest: {
resourceType: "completion",
resourceId: "my-completion-123",
userId: "user-abc456",
role: "writer",
},
});
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New(
mka1.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
res, err := s.Permissions.Llm.Grant(ctx, components.GrantPermissionRequest{
ResourceType: components.LlmResourceTypeCompletion,
ResourceID: "my-completion-123",
UserID: "user-abc456",
Role: components.ResourceRoleWriter,
}, nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Permissions.Llm.GrantAsync(body: new GrantPermissionRequest() {
ResourceType = LlmResourceType.Completion,
ResourceId = "my-completion-123",
UserId = "user-abc456",
Role = ResourceRole.Writer,
});
// handle responsefrom meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
sdk.permissions.llm.grant(resource_type="completion", resource_id="my-completion-123", user_id="user-abc456", role="writer")
# Use the SDK ...curl --request POST \
--url https://apigw.mka1.com/api/v1/authorization/llm/grant \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"resourceType": "completion",
"resourceId": "my-completion-123",
"userId": "user-abc456",
"role": "writer"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resourceType: 'completion',
resourceId: 'my-completion-123',
userId: 'user-abc456',
role: 'writer'
})
};
fetch('https://apigw.mka1.com/api/v1/authorization/llm/grant', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/authorization/llm/grant",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resourceType' => 'completion',
'resourceId' => 'my-completion-123',
'userId' => 'user-abc456',
'role' => 'writer'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authorization/llm/grant")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"resourceType\": \"completion\",\n \"resourceId\": \"my-completion-123\",\n \"userId\": \"user-abc456\",\n \"role\": \"writer\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authorization/llm/grant")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resourceType\": \"completion\",\n \"resourceId\": \"my-completion-123\",\n \"userId\": \"user-abc456\",\n \"role\": \"writer\"\n}"
response = http.request(request)
puts response.read_body