İçeriğe geç
ajan.io

Belgeler menüsü

Bu sayfada

Agent Update API

Mevcut bir agent'ı programatik olarak güncelleyin

Workspace'inizdeki mevcut bir agent'ı günceller. Yalnızca sağladığınız alanlar güncellenir; böylece diğer yapılandırmayı etkilemeden kısmi güncelleme yapılabilir.

Başlamadan önce

  • API key scope: Agent API kapsamına sahip bir API anahtarı ve güncellemek istediğiniz agent'a erişim gerekir.
  • Legacy Assistants API: Bu, yerel Vercel AI SDK uyumluluğuna sahip yeni Agents API'dir. Eski Assistants API kullanıyorsanız migration guide sayfasına bakın.
  • Draft only: Güncellemeler yalnızca agent'ın taslağına uygulanır. Aktif (yayınlanmış) sürüm, agent ajan UI'dan yayınlanana kadar değişmez.

Base URL

https://api.ajan.io/agent/v1/update

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

Update Behavior

Update endpoint, farklı alan türleri için belirli davranışlarla kısmi güncelleme semantiği kullanır:

  • Partial updates — İstekte sağlanan alanlar güncellenir; atlanan alanlar değişmez
  • Array fields replace — actions, inputFields, conversationStarters, attachments ve knowledgeFolderIds sağlandığında mevcut değerleri tamamen değiştirir
  • Empty arrays — Tüm action/alan/attachment'ları kaldırmak için [] gönderin
  • Null handling — emoji'yi temizlemek için null gönderin. description ve instruction için temizlemek üzere boş dize "" gönderin
  • Unchanged fields — İsteğe dahil edilmeyen alanlar mevcut değerlerini korur

Parameters

Agent'ın mevcut ayarlarının üzerine yazmak için aşağıdaki parametrelerden herhangi birini ayarlayın. Atladığınız alanlar değişmez. Yalnızca agentId zorunludur.

ParameterTypeRequiredDescription
agentIdstringYesGüncellenecek agent'ın UUID'si
namestringNoAgent adı (1-80 karakter)
descriptionstringNoAçıklama (maks. 800 karakter, temizlemek için "")
emojistringNoEmoji ikonu (maks. 16 karakter, temizlemek için null)
instructionstringNoSystem prompt (maks. 50000 karakter, temizlemek için "")
modelstringNoModel tanımlayıcısı (Models API deployment adı)
creativitynumberNo0 ile 1 arasında temperature
conversationStartersstring\[]NoÖnerilen prompt'lar, maks. 20, her biri 1-255 karakter (mevcut olanları değiştirir)
actionsarrayNoAction'lar (mevcut olanları değiştirir)
inputFieldsarrayNoForm alanları (mevcut olanları değiştirir)
attachmentsstring\[]NoEn fazla 50 attachment UUID (mevcut olanları değiştirir)
knowledgeFolderIdsstring\[]NoFolder UUID'leri (mevcut olanları değiştirir)
webSearchbooleanNoWeb aramayı etkinleştir
imageGenerationbooleanNoGörüntü üretmeyi etkinleştir
dataAnalystbooleanNoUyumluluk için kabul edilir. Aşağıdaki uyarıya bakın
inputTypestringNoGiriş türü: "PROMPT", "STRUCTURED", "INTEGRATION", "SCHEDULED" veya "WEBHOOK"
extendedThinkingbooleanNoExtended thinking modunu etkinleştir

dataAnalyst parametresi kullanımdan kaldırılmıştır ve etkisi yoktur. İçeren istekler geriye dönük uyumluluk için yine başarılı olur; ancak ajan değeri yok sayar ve dosya veya kod yürütmeyi etkinleştirmez. Yeni entegrasyonlarda bu parametreyi atlayın.

Dizi alanları (actions, inputFields, conversationStarters, attachments, knowledgeFolderIds) birleştirilmez, tamamen değiştirilir. Tutmak istediğiniz mevcut öğeler dahil her zaman istenen tam diziyi sağlayın.

Actions Configuration

actions dizisindeki her action şunları içermelidir:

  • actionId (required) — Etkin bir entegrasyondan action UUID'si
  • requiresConfirmation (optional) — Çalıştırmadan önce kullanıcı onayı gerekip gerekmediği (varsayılan: true)

Input Fields Configuration

inputFields dizi yapısı için Create Agent API belgelerine bakın.

Examples

Updating Basic Properties

javascript
const axios = require("axios");

