İçeriğe geç
ajan.io

Belgeler menüsü

Bu sayfada

Knowledge base erişimini paylaş

Kişiler ve workspace API anahtarları için Knowledge base erişimini verin, değiştirin veya iptal edin

Mevcut bir Knowledge base üzerinde erişim verir, değiştirir veya iptal eder. Hedefler kişiler ve workspace API anahtarlarıdır. Gruplar uygulama içi Share Knowledge bases with the API akışında kalır.

Başlamadan önce

  • API key scope: KNOWLEDGE_FOLDER_API kapsamına sahip bir API anahtarı gerekir. API anahtarının kendisinin Knowledge base üzerinde Editor rolü olmalıdır. Kurulum için Share Knowledge bases with the API sayfasına bakın.
  • Knowledge bases: Knowledge Folder API, Library'de Knowledge base olarak görünen kaynakları yönetir.

Base URL

https://api.ajan.io

Dedicated deployments Tüm isteklerde api.ajan.com'u /api/public ile değiştirin.

Roles

API valueLibrary labelAccess
USERViewerDosyaları arama ve getirme
EDITOREditorYükleme, güncelleme, silme, erişim paylaşma ve yeniden adlandırma

Yalnızca Viewer yetkisine sahip bir anahtar (Knowledge base üzerinden yalnızca API araması olan anahtar dahil) bu endpoint'leri çağıramaz.

Editor workspace anahtarı, anahtar sahibi workspace admin olmasa bile diğer uygun workspace anahtarlarına yetki verebilir. Uygulama içi Share diyaloğu API anahtarlarını hâlâ yalnızca workspace admin'lerine listeler.

Grant access

POST /knowledge/{folderId}/access

Path Parameters

ParameterTypeRequiredDescription
folderIdstringYesKnowledge base ID'si

Request Body

FieldTypeRequiredDescription
targetIdsstring\[]YesYetki verilecek kullanıcı ID'leri ve workspace API anahtarı ID'leri. Minimum: 1. Maksimum: 100.
rolestringYesUSER veya EDITOR

Tüm ID'ler bir insan workspace üyesine veya uygun bir workspace API anahtarına çözülmelidir. Group ID'leri kabul edilmez. Personal API key'ler uygun değildir. Herhangi bir ID eksik veya uygun değilse istek başarısız olur ve hiçbir yetki yazılmaz.

Grant with cURL

bash
curl -X POST "https://api.ajan.io/knowledge/{folderId}/access" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "targetIds": [
      "7c9e6679-7425-40de-944b-e07fc1f90ae7",
      "550e8400-e29b-41d4-a716-446655440000"
    ],
    "role": "EDITOR"
  }'

Grant with JavaScript

javascript
const axios = require("axios");

async function grantAccess(folderId, targetIds, role) {
  const response = await axios.post(
    `https://api.ajan.io/knowledge/${folderId}/access`,
    { targetIds, role },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
    }
  );

  return response.data;
}

const result = await grantAccess(
  "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  ["7c9e6679-7425-40de-944b-e07fc1f90ae7"],
  "EDITOR"
);
console.log(result.result.granted);

Success Response (200 OK)

json
{
  "status": "success",
  "result": {
    "granted": [
      {
        "type": "USER",
        "targetId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
        "role": "EDITOR"
      },
      {
        "type": "API_KEY",
        "targetId": "550e8400-e29b-41d4-a716-446655440000",
        "role": "EDITOR"
      }
    ]
  }
}

Change a role

PATCH /knowledge/{folderId}/access

FieldTypeRequiredDescription
typestringYesUSER veya API_KEY
targetIdstringYesKişi veya workspace API anahtarı ID'si
rolestringYesUSER veya EDITOR

Knowledge base sahibinin erişimini değiştiremezsiniz. Önce Library'de sahipliği yeniden atayın. Hedefin henüz yetkisi yoksa bu istek bir yetki oluşturur.

bash
curl -X PATCH "https://api.ajan.io/knowledge/{folderId}/access" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "API_KEY",
    "targetId": "550e8400-e29b-41d4-a716-446655440000",
    "role": "USER"
  }'
json
{
  "status": "success"
}

Revoke access

DELETE /knowledge/{folderId}/access

FieldTypeRequiredDescription
typestringYesUSER veya API_KEY
targetIdstringYesKişi veya workspace API anahtarı ID'si

Knowledge base sahibinin erişimini iptal edemezsiniz.

bash
curl -X DELETE "https://api.ajan.io/knowledge/{folderId}/access" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "API_KEY",
    "targetId": "550e8400-e29b-41d4-a716-446655440000"
  }'
json
{
  "status": "success"
}

Error Handling

StatusMeaning
400Geçersiz gövde, uygun olmayan paylaşım hedefi veya sahip erişimi değişikliği
401Geçersiz veya eksik API anahtarı
403Eksik KNOWLEDGE_FOLDER_API kapsamı veya anahtar bu Knowledge base'de Editor değil
404Knowledge base veya erişim hedefi bulunamadı
429Rate limit aşıldı
500Beklenmeyen sunucu hatası

ajan, API anahtarınızı korumak ve uygulamalarınızın güvenliğini sağlamak için tarayıcı kaynaklı istekleri bilinçli olarak engeller. Daha fazla bilgi için API Key Best Practices kılavuzuna bakın.

OpenAPI

openapi: 3.0.0
info:
  title: ajan API
  version: 3.0.0
servers:
  - url: https://api.ajan.io
    description: Production
security:
  - bearerAuth: []
paths:
  /knowledge/{folderId}/access:
    post:
      summary: Grant Knowledge base access to people or workspace API keys
      parameters:
        - name: folderId
          in: path
          required: true
          description: The ID of the knowledge folder
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - targetIds
                - role
              properties:
                targetIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                  minItems: 1
                  maxItems: 100
                role:
                  type: string
                  enum:
                    - USER
                    - EDITOR
      responses:
        '200':
          description: Access granted successfully
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"