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

# Create a credential

> Issues a new credential for the team. The raw secret is returned only
once in the response — store it securely; subsequent list responses
only show the prefix.

The `kind` field selects the credential shape:

- `integration` (sk-) authenticates programmatic API calls.
- `agent` (ak-) authenticates headless agents to the platform.
- `device` (dk-) is reserved for the desktop device-pairing flow and
  is normally created by that flow, not directly via this endpoint.

**Auth: JWT only.** `dk-` is rejected on this endpoint so a stolen
desktop credential cannot bootstrap long-lived `sk-`/`ak-` credentials
that would survive a subsequent device revoke.




## OpenAPI

````yaml /api-reference/core-openapi.yaml post /credentials
openapi: 3.0.3
info:
  title: Cyberun API
  version: 1.0.0
  description: >
    Multi-tenant GPU orchestration platform for enterprise private deployments.


    ## Authentication


    Two authentication families are supported:


    - **JWT Bearer** (`Authorization: Bearer <jwt>`) — Used by team
    owners/admins/members
      for management endpoints and user sessions. JWT-authenticated requests that operate
      on a team **must** include the `X-Team-ID` header to select which team the request
      applies to (a user can belong to multiple teams).
    - **Credential Bearer** (`Authorization: Bearer <sk-/ak-/dk-...>`) — Unified
    machine
      credential. The credential is always scoped to a single team derived from the
      credential row, and any `X-Team-ID` header is **ignored**. The three kinds differ in
      identity and routing:

      | Kind          | Prefix | Identity                  | Allowed surfaces |
      | ------------- | ------ | ------------------------- | --- |
      | `integration` | `sk-`  | Team only                 | Runtime API (`/r/`) + the Web MCP endpoint. Rejected on every management endpoint because the authorization layer needs a user identity and `sk-` has none. |
      | `agent`       | `ak-`  | Team only                 | the platform's WebSocket handshake **only** — rejected by the REST surface at the middleware layer. |
      | `device`      | `dk-`  | Team + user (per-device)  | Runtime API and scoped management endpoints — behaves like a JWT for the underlying user. Issued by the desktop pairing flow only (`POST /desktop/pair/confirm`). |

      the authorization layer runs against the user identity carried by JWT and `dk-`. `sk-` and `ak-`
      bypass the authorization layer; service-layer checks enforce team scope for them.

    Runtime endpoints under `/r/` accept **JWT (with `X-Team-ID`)**, `sk-`, and
    `dk-`.

    `ak-` is rejected at the middleware (it is only meaningful on the the
    platform's WebSocket

    handshake). Scoped management endpoints accept **JWT (with `X-Team-ID`)** or

    `dk-`; `sk-` is rejected on management because the the authorization layer
    authorize layer

    requires a user identity. The Web MCP endpoint accepts `sk-` only.

    Multipart upload endpoints (`/uploads/multipart/*`) remain JWT-only.

    Credential-bearing callers (`sk-`, `dk-`) should use single-part presign

    (`POST /r/files/presign`) instead — that returns a vanilla S3 PUT URL

    (≤ 5 GB by S3, subject to the server's configured request cap; default

    500 MB). Files beyond the cap currently require the JWT-only multipart

    flow.


    ## Task Lifecycle


    Tasks follow this state machine: `pending → waiting → queued → running →
    completed | failed | cancelled`.

    Submit tasks via workflow run endpoints, poll status via GET
    /r/tasks/{taskId},

    and retrieve results via GET /r/tasks/{taskId}/result.


    ## Pagination


    All list endpoints support pagination via `current_page` (default: 1) and
    `per_page`

    (default: 20, max: 100) query parameters. Responses include a `page_meta`
    object

    with `current_page`, `per_page`, and `total_count`.
servers:
  - url: https://core.cyberun.cloud/api/v1
    description: Cyberun Cloud API
security: []
tags:
  - name: Auth
    description: >
      Authentication and account lifecycle: register, login, logout, token
      refresh,

      password reset, and email verification.
  - name: User
    description: |
      Current user profile management: view and update profile, change password.
  - name: Team
    description: >
      Team management: create, update, delete teams, leave, and transfer
      ownership.

      Each user gets a personal team on registration.
  - name: Member
    description: |
      Team member management: list members, update roles, and remove members.
  - name: Invitation
    description: >
      Team invitation management: invite users by email, accept/decline
      invitations,

      list pending invitations, and cancel invitations.
  - name: Credential
    description: |
      Unified credential management: integration keys (`sk-`) for programmatic
      API access, agent keys (`ak-`) for headless workers, and device keys
      (`dk-`) for paired desktop installs. All three share storage and
      revocation flow; the `kind` field selects behaviour.
  - name: DevicePair
    description: >
      Desktop device pairing flow. Three endpoints — start (anonymous),

      confirm (JWT, called from the Cyberun dashboard), poll (anonymous, called
      from

      desktop) — exchange a short user-visible code for a `dk-` credential

      without the user ever typing the secret.
  - name: Workflow
    description: >
      ComfyUI workflow template management: create, update, delete, and list
      workflow templates

      with configurable parameters, labels, timeout, and retry settings.
  - name: Task
    description: |
      Task execution and monitoring: submit workflow runs, poll task status,
      retrieve results, and cancel tasks. Tasks follow the lifecycle:
      `pending → waiting → queued → running → completed | failed | cancelled`.
  - name: Webhook
    description: >
      Webhook management: register HTTPS endpoints to receive event
      notifications

      (task.completed, task.failed) with HMAC-SHA256 signed payloads.
  - name: Container
    description: >
      Container service orchestration: deploy arbitrary Docker containers (vLLM,
      Ollama,

      custom services) to agents, manage lifecycle, and proxy HTTP requests
      through

      the gateway with load balancing.
  - name: CloudProvider
    description: >
      Cloud compute provider management: configure third-party cloud GPU
      provider

      API keys (e.g. ComfyUI Cloud) for teams without local GPU agents, and

      manage automatic cloud fallback settings.
  - name: Notifications
    description: |
      In-app notification center: list, read, and manage notifications
      for status changes and system alerts.
  - name: Agent
    description: >
      Agent monitoring: view connected agents for a team, including their
      status,

      labels, and current task. Data is read from the the platform's runtime
      state.
  - name: Node
    description: |
      Custom node management: upload, register, update, and delete ComfyUI
      custom node packages (zip archives) for team-scoped agents.
  - name: Model
    description: |
      Model management: upload, register, update, and delete AI model files
      (checkpoints, LoRAs, etc.) for team-scoped agents.
  - name: File
    description: >
      File upload for workflow inputs: request presigned upload URLs to stage
      files

      (images, videos, audio) in S3, then reference them as `type: file`
      parameters

      when running workflows.
  - name: Upload
    description: >
      Multipart upload support for large files: initiate, presign parts,
      complete,

      and abort multipart uploads. Used alongside domain-specific presign
      endpoints

      for files exceeding ~100 MB.
  - name: Server
    description: |
      Public server information: registration status and other configuration
      visible to unauthenticated clients.
