{
  "name": "Track monthly OpenAI token usage with Google Sheets and Gmail reports",
  "nodes": [
    {
      "id": "78fca6be-db2a-4b21-88ca-3d64e6881b32",
      "name": "Fetch OpenAI Usage Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        32,
        144
      ]
    },
    {
      "id": "2d0bd1b3-bba6-4bf0-8b3a-a52b2382e664",
      "name": "Transform Usage to Daily Breakdown",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        144
      ]
    },
    {
      "id": "96775d45-7c96-4888-960c-14058f627f17",
      "name": "Append Data to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        448,
        144
      ]
    },
    {
      "id": "77773788-5d6a-4a91-bd46-601d4fdbc6ff",
      "name": "Create Monthly Report from Template",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -240,
        144
      ]
    },
    {
      "id": "4b6b6fea-51b8-47c1-95b5-51cc7716b5d9",
      "name": "Export Sheet as Excel",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        704,
        64
      ]
    },
    {
      "id": "5d0e6993-e7ed-4a5a-a344-0fded932b4ec",
      "name": "Archive Report to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        944,
        64
      ]
    },
    {
      "id": "c739b7b5-c19f-405c-8862-44012dbaa49a",
      "name": "Email Report to Stakeholder",
      "type": "n8n-nodes-base.gmail",
      "position": [
        944,
        208
      ]
    },
    {
      "id": "d886ba78-d654-4ecc-9bb9-5b4f22e36ac0",
      "name": "Export Sheet as PDF for Email",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        704,
        208
      ]
    },
    {
      "id": "ac6f42bc-d87b-4a45-a23a-4703d170154e",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -400
      ],
      "parameters": {
        "width": 460,
        "height": 1316,
        "content": "## Track OpenAI Token Usage with Automated Monthly Reports\n\nThis workflow automatically monitors your OpenAI API usage and costs on a monthly basis. Perfect for finance teams and developers who need t"
      }
    },
    {
      "id": "838ae489-19f4-480c-a6a8-a9962cdf752d",
      "name": "Monthly Report Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -528,
        144
      ]
    },
    {
      "id": "c75ec0dc-4d1b-481a-b8e9-28e2d07d225e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -144
      ],
      "parameters": {
        "width": 608,
        "height": 544,
        "content": "## Step 2: Fetch and Process Usage Data\n\nRetrieves OpenAI usage data for the previous month via API, transforms it into a daily breakdown by model (input/output tokens), and populates the Google Sheet"
      }
    },
    {
      "id": "9bb45d33-875c-4286-9df8-6830cf04288e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -144
      ],
      "parameters": {
        "width": 896,
        "height": 544,
        "content": "## Step 3: Generate and Distribute Report\n\nDownloads the completed sheet as both PDF and Excel formats, emails the PDF to stakeholders with usage summary, and archives the Excel file in Google Drive f"
      }
    },
    {
      "id": "b3e56d33-58f6-479d-b00a-9722601489c0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        -144
      ],
      "parameters": {
        "width": 544,
        "height": 544,
        "content": "## Step 1: Initialize Monthly Report\n\nTriggers on the 5th of each month and copies the Google Sheets template with proper naming convention (e.g., 'Token_Tracking_December_2025').\n\n**Update:** Set you"
      }
    }
  ],
  "connections": {
    "Export Sheet as Excel": {
      "main": [
        [
          {
            "node": "Archive Report to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monthly Report Trigger": {
      "main": [
        [
          {
            "node": "Create Monthly Report from Template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch OpenAI Usage Data": {
      "main": [
        [
          {
            "node": "Transform Usage to Daily Breakdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Data to Google Sheet": {
      "main": [
        [
          {
            "node": "Export Sheet as Excel",
            "type": "main",
            "index": 0
          },
          {
            "node": "Export Sheet as PDF for Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export Sheet as PDF for Email": {
      "main": [
        [
          {
            "node": "Email Report to Stakeholder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Usage to Daily Breakdown": {
      "main": [
        [
          {
            "node": "Append Data to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Monthly Report from Template": {
      "main": [
        [
          {
            "node": "Fetch OpenAI Usage Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}