> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flashduty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload knowledge file

> Create or overwrite a file in a knowledge pack with base64-encoded content.

## Restrictions

| Aspect      | Value                                                       |
| ----------- | ----------------------------------------------------------- |
| Rate limits | **300 requests/minute**; **20 requests/second** per account |
| Permissions | **Knowledge Manage** (`ai-sre`)                             |

## Usage

* The file body is sent as base64 text in the JSON field `content_b64` — this is not a multipart upload.
* Writing an existing `rel_path` overwrites it; `content_type` is inferred from the extension when omitted (`.md` → `text/markdown`).
* Content must decode to valid UTF-8 text; binary payloads are rejected with `InvalidParameter`.
* Editing the account-scope pack requires account owner/admin; editing a team pack requires team membership.
* Every call is recorded in the account audit log.


## OpenAPI

````yaml /api-reference/safari.openapi.en.json post /safari/knowledge/file/put
openapi: 3.1.0
info:
  title: Flashduty Open API
  description: >-
    Public HTTP API for the Flashduty AI SRE platform — skills, MCP servers
    (connectors), A2A agents, and sessions. Every operation is authenticated
    with an `app_key` query parameter issued from the Flashduty console.
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: AI SRE/Skills
    description: AI SRE agent skill management.
  - name: AI SRE/MCP servers
    description: MCP (Model Context Protocol) server management.
  - name: AI SRE/A2A agents
    description: A2A (agent-to-agent) remote agent management.
  - name: AI SRE/Sessions
    description: AI SRE agent session history — list, inspect, and export transcripts.
  - name: AI SRE/Automations
  - name: AI SRE/Knowledge
paths:
  /safari/knowledge/file/put:
    post:
      tags:
        - AI SRE/Knowledge
      summary: Upload knowledge file
      description: >-
        Create or overwrite a file in a knowledge pack with base64-encoded
        content.
      operationId: knowledge-file-write-put
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KnowledgeFilePutRequest'
            example:
              rel_path: tmp/openapi-example.md
              content_b64: >-
                IyBPcGVuQVBJIGV4YW1wbGUKVGVtcCBmaWxlIGZvciBBUEkgZG9jcyBleGFtcGxlLgo=
              content_type: text/markdown
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/KnowledgeFilePutResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  file:
                    file_id: kfl_gctXKRG45aFQGgxSFr59WY
                    pack_id: kpk_kE49k3FhecfJBwutbshEEc
                    rel_path: tmp/openapi-example.md
                    content_type: text/markdown
                    size_bytes: 50
                    checksum: >-
                      a0775f9b3f392cd0560b21ad2f579ae4a5d6b1282b9eb145688ba2de717a816d
                    updated_by: 2476444212131
                    updated_at_ms: 1786458764961
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - AppKeyAuth: []
components:
  schemas:
    KnowledgeFilePutRequest:
      type: object
      description: >-
        File to create or overwrite. The body is base64 text in `content_b64`,
        not a multipart upload.
      properties:
        pack_id:
          type: string
          description: Knowledge pack ID; defaults to the caller's account-scope pack.
        rel_path:
          type: string
          description: >-
            Destination path relative to the pack root; existing files are
            overwritten.
        content_b64:
          type: string
          description: Base64-encoded file content; must decode to valid UTF-8 text.
        content_type:
          type: string
          description: MIME type; inferred from the file extension when omitted.
      required:
        - rel_path
    ResponseEnvelope:
      type: object
      description: >-
        Standard response envelope used by every Flashduty public API. On
        success `data` contains the endpoint-specific payload and `error` is
        absent. On failure `error` is present and `data` is absent. `request_id`
        is always present and is also mirrored in the `Flashcat-Request-Id`
        response header.
      properties:
        request_id:
          type: string
          description: >-
            Unique ID for this request. Mirrored in the Flashcat-Request-Id
            header. Include it when reporting issues.
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
        data:
          description: Endpoint-specific payload. See each operation's 200 response schema.
      required:
        - request_id
    KnowledgeFilePutResponse:
      type: object
      description: The written file plus any non-blocking warnings.
      properties:
        file:
          $ref: '#/components/schemas/KnowledgeFileItem'
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/KnowledgeWarning'
          description: >-
            Non-blocking warnings after a successful write;
            `code=unresolved_reference` means an @ref in the file content points
            to a file that does not exist in the pack. Absent when there are no
            warnings (omitempty).
      required:
        - file
    DutyError:
      type: object
      description: >-
        Error payload inside the response envelope. Present only on non-2xx
        responses.
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: >-
            Human-readable error message, localized by the caller's
            Accept-Language. May contain field names, IDs, or other context from
            the failing request.
      required:
        - code
        - message
    KnowledgeFileItem:
      type: object
      description: >-
        Metadata of one file inside a knowledge pack. Content is fetched
        separately via file/get.
      properties:
        file_id:
          type: string
          description: File ID (`kfl_` prefix).
        pack_id:
          type: string
          description: ID of the knowledge pack that contains the file.
        rel_path:
          type: string
          description: Path relative to the pack root, e.g. `runbooks/restart.md`.
        content_type:
          type: string
          description: MIME type; inferred from the file extension when not set on upload.
        size_bytes:
          type: integer
          description: File size in bytes.
          format: int64
        checksum:
          type: string
          description: SHA-256 hex digest of the file content.
        updated_by:
          type: integer
          description: Person ID of the member who last modified the file.
          format: int64
        updated_at_ms:
          type: integer
          description: Unix timestamp in milliseconds when the file was last modified.
          format: int64
      required:
        - file_id
        - pack_id
        - rel_path
        - content_type
        - size_bytes
        - checksum
        - updated_by
        - updated_at_ms
    KnowledgeWarning:
      type: object
      description: >-
        Non-blocking annotation returned by file uploads and deletions, e.g.
        references that point at a removed file.
      properties:
        code:
          type: string
          description: >-
            Warning code. One of: `unresolved_reference` (an @ref in the written
            file's content points to a file that does not exist in the pack;
            `ref` carries it), `still_referenced_by` (the deleted file is still
            @ref-referenced by other files in the pack; `refs` lists the
            referrers).
          enum:
            - unresolved_reference
            - still_referenced_by
        ref:
          type: string
          description: Single reference related to the warning.
        refs:
          type: array
          description: Multiple references related to the warning.
          items:
            type: string
      required:
        - code
    ErrorResponse:
      type: object
      description: Response envelope for errors. `error` is required; `data` is absent.
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          description: >-
            Unique trace ID of this request; include it when reporting issues so
            logs can be located.
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    ErrorCode:
      type: string
      description: >-
        Flashduty error code enum. Every failed API response sets `error.code`
        to one of these values. The value is a stable wire string — not a
        localized message and not a numeric status. HTTP status is
        informational.
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
  responses:
    BadRequest:
      description: Invalid request — usually a missing or malformed parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              summary: Missing required parameter
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter skill_id is not valid.
    Unauthorized:
      description: Missing or invalid app_key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingAppKey:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: Unauthorized
                  message: You are unauthorized.
    Forbidden:
      description: The app_key is valid but lacks permission for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            accessDenied:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: AccessDenied
                  message: Access Denied.
    TooManyRequests:
      description: Rate limit hit. Either the global API limit or a per-account limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: Unexpected server-side error. Include the request_id when reporting.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        App key issued from the Flashduty console. Required on every public API
        call. Keep it secret — it grants the same access as the owning account.

````