メインコンテンツへスキップ

概要

Sanka の REST API はワークスペース単位で動作します。発行したトークンにはワークスペースの情報が含まれ、Bearer JWT として利用します。

アクセストークンの発行

  1. Sankaで 開発者 → API を開く。
  2. トークンを作成 をクリックし、権限(POST+GET の Full Access / GET のみ Regular)を選択して作成。
  3. 表示された アクセストークン / リフレッシュトークン を安全な場所に保存(再表示不可)。

ベースURL

https://api.sanka.com/v1

認証

すべてのエンドポイントで以下を使用します。
Authorization: Bearer <access_token>
リフレッシュ: POST /api/token/refresh/{ "refresh": "<refresh_token>" } を送信。

サンプルリクエスト

受注一覧:
curl -X GET "https://api.sanka.com/v1/orders/?page=1&amount=30" \
  -H "Authorization: Bearer <access_token>"
商品一覧:
curl -X GET "https://api.sanka.com/v1/items" \
  -H "Authorization: Bearer <access_token>"
連絡先一覧:
curl -X GET "https://api.sanka.com/v1/contacts" \
  -H "Authorization: Bearer <access_token>"
サブスクリプション一覧:
curl -X POST "https://api.sanka.com/v1/subscriptions/create" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{ "cid": "<contact_or_company_id>", "subscription_status": "active", "items": [{ "id": "<item_id>", "amount": 1 }], "currency": "JPY" }'
売上請求レコード作成:
curl -X POST "https://api.sanka.com/v1/invoices/create" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{ "cid": "<contact_or_company_id>", "status": "scheduled", "items": [{ "id": "<item_id>", "amount": 1 }], "currency": "JPY" }'
トークン更新:
curl -X POST "https://api.sanka.com/api/token/refresh/" \
  -H "Content-Type: application/json" \
  -d '{ "refresh": "<refresh_token>" }'