İçeriğe geç
ajan.io

Belgeler menüsü

Bu sayfada

Agent Publish API

Taslak bir agent'ı yeni bir sürüm olarak yayınlayın

Bir agent'ın mevcut taslağını yeni bir sürüm olarak yayınlar. Bu, agent editöründeki Update düğmesini yansıtır: yayınlanan sürüm, kullanıcıların gördüğü aktif sürüm haline gelen taslağın dondurulmuş bir anlık görüntüsüdür.

Başlamadan önce

  • 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.

Base URL

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

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

Draft vs. Published Version

/agent/v1/update üzerinden yapılan düzenlemeler yalnızca taslağı etkiler. publish çağrılana kadar bu değişiklikler workspace üyelerine görünmez.

Kullanım senaryoları

  • Update API ile yapılan taslak düzenlemeleri yeni aktif sürüme yükseltme
  • CI/CD hattının parçası olarak değişiklikleri programatik yayınlama
  • Sürüm geçmişinde gösterilen isteğe bağlı bir değişiklik açıklamasıyla yeni revizyon yayınlama

Parameters

ParameterTypeRequiredDescription
agentIdstringYesYayınlanacak agent'ın UUID'si
descriptionstringNoSürüm geçmişinde gösterilen kısa değişiklik açıklaması (maks. 100 karakter)

Example

javascript
const axios = require("axios");

async function publishAgent(agentId, description) {
  const response = await axios.post(
    "https://api.ajan.io/agent/v1/publish",
    {
      agentId: agentId,
      description: description,
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
    },
  );

  console.log("Published version:", response.data.version);
}

publishAgent(
  "550e8400-e29b-41d4-a716-446655440000",
  "Tightened the system prompt",
);

Response Format

Success Response (200 OK)

typescript
{
  status: "success";
  message: "Agent published successfully";
  version: {
    id: string;          // UUID of the new version
    version: number;     // Monotonically increasing version number
    createdAt: string;   // ISO 8601 timestamp
  };
}

Validation Rules

  • Agent access — API anahtarının agent üzerinde owner veya editor erişimi olmalıdır (Update ile aynı).
  • Workspace match — Agent, API anahtarıyla aynı workspace'e ait olmalıdır.
  • Agents only — Projeler (type=PROJECT) desteklenmez ve 403 döner.
  • Has draft changes — Taslak, en son yayınlanan sürümden farklı olmalıdır. Bekleyen değişiklik olmadan yayınlamak 409 Conflict döner; UI'daki devre dışı "Update" düğmesiyle aynı davranış.

Error Handling

Status CodeDescription
400Geçersiz istek gövdesi (eksik veya hatalı agentId / description çok uzun)
401Geçersiz veya eksik API anahtarı
403API anahtarının düzenleme erişimi yok, agent farklı workspace'te veya kaynak bir proje
409Yayınlanacak taslak değişiklik yok
429Rate limit aşıldı

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/publish:
    post:
      tags:
        - Agent Build
      summary: Publishes a draft agent as a new version
      description: >-
        Publishes the current draft of an agent as a new version. Mirrors the
        "Update" button in the agent editor — only agents (not projects) are
        supported, and the draft must differ from the latest published version.
      operationId: publishAgentV2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - agentId
              properties:
                agentId:
                  type: string
                  format: uuid
                  description: UUID of the agent to publish
                description:
                  type: string
                  minLength: 1
                  maxLength: 500
                  description: Optional change description shown in version history
      responses:
        '200':
          description: Agent published successfully
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - message
                  - version
                properties:
                  status:
                    type: string
                  message:
                    type: string
                  version:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      version:
                        type: integer
                      createdAt:
                        type: string
                        format: date-time
        '403':
          description: >-
            API key lacks edit access, agent is in a different workspace, or the
            resource is a project
        '409':
          description: No draft changes to publish
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"