Implement Run Task integration callback API support#160
Merged
Conversation
isivaselvan
reviewed
May 22, 2026
isivaselvan
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds support for Terraform Run Task integration callbacks in the Python TFE SDK.
Changes included
- sending Run Task callbacks
- receiving Terraform webhooks with FastAPI
This implementation allows users to send Run Task results back to Terraform using the callback URL and access token received in the webhook payload.
Testing plan
Unit tests
Ran:
pytest tests/units/test_run_task_integration.py -v
Verified:
End-to-end testing
Verified the integration flow locally using:
Tested flow:
- task_result_callback_url
- access_token
Example commands used:
uvicorn examples.run_task_webhook_server:app --reload --port 8000
ngrok http 8000
terraform apply
Output from tests
Unit tests completed successfully.

Example integration output:
=== EXTRACTED VALUES ===
callback_url: https://app.terraform.io/api/v2/...
access_token: v1.xxxxx...
Sending callback to: https://app.terraform.io/api/v2/...
Run task callback sent successfully
Terraform Run Task status:
Overall Result: Passed
Example Webhook output:
=== FULL PAYLOAD ===
{
"payload_version": 1,
"access_token": "Cddi7kxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"stage": "post_plan",
"is_speculative": false,
"task_result_id": "taskrs-FiaAxxxxxxxxxx",
"task_result_enforcement_level": "advisory",
"task_result_callback_url": "https://app.terraform.io/api/v2/xxxxxxxxxxxxxxxx",
"run_app_url": "https://app.terraform.io/app/prab-sandbox02/RunTask_test/runxxxxxxxxxxx",
"run_id": "run-Demxxxxxxxx",
"run_message": "Triggered via CLI",
"run_created_at": "2026-05-20T06:12:07.247Z",
"run_created_by": "tanya_singh369",
"workspace_id": "ws-Nn3Fsy8iw4voxxxx",
"workspace_name": "RunTask_test",
"workspace_app_url": "https://app.terraform.io/app/prab-sandbox02/RunTask_test",
"organization_name": "prab-sandbox02",
"vcs_repo_url": null,
"vcs_branch": null,
"vcs_pull_request_url": null,
"vcs_commit_url": null,
"configuration_version_id": "cv-Lpv2dF7xxxxxx",
"configuration_version_download_url": "https://app.terraform.io/api/v2/configuration-versions/cv-Lpv2dxxxxxx/download",
"workspace_working_directory": "",
"project_id": "prj-vhp5szCtbuxxxxxx",
"project_name": "Default Project",
"project_app_url": "https://app.terraform.io/app/prab-sandbox02/Default Project",
"plan_json_api_url": "https://app.terraform.io/api/v2/plans/plan-9DXkxxxxxxxxxx",
"capabilities": {
"outcomes": true
}
}
=== EXTRACTED VALUES ===
callback_url: https://app.terraform.io/api/v2/task-results/e8289ee8-7ab3-xxxxxxxxxxxxx/callback
access_token: Cddi7kOES2xqxA.atlasv1.pGwm9yc8xxxxxxxxxx
Sending callback to: https://app.terraform.io/api/v2/task-results/e8289ee8-7ab3-4f4f-972xxxxxxxxxx/callback
Run task callback sent successfully
INFO: 52.86.201.227:0 - "POST / HTTP/1.1" 200 OK