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

アクション一覧

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

エンドポイント

GET /environments/{environment_id}/actions

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

パスパラメータ

名前必須説明
environment_idstring必須対象環境のID(env_で始まるULID)。管理画面の環境設定で確認できる

クエリパラメータ

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

リクエスト例

curl https://platform.basemachina.com/public/v1/environments/env_01H.../actions \
  -H "Authorization: Bearer $BM_TOKEN" \
  -H "Basemachina-Project: prj_01H..."

レスポンス

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

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

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

envelopeのフィールド

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

data[]の各フィールド

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

引数スキーマ(input_schema)

input_schemaはJSON Schema 2020-12形式で、ベースマキナ独自の入力タイプはx-basemachina-*拡張で表現されます。

ベースマキナの入力タイプJSON Schemaでの表現
テキスト{ "type": "string", "x-basemachina-input-type": "text" }patternminLengthmaxLengthenumなどの制約がつく場合あり)
数値{ "type": "number", "x-basemachina-input-type": "number" }minimummaximumがつく場合あり)
真偽値{ "type": "boolean", "x-basemachina-input-type": "bool" }
日時{ "type": "string", "format": "date-time", "x-basemachina-input-type": "date", "x-basemachina-date-granularity": "datetime" }
SQL{ "type": "string", "x-basemachina-input-type": "sql", "x-basemachina-format": "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", "x-basemachina-date-granularity": "datetime" }
配列{ "type": "array", "x-basemachina-input-type": "array", "items": {} }
タプル{ "type": "array", "x-basemachina-input-type": "tuple", "prefixItems": [...], "minItems": N, "maxItems": N }

enum制約付きのテキスト入力では、表示用ラベルがx-basemachina-select-labelsに格納されます。

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

エラー

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

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

次のステップ