開発中の機能
公開API
アクション
アクション一覧

アクション一覧

指定した環境で利用できるアクションの一覧を取得します。レスポンスには各アクションの引数スキーマも含まれるため、このAPIだけでアクション実行に必要な情報をまとめて取得できます。

エンドポイント

GET /projects/{project_id}/environments/{environment_id}/actions

認証・共通ヘッダー・エラー形式は公開APIとはを参照してください。

パスパラメータ

名前必須説明
project_idstring必須対象プロジェクトのID
environment_idstring必須対象環境のID

クエリパラメータ

名前必須説明
limitinteger任意1ページあたりの取得件数。1100、デフォルト20
cursorstring任意前ページのレスポンスのnext_cursorを不透明な値としてそのまま指定する(^[A-Za-z0-9+/=_-]+$

リクエスト例

curl https://platform.basemachina.com/public/v1/projects/csi2hcc0iaejrqgivkfg/environments/9m4e2mr0ui3e8a215n4g/actions \
  -H "Authorization: Bearer $BM_TOKEN"

レスポンス

ステータス200 OKで、以下のenvelope形式が返ります。

{
  "data": [
    {
      "id": "send_email",
      "name": "メール送信",
      "description": "ユーザーにメール本文を送信する",
      "input_schema": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string",
            "description": "ユーザーID",
            "x-basemachina-input-type": "text"
          },
          "subject": {
            "type": "string",
            "x-basemachina-input-type": "text"
          },
          "body": {
            "type": "string",
            "x-basemachina-input-type": "text",
            "x-basemachina-multiline": true
          }
        },
        "required": ["user_id", "subject", "body"],
        "additionalProperties": false
      }
    }
  ],
  "has_more": false
}

has_moretrueのときは、レスポンスにnext_cursorが含まれます。has_morefalseの場合、next_cursorは省略されます。次ページの取得情報はレスポンスボディのみで提供され、Linkなどのヘッダーは付与されません。

envelopeのフィールド

フィールド説明
dataarrayアクションリソースの配列。最大100件
has_moreboolean次ページが存在するかどうか
next_cursorstring次ページ取得用のカーソル。has_moretrueの場合のみ含まれる

data[]の各フィールド

フィールド説明
idstringアクションの識別子。実行時のパスパラメーターに使用する
namestring管理画面に表示されるアクション名
descriptionstringアクションの説明文
input_schemaobject引数のJSON Schema(2020-12 draft)。後述の引数スキーマを参照
無効化されたアクションはdata[]に含まれません。

引数スキーマ(input_schema)

input_schemaはJSON Schema 2020-12形式です。ベースマキナ独自の入力タイプはx-basemachina-input-typeをdiscriminatorとして表現されます。

ベースマキナの入力タイプJSON Schemaでの表現
テキスト{ "type": "string", "x-basemachina-input-type": "text" }patternminLengthmaxLengthenumなどの制約がつく場合あり)
数値{ "type": "number", "x-basemachina-input-type": "number" }minimummaximumenumなどの制約がつく場合あり)
真偽値{ "type": "boolean", "x-basemachina-input-type": "bool" }
日時{ "type": "string", "format": "date-time", "x-basemachina-input-type": "date" }(日付のみの場合はformat: "date"
SQL{ "type": "string", "format": "sql", "x-basemachina-input-type": "sql" }
ファイル{ "type": "string", "contentEncoding": "base64", "contentMediaType": "image/png", "x-basemachina-input-type": "file", "readOnly": true }
JSON値(テキスト){ "type": "string", "x-basemachina-input-type": "json_text" }
JSON値(数値){ "type": "number", "x-basemachina-input-type": "json_number" }
JSON値(日時){ "type": "string", "format": "date-time", "x-basemachina-input-type": "json_date" }(日付のみの場合はformat: "date"
配列{ "type": "array", "x-basemachina-input-type": "array", "items": {...} }
タプル{ "type": "array", "x-basemachina-input-type": "tuple", "prefixItems": [...], "minItems": N, "maxItems": N }

enum制約付きのテキスト・数値・SQL入力では、表示用ラベルがx-basemachina-select-labelsに格納されることがあります。

{
  "type": "string",
  "enum": ["admin", "member"],
  "x-basemachina-select-labels": { "admin": "管理者", "member": "一般" }
}

エラー

ステータスcode発生条件
401unauthorizedAuthorizationヘッダー欠落・トークン検証失敗
422argument_invalidlimitが範囲外、cursorの形式不正など、クエリパラメータの値が不正
500internal_errorgatewayまたは内部APIの障害

エラーコードの詳細は公開APIとはを参照してください。

次のステップ