このページの内容

APIの概要

ProcessMindへのAPIリクエスト

このガイドでは、データの取得や情報の送信、ワークフローの自動化にProcessMind APIを呼び出す方法を、例とベストプラクティスとともに説明します。

リクエスト/レスポンス形式を含む全エンドポイントの詳細は、APIリファレンスをご覧ください。

その他の例やクライアントライブラリについては、GitHubのAPI文書をご覧ください。

APIのベースURL

すべてのAPIリクエストの送信先:

https://api.processmind.com

すべてのルートは/v1以下でバージョン管理されています。機械可読形式のAPI仕様(OpenAPI 3.1)は、次の場所で確認できます。

GET https://api.processmind.com/v1/openapi.json

認証

公開OpenAPI文書(/v1/openapi.json)とMCP OAuthエンドポイントを除き、すべてのAPIリクエストでx-api-keyヘッダーにAPIキーが必要です。

x-api-key: your-api-key-here

APIキーはProcessMindアカウントの設定から取得できます。手順についてはAPIキーの取得をご覧ください。

ステータスコード

ProcessMind APIでは、標準的なHTTPステータスコードを使用します。

ステータス 意味
200 OK リクエスト成功
201 Created リソースを作成しました
204 No Content リクエスト成功、レスポンス本文なし
400 Bad Request リクエストが無効、またはパラメーターがないか無効
401 Unauthorized APIキーがないか無効
403 Forbidden 認証済みですが、この操作は許可されていません
404 Not Found リソースが存在しません
500 Internal Server Error 予期しないサーバーエラー

主な概念

  • apiKey:すべてのAPIリクエストに使う認証トークンです。
  • tenantId:ワークスペース/組織のコンテキストを識別します。アカウント設定で確認できます。
  • datatableId:データ操作の対象となるデータテーブルを識別します。ProcessMindのデータセット設定メニューにあるデータテーブルIDを取得から確認できます。

実行できる操作

ProcessMind APIでは、次の操作を実行できます。

  • テナントの管理:テナント情報の取得、設定の更新、統計情報の確認
  • ユーザーの管理:テナントや組織へのユーザーの追加、更新、削除
  • プロセスの管理:プロセスの作成、BPMNモデルのアップロード、フォルダーへの整理
  • データの接続:分析用にデータテーブルをプロセスにマッピング
  • データのアップロード:CSV/XLSXファイルをデータテーブルに直接アップロード
  • データセットの管理:データセットとデータテーブルの一覧表示、確認、削除

よく使う操作の例

以下では、ProcessMind APIでよく使う操作の例を紹介します。

アップロード用の署名付きURLを取得する

データテーブルにファイルをアップロードするには、まず署名付きURLを取得します。

const presignedUrl = await getPresignedUploadUrl({
	apiKey,
	tenantId: "tenant-123",
	datatableId: "table-456"
});
console.log(presignedUrl); // https://s3.amazonaws.com/…?X-Amz-Signature=…

データセットの一覧取得

テナント内のすべてのデータセットを取得します。

const datasets = await getDatasets({
	apiKey,
	tenantId: "tenant-123"
});
console.log(datasets);

テナント情報の取得

テナントの詳細情報を取得します。

const tenantInfo = await getTenant({
	apiKey,
	tenantId: "tenant-123"
});
console.log(tenantInfo);

プロセスの作成

テナントに新しいプロセスを作成します。

const process = await createProcess({
	apiKey,
	tenantId: "tenant-123",
	displayName: "Order to Cash"
});
console.log(process.id); // Use this ID for subsequent operations

BPMNモデルのアップロード

BPMNファイルをアップロードして、プロセスモデルを定義します。

const fs = require("fs");
const bpmnXml = fs.readFileSync("./my-process.bpmn", "utf8");

await uploadBpmn({
	apiKey,
	tenantId: "tenant-123",
	processId: "process-456",
	bpmnXml
});

プロセスへのデータのマッピング

分析用にデータテーブルをプロセスに接続します。

const mapping = await createProcessMapping({
	apiKey,
	tenantId: "tenant-123",
	processId: "process-456",
	dataTableId: "datatable-789",
	displayName: "Sales Data 2024",
	showByDefault: true
});

テナントへのユーザー追加

テナントにユーザーを追加します。

const result = await addTenantUser({
	apiKey,
	tenantId: "tenant-123",
	id: "user-456",
	email: "colleague@example.com",
	isAdminInTenant: false,
	isActiveInTenant: true,
	sendInvitationEmail: true
});

**注:**本文のロールフィールド(isAdminInTenant、access、 isDashboardViewer)は、指定された値のまま適用されます。ユーザー管理エンドポイントでは、テナント管理者向けのすべての操作が可能です。そのため、書き込み権限を持つAPIキーは、管理権限を任せられる呼び出し元にのみ発行してください。システムAPIから招待メールは送信されません。ユーザーのオンボーディングはご自身で行ってください。

ファイルのアップロード

