0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Toggl APIを使って定型稼働をまとめて登録する方法

Posted at

行いたいこと

toggl trackにおいて、決まった稼働時間を繰り返し入力したい。
しかし、GUIで操作をするのは面倒であるためターミナルから一括登録する。

APIの制限に注意してください。記事投稿時点では無料プランで、1時間あたり30リクエストです。https://support.toggl.com/en/articles/11484112-api-webhook-limits-are-changing

事前準備

  • プロフィールのページよりAPI tokenを取得
    スクリーンショット 2025-07-10 20.45.02.png
  • workspace idを取得(${TOGGL_API_TOKEN}に上記で取得したものを用いる)
curl -u ${TOGGL_API_TOKEN}:api_token https://api.track.toggl.com/api/v9/me 
  • project idを取得({workspace id}に上記で取得したものを用いる)
curl -u ${TOGGL_API_TOKEN}:api_token https://api.track.toggl.com/api/v9/workspaces/{workspace id}/projects

コマンド

例: 7月7日~11日の9:00~17:00勤務を入力する(12:00~13:00で休憩)を2回に分けて入力

for i in {7..11}; do
curl -u ${TOGGL_API_TOKEN}:api_token \
-H "Content-Type: application/json" \
-X POST https://api.track.toggl.com/api/v9/workspaces/{workspace id}/time_entries \
-d '{
"description": "会社勤務",
"start": "2025-07-'${i}'T09:00:00+09:00",
"stop": "2025-07-'${i}'T12:00:00+09:00",
"wid": {workspace id},
"project_id": {project id},
"created_with": "curl"
}'
done
for i in {7..11}; do
curl -u ${TOGGL_API_TOKEN}:api_token \
-H "Content-Type: application/json" \
-X POST https://api.track.toggl.com/api/v9/workspaces/{workspace id}/time_entries \
-d '{
"description": "会社勤務",
"start": "2025-07-'${i}'T13:00:00+09:00",
"stop": "2025-07-'${i}'T17:00:00+09:00",
"wid": {workspace id},
"project_id": {project id},
"created_with": "curl"
}'
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?