Is There an API to Track Credits Consumed and Frequency of Workflow Runs for External Users?

This topic was automatically generated from Slack. You can find the original thread here.

Hey , @U05FUC30Q01
we are looking to integrate credits consumed in a workflow run for our external users, is there an api support to know how many credits are consumed by a run. also is it a possibility that we could know how many times a workflow ran for a particular external user.

cc: @U095D9MBG49 @U05A7KLNALC @U094Y8Z67C4

At this time, Pipedream does not provide a public API endpoint that directly returns the number of credits consumed by a specific workflow run, nor does it provide a built-in API to filter workflow runs by an external user identifier out of the box. ### Tracking Credits Consumed Per Workflow Run - Credits Calculation: Credits are charged based on compute time and memory used per workflow segment. You can see detailed examples of how credits are calculated in the Pipedream pricing documentation. - No Direct API: There is currently no documented API to fetch the exact number of credits consumed for a given workflow run programmatically. ### Tracking Workflow Runs Per External User - No Built-in User Attribution: Pipedream does not natively track workflow runs by an “external user” field. However, you can implement this yourself: - Custom Propagation: If your workflow is triggered by an event that includes an external user identifier (e.g., a user ID in the payload), you can log or store this information in a Pipedream Data Store or an external database. - Counting Runs: You could increment a counter in a Data Store keyed by the external user ID each time the workflow runs for that user. #### Example: Counting Workflow Runs Per External User ```
export default defineComponent({ props: { data: { type: “data_store” }, userId: { type: “string”, label: “External User ID” }, }, async run({ steps, $ }) { const count = await this.data.get(this.userId) ?? 0; await this.data.set(this.userId, count + 1); return { userId: this.userId, runs: count + 1 }; }, })

Not currently but it’s on the roadmap