B3

B3 CU API

The CU API from B3 — 4 operation(s) for cu.

OpenAPI Specification

b3-cu-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  description: Workflow management API for B3OS
  title: B3OS Workflow Action CU API
  version: '1.0'
tags:
- name: CU
paths:
  /v1/cu/costs:
    get:
      description: Get the complete CU cost list for all triggers and actions (public, no auth)
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCUCostsSuccessResponse'
          description: OK
      summary: Get CU costs
      tags:
      - CU
  /v1/organizations/{orgId}/cu:
    get:
      description: Get current CU balance and minimum threshold for an organization
      parameters:
      - description: Organization ID
        in: path
        name: orgId
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCUBalanceSuccessResponse'
          description: OK
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Internal Server Error
      summary: Get CU balance and threshold
      tags:
      - CU
  /v1/organizations/{orgId}/cu/threshold:
    put:
      description: Update the CU minimum balance threshold for an organization (admin only)
      parameters:
      - description: Organization ID
        in: path
        name: orgId
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
              - type: object
              - $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_service_cu.UpdateThresholdParams'
                summary: body
                description: Threshold parameters
        description: Threshold parameters
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateCUThresholdSuccessResponse'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Bad Request
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Forbidden
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Internal Server Error
      summary: Update CU min threshold
      tags:
      - CU
  /v1/organizations/{orgId}/cu/usage:
    get:
      description: Get CU usage breakdown for a specific month
      parameters:
      - description: Organization ID
        in: path
        name: orgId
        required: true
        schema:
          type: string
      - description: Year-Month in YYYY-MM format
        in: query
        name: yearMonth
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCUUsageSuccessResponse'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Bad Request
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse'
          description: Internal Server Error
      summary: Get CU usage
      tags:
      - CU
components:
  schemas:
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUsageSummaryTotals:
      properties:
        deposited:
          type: number
        granted:
          type: number
        used:
          type: number
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_service_cu.UpdateThresholdParams:
      properties:
        minThreshold:
          type: number
      type: object
    GetCUUsageSuccessResponse:
      properties:
        code:
          example: 0
          type: integer
        data:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUsageSummary'
        message:
          example: successfully
          type: string
        requestId:
          example: req_abc123
          type: string
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUsageBreakdown:
      properties:
        count:
          type: integer
        cu:
          type: number
        nodeType:
          type: string
        type:
          description: '"trigger" or "action"'
          type: string
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUGetBalanceResult:
      properties:
        balance:
          type: number
        minThreshold:
          type: number
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUsageSummary:
      properties:
        daily:
          items:
            $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUDailyUsage'
          type: array
          uniqueItems: false
        summary:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUsageSummaryTotals'
        yearMonth:
          type: string
      type: object
    GetCUBalanceSuccessResponse:
      properties:
        code:
          example: 0
          type: integer
        data:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUGetBalanceResult'
        message:
          example: successfully
          type: string
        requestId:
          example: req_abc123
          type: string
      type: object
    UpdateCUThresholdSuccessResponse:
      properties:
        code:
          example: 0
          type: integer
        data:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUpdateThresholdResult'
        message:
          example: successfully
          type: string
        requestId:
          example: req_abc123
          type: string
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostsResult:
      properties:
        actions:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostActionsByCategory'
        defaults:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostDefaults'
        triggers:
          items:
            $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostItem'
          type: array
          uniqueItems: false
      type: object
    GetCUCostsSuccessResponse:
      properties:
        code:
          example: 0
          type: integer
        data:
          $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostsResult'
        message:
          example: successfully
          type: string
        requestId:
          example: req_abc123
          type: string
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostDefaults:
      properties:
        builtIn:
          type: number
        dynamic:
          type: number
        logic:
          type: number
        trigger:
          type: number
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUpdateThresholdResult:
      properties:
        newThreshold:
          type: number
        oldThreshold:
          type: number
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostItem:
      properties:
        cost:
          type: number
        source:
          description: '"default" or "override"'
          type: string
        type:
          type: string
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUDailyUsage:
      properties:
        breakdown:
          items:
            $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUUsageBreakdown'
          type: array
          uniqueItems: false
        date:
          type: string
        used:
          type: number
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_app_api_http.ErrorResponse:
      properties:
        code:
          type: integer
        details:
          items: {}
          type: array
          uniqueItems: false
        message:
          type: string
        requestId:
          type: string
      type: object
    github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostActionsByCategory:
      properties:
        builtIn:
          items:
            $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostItem'
          type: array
          uniqueItems: false
        dynamic:
          items:
            $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostItem'
          type: array
          uniqueItems: false
        logic:
          items:
            $ref: '#/components/schemas/github_com_b3-fun_b3-mono_services_b3os-workflow_internal_pkg_entity.CUCostItem'
          type: array
          uniqueItems: false
      type: object