ProcessMindにファイルをアップロードする基本的な流れは次のとおりです。

  1. getPresignedUploadUrl呼び出しを使って署名付きURLを取得します。
  2. ファイルの内容を指定して、そのURLにPUTリクエストを送信します。
  3. 署名付きURLを使うと、追加の認証情報なしでクラウドストレージに直接アップロードできます。

fetchを使った簡単な例を示します。

async function uploadFile({ apiKey, tenantId, datatableId, file }) {
	// Step 1: Obtain a presigned URL
	const uploadUrl = await getPresignedUploadUrl({ apiKey, tenantId, datatableId });
	
	// Step 2: Upload the file via PUT
	await fetch(uploadUrl, {
		method: "PUT",
		headers: {
			"Content-Type": file.type
		},
		body: file
	});
}

info

  • 署名付きURLには有効期限があります(アップロードとダウンロードでは、デフォルトで1時間です)。取得後は速やかに使用してください。
  • アップロードに失敗した場合(ネットワークの中断など)は、再試行する前に新しい署名付きURLをリクエストしてください。
  • apiKeyは必ず安全に保管し、クライアント側(公開されるフロントエンドなど)に公開しないでください。

完全なコード例

以下に、さまざまな言語でそのままコピーして使えるコード例を示します。

Bashの例:ファイルのアップロード

2回のcurl呼び出しでProcessMindにファイルをアップロードする、必要な値をすべてプレースホルダーにした最小限のBashスクリプト

Bashの例をダウンロード
#!/bin/bash
# Minimal Bash script to upload a file to ProcessMind using two curl calls, with placeholders for all values

# Replace the following placeholders with your actual values:
# <API_KEY>, <TENANT_ID>, <DATATABLE_ID>, <FILE_PATH>

curl -s -H "x-api-key: <API_KEY>" \
	"https://api.processmind.com/v1/tenant/<TENANT_ID>/datatables/<DATATABLE_ID>/uploads/presigned-url" \
	| grep -oP '"PreSignedUploadUrl"\s*:\s*"\K[^"]+' \
	| xargs -I {} curl -s -X PUT --upload-file "<FILE_PATH>" "{}"

Node.jsの例:ローカルのCSVファイルをアップロード

署名付きURLを使って、ローカルのCSVファイルをProcessMindにアップロードします。

手順:

  1. APIからアップロード用の署名付きURLを取得します。
  2. ディスクからローカルファイルを読み込みます。
  3. HTTP PUTを使って、署名付きURLにファイルをアップロードします。

設定:

  • uploadFile()の呼び出し時に、APIキー、tenantId、datatableId、filePathを指定します。
  • APIのベースURLはhttps://api.processmind.comに設定されています。
Node.jsの例をダウンロード
/**
 * Uploads a local CSV file to ProcessMind using a presigned URL.
 *
 * Steps:
 * 1. Fetch a presigned upload URL from the API.
 * 2. Read the local file from disk.
 * 3. Upload the file to the presigned URL using HTTP PUT.
 *
 * Configuration:
 * - Provide your API key, tenantId, datatableId, and filePath when calling uploadFile().
 * - The API base URL is set to https://api.processmind.com
 */

const fs = require("node:fs");

/**
 * Uploads a file to ProcessMind datatable using a presigned URL.
 * @param {string} apiKey - Your API key for authentication.
 * @param {string} tenantId - Your tenant identifier.
 * @param {string} datatableId - Your datatable identifier.
 * @param {string} filePath - Path to the file to upload.
 */

async function getApi({path, apiKey, apiUrl = "https://api.processmind.com"}) {
	try {
        const response = await fetch(`${apiUrl}${path}`, {
            method: "GET",
            headers: {
                "x-api-key": apiKey
            }
        });
        const body = await response.json();
        if (!response.ok) {
            console.error(`Error loading from API: ${response.status}, ${response.statusText}: ${body.message}`);
            return;
        }
        return body;
    } catch (err) {
        console.error("Unexpected error:", err);
    }
}

async function getPresignedUploadUrl({apiKey, tenantId, datatableId, apiUrl = "https://api.processmind.com"}) {
	return (await getApi({apiKey, path: `/v1/tenant/${tenantId}/datatables/${datatableId}/uploads/presigned-url`, apiUrl})).PreSignedUploadUrl;
}

async function getDatasets({apiKey, tenantId, apiUrl = "https://api.processmind.com"}) {
	return await getApi({apiKey, path: `/v1/tenant/${tenantId}/datasets`, apiUrl});
}

async function getTenant({apiKey, tenantId, apiUrl = "https://api.processmind.com"}) {
	return await getApi({apiKey, path: `/v1/tenant/${tenantId}`, apiUrl});
}

async function getOrganization({apiKey, tenantId, apiUrl = "https://api.processmind.com"}) {
	return await getApi({apiKey, path: `/v1/tenant/${tenantId}/organization`, apiUrl});
}

