Cancel a running execution and any associated Google Earth Engine tasks.

Authentication: JWT token required Access: Users can cancel their own executions, ADMIN+ users can cancel any Purpose: Immediately stops execution processing, cleans up resources, and cancels any associated Google Earth Engine tasks that may have been started.

Path Parameters:

  • execution: The ID of the execution to cancel

Request: No request body required - this is a POST endpoint that triggers cancellation

Usage Examples:

# Cancel your own execution
curl -X POST "https://api.trends.earth/api/v1/execution/abc123-def456/cancel"          -H "Authorization: Bearer your_jwt_token"

# Admin canceling any user's execution
curl -X POST "https://api.trends.earth/api/v1/execution/xyz789-uvw012/cancel"          -H "Authorization: Bearer admin_jwt_token"

Success Response Schema:

{
  "data": {
    "execution": {
      "id": "abc123-def456",
      "script_id": "vegetation-analysis",
      "status": "CANCELLED",
      "params": {
        "region": "africa",
        "year_start": 2020,
        "year_end": 2023
      },
      "user_id": "user-789",
      "created_at": "2025-01-15T10:30:00Z",
      "updated_at": "2025-01-15T10:35:00Z",
      "start_time": "2025-01-15T10:31:00Z",
      "end_time": "2025-01-15T10:35:00Z",
      "progress": 100
    },
    "cancellation_details": {
      "execution_id": "abc123-def456",
      "previous_status": "RUNNING",
      "docker_service_stopped": true,
      "docker_container_stopped": false,
      "batch_jobs_terminated": [
        {
          "job_id": "aws-batch-job-id-123",
          "name": "extract",
          "previous_status": "RUNNING",
          "success": true
        }
      ],
      "gee_tasks_cancelled": [
        {
          "task_id": "6CIGR7EG2J45GJ2DN2J7X3WZ",
          "success": true,
          "error": null,
          "status": "CANCELLED"
        },
        {
          "task_id": "YBKKBHM2V63JYBVIPCCRY7A2",
          "success": true,
          "error": null,
          "status": "CANCELLED"
        }
      ],
      "errors": []
    }
  }
}

Response Fields:

  • execution: The updated execution object with CANCELLING status
  • cancellation_details: Dispatch metadata for background cancellation:
    • execution_id: ID of the execution being cancelled
    • previous_status: Status before cancellation request
    • new_status: Set to CANCELLING
    • queued: true when cancellation work was enqueued
    • task_id: Celery task ID handling cancellation
    • errors: Any immediate dispatch errors

Cancellation Process:

  1. Request transitions execution to CANCELLING
  2. API returns 202 Accepted immediately
  3. Background worker cancels compute resources and GEE tasks
  4. Background worker sets final status to CANCELLED

Cancellable States:

  • PENDING: Execution queued, waiting to start
  • READY: Execution initialized and starting
  • RUNNING: Currently executing

Non-Cancellable States:

  • FINISHED: Execution completed successfully
  • FAILED: Execution already failed
  • CANCELLED: Execution already cancelled
  • CANCELLING: Cancellation already in progress

Error Responses:

  • 400 Bad Request: Execution is not in a cancellable state
    {
      "status": 400,
      "detail": "Cannot cancel execution in FINISHED state"
    }
    
  • 409 Conflict: Cancellation is already in progress
    {
      "status": 409,
      "detail": "Cancellation already in progress for this execution"
    }
    
  • 401 Unauthorized: JWT token required
  • 403 Forbidden: User can only cancel their own executions (unless admin)
    {
      "status": 403,
      "detail": "You can only cancel your own executions"
    }
    
  • 404 Not Found: Execution does not exist
  • 500 Internal Server Error: Cancellation process failed

Partial Cancellation: The endpoint will attempt to cancel all associated resources even if some steps fail. Check the cancellation_details.errors array for any issues encountered during the process.

post/api/v1/execution/{execution}/cancel

Path parameters

executionstring required

Path parameter: execution

Request body

object required

Response

Success

object required

Changes

No recorded changes to this endpoint across all 1 revision of this API.