New v2 API Endpoint: job approval

We have a new API endpoint available to allow you to approve jobs programatically. The endpoint is:

POST /api/v2/workflow/:id/approve/:approval-request-id

You can find the approval_request_id of the job you wish to approve via the listWorkflowJobs endpoint:

GET /api/v2/workflow/:id/job

Jobs that can be approved (i.e. approval jobs) will have an approval_request_id field.

See the v2 API docs for more details. Happy approving!

3 Likes

Thanks for creating this endpoint. It’s very useful. I’m not able to use it successfully, though. I get a 404 when I try to make a POST request. I triple checked that I have the right workflow and approval request IDs. I also confirmed I have a working personal token because I’m able to make other GET requests. Any idea why this one might be returning a 404?

I know what I did wrong. I’ve been using RestClient in Ruby, and for GET requests, I’ve been passing in the token via the params, as in RestClient.get some_endpoint, params: { "circle-token" => my_token }, but that doesn’t work for post requests. The token needs to be appended to the endpoint, as in https://circleci.com/api/v2/workflow/{workflow_id}/approve/{approval_request_id}?circle-token=my_token. If I try that with the job that I was trying to approve earlier (and that I ended up approving manually), then I get a 400 error saying the job was already approved, which is expected.

1 Like

@johnswanson This is really cool! have been waiting a while for this :slight_smile:

Any chance you can expose attributions via admins? I want to build an app that allows approvals from slack, and instead of me asking all my team for their circle tokens, i’ll use the token of a bot which is an admin and pass in sonething like on_behalf_of which thwn marks the job approves by that user.

I realize this is probably a huge ask, but curious if this can be planned

1 Like