async function uploadFile({apiKey, tenantId, datatableId, filePath, apiUrl = "https://api.processmind.com"}) {
    try {
        const uploadUrl = await getPresignedUploadUrl({apiKey, tenantId, datatableId, apiUrl});

		console.log("Uploading file...");
        fs.readFile(filePath, async (err, data) => {
            if (err) {
                console.error("Error reading file:", err);
                return;
            }
            try {
                const uploadRes = await fetch(uploadUrl, {
                    method: "PUT",
                    body: data
                });
                if (!uploadRes.ok) {
                    console.error("Upload failed:", uploadRes.status, uploadRes.statusText);
                } else {
                    console.log("File uploaded successfully.");
                }
            } catch (uploadErr) {
                console.error("Error uploading file:", uploadErr);
            }
        });
    } catch (err) {
        console.error("Unexpected error:", err);
    }
}

// Export the function for use in other modules
module.exports = { 
	getPresignedUploadUrl,
	getDatasets,
	getTenant,
	getOrganization,
	uploadFile 
};

Pythonの例:ローカルのCSVファイルをアップロード

署名付きURLを使って、ローカルのCSVファイルをリモートAPIにアップロードします。

手順:

  1. APIからアップロード用の署名付きURLを取得します。
  2. ディスクからローカルファイルを読み込みます。
  3. HTTP PUTを使って、署名付きURLにファイルをアップロードします。

設定:

  • 必要に応じてapi_key、tenant_id、datatable_id、file_pathを更新します。
Pythonの例をダウンロード
"""
Uploads a local CSV file to a remote API using a presigned URL.

Steps:
1. Fetch a presigned upload URL from the API.
2. Read the local file from disk.
3. Upload the file to the presigned URL using HTTP PUT.

Configuration:
- Update api_key, tenant_id, datatable_id, file_path as needed.
"""

import requests

# === Configuration ===
api_key = ""  # API key for authentication
tenant_id = ""  # Tenant identifier
datatable_id = ""  # Datatable identifier
file_path = ""  # Path to the file to upload


print("Fetching upload URL...")
api_url = "https://api.processmind.com"  # Base API URL
presign_url = f"{api_url}/v1/tenant/{tenant_id}/datatables/{datatable_id}/uploads/presigned-url"
presign_res = requests.get(presign_url, headers={"x-api-key": api_key})
if not presign_res.ok:
	print(f"Error fetching upload URL: {presign_res.status_code}, {presign_res.reason}: {presign_res.text}")
	exit(1)

presign_body = presign_res.json()
upload_url = presign_body.get("PreSignedUploadUrl")
if not upload_url:
	print("No presigned upload URL returned.")
	exit(1)

print("Uploading file...")
with open(file_path, "rb") as f:
	upload_res = requests.put(upload_url, data=f)
if not upload_res.ok:
	print(f"Upload failed: {upload_res.status_code}, {upload_res.reason}")
else:
	print("File uploaded successfully.")

ページネーション

一覧取得エンドポイントでは、limitとoffsetのクエリパラメーターを指定できます。レスポンスはJSON配列のみで、ラッパーや合計件数は含まれません。

パラメーター 型 デフォルト 最大値
limit 整数 100 1,000(データテーブル一覧では250)
offset 整数 0 なし
GET /v1/tenant/{tenantId}/processes?limit=50&offset=100

すべての結果をページ単位で取得するには、レスポンス配列が指定したlimitより短くなる(または空になる)まで、offset += limitを指定してリクエストを繰り返します。最大値を超える値を指定すると、400で拒否されます。バージョン管理されたデータエンドポイント(データセット、バージョン、Webhook)も同じ方式です。2つのデータテーブル一覧では、limitの上限は250です。

バージョン管理と非推奨化

  • すべてのルートは/v1以下でバージョン管理されています。互換性を損なう変更は、/v1を予告なく変更するのではなく、新しいバージョンで提供します。
  • ルートの変更や削除は、リリースノートでお知らせします。
  • クライアントに影響する大きな変更は、必ず変更履歴に記載します。固定したAPIクライアントをアップグレードする前に、購読するか、変更履歴を確認してください。

次のステップ

  • APIリファレンス:リクエスト/レスポンス形式を含む、全エンドポイントの詳細な文書
  • GitHubの例:ダウンロード可能なコード例とクライアントライブラリ
  • APIキーの取得:APIキーの取得と管理方法

info

APIについてご質問やサポートが必要な場合は、サポートチームにお問い合わせいただくか、APIサンプルリポジトリで課題を登録してください。

プロセスをより良く設計し、つながりのあるアーキテクチャを構築して、管理を続けましょう。

クレジットカード不要、待ち時間なしですぐにご利用いただけます。組織の業務の進め方を、明確につながるプロセス設計として可視化します。

プロセスアーキテクチャを構築し、オーナーシップと統制を定め、あらゆる階層で役割と責任を明確にします。

無料トライアルを開始して、プロセスのガバナンス、管理、継続的な改善を支える信頼できる基盤を築きましょう。