[TRI-1135] Add job management API endpoints
We need to flesh out our API to allow you to manage jobs and runs:
- Get a list of runs for a specific job (with filtering for status, environment, etc.)
- Get task data for a specific run
- Cancel a run
- Retry a run
- Resume a run
- Test a job
These would ideally all be exposed via the TriggerClient class and would require the Server API Key to access.
/bounty $200
💎 $200 bounty • Trigger.dev (YC W23)
Steps to solve:
- Start working: Comment
/attempt #388with your implementation plan - Submit work: Create a pull request including
/claim #388in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
Thank you for contributing to triggerdotdev/trigger.dev!
@fvckDesa is already attempting to complete #388 and claim the bounty. If you attempt to complete the same issue, there is a chance that @fvckDesa will complete the issue first, and be awarded the bounty. Try discussing with @fvckDesa and potentially collaborating on the same solution versus creating an alternate solution.
@ericallam you can already get runs for a job, and get info about a run using the SDK
@matt-aitken private data or just public?
BTW the reason I created this issue is because of this scenario:
https://github.com/triggerdotdev/trigger.dev/issues/386#issuecomment-1690604407
Hold off on working on this for now, I think there's a discussion that needs to be had first about if it makes sense to use the Project API Key's for these management API endpoints or if we should have another type of API key that works across projects & environments. A sort of "Personal Access Token" type API Key, similar to the Supabase Management API works
@Chigala @fvckDesa don't work on this. We need to think more about how this works.
Yea this feature will require a new type of API Key called a Personal Access Token:
These API Keys have authorization the "Management APIs", some of which are mentioned above. The endpoints should be different from our current API endpoints (maybe something like /manage/api/v1/...)
You should be able to create multiple personal access tokens, and we don't create one for you by default. The PAT should look like tr_pat_XXXXXXXXXXXXXX.
PATs should also be revokable. They should be stored in a new table called PersonalAccessToken and belong to a specific User. The PersonAccessToken table should have a lastAccessedAt column that should be updated anytime the PAT is used and that value should be displayed in the list of PATs
@ericallam using personal access tokens for the management APIs makes more sense. This is how the PAT table would be modelled right?
model PersonalAccessToken {
id String @id @default(cuid())
token String @unique
revoked Boolean @default(false)
revokedAt DateTime?
lastAccessedAt DateTime
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
}
When a PAT is revoked, should we just take this my approach of a soft delete or remove the token from the DB?
Yea I think you don't need the revoked column, you can just use revokedAt. Also lastAccessedAt should be optional. everything else looks good
Ohk, Thanks. Are there any more changes on your end about this? If no, that means I can start working on it right?
@Chigala I would let @neo773 take this one for now, as he started on it last night
That's ohk
@fvckDesa: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
@Chigala: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
this seems easy why and august in the tech world is ages ago so how comes no one has finished it. or claimed the reward anyways is this still open ?
@dennismzia I had a PR for this but the trigger management have put it on hold for now.
I would really benefit from this functionality as right now our end users have no way of retrying a job run if it fails. Either a management API or even returning the run's payload info in getRun() or useEventRunDetails(), would enable users to retry failed runs. Is there any update on this?
@andrewlu0 we've recently released a new API for exposing run data to the public called Run Statuses:
https://trigger.dev/docs/documentation/guides/react-hooks-statuses
Would that help in your case?
@VirtualDharm: The Trigger.dev (YC W23) team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.
@ericallam Can I work on this?
@rishi-raj-jain They put it on hold since they needed a few prerequisite changes prior to merging my PR. Not sure what the status is now. You could use my closed PR as base if you'd wish https://github.com/triggerdotdev/trigger.dev/pull/406
@vinfinity7: The Trigger.dev (YC W23) team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.
/attempt #388
@xiaoqixing: The Trigger.dev (YC W23) team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.
/attempt #388