async function updateAgentName() {
  const response = await axios.patch(
    "https://api.ajan.io/agent/v1/update",
    {
      agentId: "550e8400-e29b-41d4-a716-446655440000",
      name: "Advanced Document Analyzer",
      description: "Analyzes documents with enhanced capabilities",
      creativity: 0.7
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log("Agent updated:", response.data.message);
}

Validation Rules

API birkaç doğrulama kuralı uygular:

  • Agent access — API anahtarınızın agent'a erişimi olmalıdır
  • Workspace match — Agent, API anahtarınızla aynı workspace'e ait olmalıdır
  • Model — Sağlanırsa workspace'inizin aktif modeller listesinde olmalıdır
  • Actions — Sağlanırsa workspace'inizde etkin entegrasyonlara ait olmalıdır
  • Attachments — Sağlanırsa workspace'inizde var olmalı ve silinmiş olmamalıdır
  • Folders — Sağlanırsa workspace'inizde var olmalı ve silinmiş olmamalıdır
  • Name — Sağlanırsa 1-80 karakter arasında olmalıdır
  • Description — Sağlanırsa maksimum 800 karakter
  • Instruction — Sağlanırsa maksimum 50000 karakter
  • Creativity — Sağlanırsa 0 ile 1 arasında olmalıdır

Response Format

Success Response (200 OK)

typescript
{
  status: "success";
  message: "Agent updated successfully";
  agent: {
    id: string;
    name: string;
    description: string | null;
    instruction: string | null;
    emojiIcon: string | null;
    model: string | null;
    temperature: number;
    conversationStarters: string[];
    inputType: "PROMPT" | "STRUCTURED" | "INTEGRATION" | "SCHEDULED" | "WEBHOOK";
    webSearchEnabled: boolean;
    imageGenerationEnabled: boolean;
    canvasEnabled: boolean;
    extendedThinking: boolean;
    actions: Array<{
      actionId: string;
      requiresConfirmation: boolean;
    }>;
    inputFields: Array<{
      type: "TEXT" | "MULTI_LINE_TEXT" | "NUMBER" | "CHECKBOX" | "FILE" | "SELECT" | "MULTI_SELECT" | "DATE" | "EMAIL";
      label: string;
      description: string | null;
      required: boolean;
      order: number;
    }>;
    attachments: string[];
    knowledgeFolderIds: string[];
    owner: {
      id: string;
      name: string | null;
      email: string;
    } | null;
    createdAt: string;
    updatedAt: string;
  };
}

Error Handling

typescript
try {
  const response = await axios.patch('https://api.ajan.io/agent/v1/update', ...);
} catch (error) {
  if (error.response) {
    switch (error.response.status) {
      case 400:
        console.error('Invalid parameters or resource not found:', error.response.data.message);
        break;
      case 401:
        console.error('Invalid or missing API key');
        break;
      case 403:
        console.error('Insufficient permissions - no access to this agent');
        break;
      case 404:
        console.error('Agent not found or API key does not have access');
        break;
      case 429:
        console.error('Rate limit exceeded');
        break;
      case 500:
        console.error('Server error');
        break;
    }
  }
}

Best Practices

Mevcut değerleri koruma: actions veya attachments gibi dizi alanlarını güncellerken, tutmak istediğiniz mevcut öğeleri her zaman ekleyin; dizi tamamen değiştirilir.

  1. Fetch before update — Mevcut dizi değerlerini korumanız gerekiyorsa önce mevcut agent yapılandırmasını alın
  2. Incremental updates — Yalnızca değişmesi gereken alanları güncelleyin
  3. Validate attachments — Eklemeden önce attachment UUID'lerinin geçerli olduğundan emin olun
  4. Test actions — Güncellemeden önce action'ların etkin entegrasyonlara ait olduğunu doğrulayın
  5. Handle errors gracefully — Doğrulama hataları için uygun hata işleme uygulayın

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:
  /agent/v1/update:
    patch:
      tags:
        - Agent Build
      summary: Updates an existing agent
      description: Updates an existing agent in your workspace.
      operationId: updateAgentV2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required:
                    - agentId
                  properties:
                    agentId:
                      type: string
                      format: uuid
                - $ref: '#/components/schemas/AssistantWriteRequest'
      responses:
        '200':
          description: Agent updated successfully
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - message
                  - agent
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  message:
                    type: string
                    example: Agent updated successfully
                  agent:
                    $ref: '#/components/schemas/AssistantDetails'
components:
  schemas:
    AssistantWriteRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 80
          description: Name of the agent or assistant
        description:
          type: string
          maxLength: 800
          description: >-
            Description of what the agent or assistant does. Send an empty
            string to clear it during an update.
        instruction:
          type: string
          maxLength: 50000
          description: >-
            System prompt or instructions. Send an empty string to clear it
            during an update.
        inputType:
          type: string
          enum:
            - PROMPT
            - STRUCTURED
            - INTEGRATION
            - SCHEDULED
            - WEBHOOK
          description: Input type
        emoji:
          type: string
          nullable: true
          maxLength: 16
          description: Emoji icon
        model:
          type: string
          description: Model deployment name
        creativity:
          type: number
          minimum: 0
          maximum: 1
          description: Temperature for response generation
        conversationStarters:
          type: array
          maxItems: 20
          items:
            type: string
            minLength: 1
            maxLength: 255
          description: Suggested prompts
        actions:
          type: array
          items:
            $ref: '#/components/schemas/AssistantActionRequest'
          description: Actions that the agent or assistant can use
        inputFields:
          type: array
          items:
            $ref: '#/components/schemas/AssistantInputFieldRequest'
          description: Form fields for STRUCTURED input
        webSearch:
          type: boolean
          description: Enable web search
        imageGeneration:
          type: boolean
          description: Enable image generation
        dataAnalyst:
          type: boolean
          deprecated: true
          description: Deprecated. Accepted for compatibility and ignored.
        extendedThinking:
          type: boolean
          description: Enable extended thinking
        attachments:
          type: array
          maxItems: 50
          items:
            type: string
            format: uuid
          description: Attachment UUIDs
        knowledgeFolderIds:
          type: array
          items:
            type: string
            format: uuid
          description: Folder UUIDs
    AssistantDetails:
      type: object
      required:
        - id
        - name
        - description
        - instruction
        - emojiIcon
        - model
        - temperature
        - conversationStarters
        - inputType
        - webSearchEnabled
        - imageGenerationEnabled
        - canvasEnabled
        - extendedThinking
        - actions
        - inputFields
        - attachments
        - knowledgeFolderIds
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the agent
        name:
          type: string
          description: Name of the agent
        description:
          type: string
          nullable: true
          description: Description of what the agent does
        instruction:
          type: string
          nullable: true
          description: System prompt/instructions for the agent
        emojiIcon:
          type: string
          nullable: true
          description: Emoji icon for the agent
        model:
          type: string
          nullable: true
          description: Model ID to use (see Models for Agent API)
        temperature:
          type: number
          minimum: 0
          maximum: 1
          description: Temperature/creativity setting for response generation
        conversationStarters:
          type: array
          items:
            type: string
          description: Array of suggested prompts to help users get started
        inputType:
          type: string
          enum:
            - PROMPT
            - STRUCTURED
            - INTEGRATION
            - SCHEDULED
            - WEBHOOK
          description: Input type for the agent
        webSearchEnabled:
          type: boolean
          description: Whether web search capability is enabled
        imageGenerationEnabled:
          type: boolean
          description: Whether image generation capability is enabled
        canvasEnabled:
          type: boolean
          description: Whether canvas capability is enabled
        extendedThinking:
          type: boolean
          description: >-
            Whether extended thinking is enabled. Only supported on models that
            expose this capability; enabling it on an unsupported model returns
            a 400 error.
        actions:
          type: array
          items:
            type: object
            required:
              - actionId
              - requiresConfirmation
            properties:
              actionId:
                type: string
                format: uuid
                description: UUID of the action from an enabled integration
              requiresConfirmation:
                type: boolean
                description: Whether user confirmation is required before executing
          description: Array of action objects for custom integrations
        inputFields:
          type: array
          items:
            type: object
            required:
              - type
              - label
              - description
              - required
              - order
            properties:
              type:
                type: string
                enum:
                  - TEXT
                  - MULTI_LINE_TEXT
                  - NUMBER
                  - CHECKBOX
                  - FILE
                  - SELECT
                  - MULTI_SELECT
                  - DATE
                  - EMAIL
                description: Field type
              label:
                type: string
                description: Display label for the field
              description:
                type: string
                nullable: true
                description: Help text for the field
              required:
                type: boolean
                description: Whether the field is required
              order:
                type: integer
                minimum: 0
                description: Display order (0-indexed)
          description: Array of form field definitions (for STRUCTURED input type)
        attachments:
          type: array
          items:
            type: string
            format: uuid
          description: Array of attachment UUIDs associated with the agent
        knowledgeFolderIds:
          type: array
          items:
            type: string
            format: uuid
          description: Array of Folder UUIDs associated with the agent
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the agent was created
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the agent was last updated
    AssistantActionRequest:
      type: object
      required:
        - actionId
      properties:
        actionId:
          type: string
          format: uuid
          description: UUID of the action from an enabled integration
        requiresConfirmation:
          type: boolean
          default: true
          description: Whether to require user confirmation before executing
    AssistantInputFieldRequest:
      type: object
      required:
        - slug
        - type
        - label
        - order
      properties:
        slug:
          type: string
          minLength: 1
          maxLength: 64
          description: Unique identifier for the field
        type:
          type: string
          enum:
            - TEXT
            - MULTI_LINE_TEXT
            - NUMBER
            - CHECKBOX
            - FILE
            - SELECT
            - MULTI_SELECT
            - DATE
            - EMAIL
          description: Field type
        label:
          type: string
          minLength: 1
          maxLength: 255
          description: Display label for the field
        description:
          type: string
          maxLength: 512
          description: Help text for the field
        required:
          type: boolean
          default: false
          description: Whether the field is required
        order:
          type: integer
          minimum: 0
          description: Display order
        options:
          type: array
          default: []
          items:
            type: string
            minLength: 1
            maxLength: 255
          description: Options for SELECT and MULTI_SELECT fields
        fileTypes:
          type: string
          nullable: true
          maxLength: 255
          description: Allowed file types for FILE fields
        emailDomain:
          type: string
          nullable: true
          description: Allowed email domain for EMAIL fields
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"