paths:
  /credentials:
    parameters:
      - $ref: '#/components/parameters/TeamIdHeader'
    post:
      tags:
        - Credential
      summary: Create a credential
      description: |
        Issues a new credential for the team. The raw secret is returned only
        once in the response — store it securely; subsequent list responses
        only show the prefix.

        The `kind` field selects the credential shape:

        - `integration` (sk-) authenticates programmatic API calls.
        - `agent` (ak-) authenticates headless agents to the platform.
        - `device` (dk-) is reserved for the desktop device-pairing flow and
          is normally created by that flow, not directly via this endpoint.

        **Auth: JWT only.** `dk-` is rejected on this endpoint so a stolen
        desktop credential cannot bootstrap long-lived `sk-`/`ak-` credentials
        that would survive a subsequent device revoke.
      operationId: createCredential
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCredentialRequest'
      responses:
        '201':
          description: Credential created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCredentialResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
      security:
        - bearerAuth: []
components:
  parameters:
    TeamIdHeader:
      name: X-Team-ID
      in: header
      required: true
      description: >
        UUID of the team to scope the request to. Required on all team-scoped
        JWT

        endpoints because a user may belong to multiple teams.
      schema:
        type: string
        format: uuid
        example: 019abc12-4567-7890-abcd-ef1234567891
  schemas:
    CreateCredentialRequest:
      type: object
      required:
        - kind
        - display_name
      properties:
        kind:
          $ref: '#/components/schemas/CreatableCredentialKind'
        display_name:
          type: string
          minLength: 1
          maxLength: 100
          description: >-
            Human-readable label for the credential (shown back in the list
            view).
          example: CI bot
        expires_in_days:
          type: integer
          minimum: 1
          maximum: 365
          description: >
            Optional expiry, in **days** from creation. Integer between 1 and
            365

            inclusive. If omitted, the credential never expires until manually

            revoked.
          example: 90
    CreateCredentialResponse:
      type: object
      required:
        - id
        - kind
        - key_prefix
        - raw_key
      properties:
        id:
          type: string
          format: uuid
          description: UUID of the credential row.
        kind:
          $ref: '#/components/schemas/CredentialKind'
        key_prefix:
          type: string
          description: The first 12 characters of the raw key, e.g. "sk-abcd1234..".
          example: sk-abcd1234
        raw_key:
          type: string
          description: |
            The full secret. **Shown only once** — store it securely; subsequent
            list responses only show the prefix.
          example: sk-abcdefghijklmnop...
    CreatableCredentialKind:
      type: string
      description: >
        Subset of `CredentialKind` permitted in `POST /credentials`. Excludes

        `device` because `dk-` credentials must come from
        `/desktop/pair/confirm`

        (which binds the credential to the confirming user's JWT). Direct

        `POST /credentials { kind: "device" }` is rejected by the service layer

        even if a client sends it.
      enum:
        - integration
        - agent
      example: integration
    CredentialKind:
      type: string
      description: >
        Type of credential. Each kind shares the same storage shape but has
        different

        behaviour:

        - `integration` (`sk-...`): team-scoped programmatic key. Carries no
        user
          identity; used by CI bots, third-party integrations, scripts.
        - `agent` (`ak-...`): team-scoped agent key. Used by headless workers
          connecting to the platform's WebSocket. **Rejected by the REST surface** — see
          the carrier table at the top of the spec.
        - `device` (`dk-...`): per-user, team-scoped key issued by the desktop
          device-pairing flow (`POST /desktop/pair/confirm`). Carries `user_id`
          so the authorization layer can run against the actual user. **Cannot be issued via
          `POST /credentials`** — use the pairing flow.
      enum:
        - integration
        - agent
        - device
      example: integration
    ErrorResponse:
      type: object
      required:
        - error_message
      properties:
        error_message:
          type: string
          description: Human-readable error message describing what went wrong.
          example: resource not found
  responses:
    BadRequest:
      description: >-
        Invalid request: missing required fields, validation failure, or
        malformed input.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: 'Authentication failed: missing, expired, or invalid JWT/API key.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: >-
        Insufficient permissions: the authenticated user does not have the
        required role or the authorization layer policy.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        User session JWT (Bearer <jwt>). Must be paired with the `X-Team-ID`
        request header on team-scoped endpoints so the server knows which
        team's resources to operate on.

````