Administrator

POST /core/v1/admin/credits

Administrator · POST /core/v1/admin/credits

Authentication

Administrator. Session/administrative writes are not executed in the public Playground.

Endpoint

curl --request POST 'https://api.oneaster.ai/core/v1/admin/credits' \
  --header 'Authorization: Bearer '"$ONEASTER_SESSION_TOKEN" \
  --header 'Idempotency-Key: '"$ONEASTER_INTENT" \
  --header 'Content-Type: application/json' \
  --data "$REQUEST_BODY_JSON"

Parameters

- Idempotency-Key (header, Required): {"type":"string","minLength":1,"maxLength":100}

Request JSON Schema

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "user_id": {
      "type": "string",
      "pattern": "^[0-9]+$"
    },
    "amount_micro": {
      "type": "string",
      "pattern": "^[0-9]+$",
      "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
    },
    "reference": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    }
  },
  "required": [
    "user_id",
    "amount_micro",
    "reference"
  ]
}

Responses

200

相同幂等请求已入账

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "reused": {
              "const": true
            }
          },
          "required": [
            "reused"
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

201

管理员发放邀请额度;不是支付

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "reused": {
              "type": "boolean"
            }
          },
          "required": [
            "reused"
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

default

错误代码见 core-api.md;供应商/数据库错误已隐藏。

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": false
        },
        "error": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "type": {
              "const": "oneaster_error"
            }
          },
          "required": [
            "code",
            "message",
            "type"
          ]
        },
        "data": {
          "type": "null"
        }
      },
      "required": [
        "success",
        "error",
        "data"
      ]
    }
  }
}