Tasks

Submit a new task

post

Submits a new task for asynchronous execution. Tasks can be one-time, delayed, or recurring. Supported task types include review environment operations (fetch, check, transition, list, unassign). Returns an operation ID that can be used to track task progress and retrieve results.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
typestring · enumRequired

The type of task to be executed

Example: fetchReviewEnvironmentPossible values:
dataobjectRequired

The data required for the task

Example: {"value":{"repoId":"repo123","directory":"/path/to/dir","username":"[email protected]","pool":"core","pooltype":"sandbox","branch":"feature/123","issue":"ISSUE-123","wait":300,"leasefor":3600},"description":"Fetch a review environment"}
lockDurationnumberOptional

Lock duration in milliseconds (default: 300000 - 5 minutes)

Example: 300000
prioritystring · enumRequired

Type of task priority

Default: lowPossible values:
scheduleTypestring · enumRequired

Type of task scheduling

Default: immediatePossible values:
scheduledForstringOptional

Scheduled execution time for one-time scheduled tasks

Example: 2024-10-27T10:00:00Z
retryConfigall ofOptional

Retry configuration for this task

recurrenceConfigall ofOptional

Configuration for recurring tasks

Responses
post
/sfp/api/tasks
POST /sfp/api/tasks HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 222

{
  "type": "fetchReviewEnvironment",
  "data": {
    "repoId": "repo123",
    "directory": "/path/to/dir",
    "username": "[email protected]",
    "pool": "core",
    "pooltype": "sandbox",
    "branch": "feature/123",
    "issue": "ISSUE-123",
    "wait": 300,
    "leasefor": 3600
  }
}
201

The task has been successfully created.

{
  "operationId": "1234567890",
  "type": "listAssignedReviewEnvironments"
}

Get task status

get

Retrieves the current status of a task including progress percentage, current step, and completion status. Use this endpoint to poll for task completion. Status values include: pending, active, completed, failed, cancelled.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
operationIdstringRequired
Responses
200

The task status has been successfully retrieved.

application/json
get
/sfp/api/tasks/{operationId}/status
GET /sfp/api/tasks/{operationId}/status HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

The task status has been successfully retrieved.

{
  "status": "completed",
  "progress": 100,
  "error": {
    "message": "Operation failed",
    "stack": "Error stack trace"
  }
}

Cancel a task

delete

Cancels a pending or active task. Completed tasks cannot be cancelled. For recurring tasks, this cancels the current execution but does not prevent future executions - use stop-recurring endpoint instead. Cancellation may not be immediate for actively running tasks.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
operationIdstringRequired
Responses
200

The task has been successfully cancelled.

application/json
delete
/sfp/api/tasks/{operationId}
DELETE /sfp/api/tasks/{operationId} HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

The task has been successfully cancelled.

{
  "message": "Task cancelled successfully"
}

Get task result

get

Retrieves the final result of a completed task. Returns error details if the task failed. Results are retained for a limited time after completion. For recurring tasks, this returns the result of the most recent execution.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
operationIdstringRequired
Responses
200

The task result has been successfully retrieved.

application/json
get
/sfp/api/tasks/{operationId}/result
GET /sfp/api/tasks/{operationId}/result HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

The task result has been successfully retrieved.

{
  "status": "completed",
  "progress": 100,
  "error": {
    "message": "Operation failed",
    "stack": "Error stack trace"
  },
  "result": {
    "data": "example result"
  }
}

Stop a recurring task

post

Stops a recurring task and prevents any future executions. Does not affect already completed executions.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
operationIdstringRequired

The ID of the recurring task to stop

Example: 123e4567-e89b-12d3-a456-426614174000
Responses
200

The recurring task has been stopped successfully.

application/json
post
/sfp/api/tasks/{operationId}/stop-recurring
POST /sfp/api/tasks/{operationId}/stop-recurring HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "message": "Recurring task stopped successfully",
  "operationId": "123e4567-e89b-12d3-a456-426614174000",
  "stoppedAt": "2024-10-26T21:43:47.000Z",
  "totalExecutions": 10,
  "lastExecutionAt": "2024-10-26T21:43:47.000Z",
  "originalEndDate": "2024-12-31T23:59:59.000Z"
}

Get all instances of a recurring task

get

Retrieves execution history for a recurring task including all past instances. Each instance shows its execution time, status, and result. Useful for monitoring recurring task performance and debugging issues. Returns empty array for non-recurring tasks.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
operationIdstringRequired
Responses
200

List of all instances of the recurring task

application/json
get
/sfp/api/tasks/{operationId}/recurring-instances
GET /sfp/api/tasks/{operationId}/recurring-instances HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

List of all instances of the recurring task

[
  {
    "status": "completed",
    "progress": 100,
    "error": {
      "message": "Operation failed",
      "stack": "Error stack trace"
    },
    "result": {
      "data": "example result"
    }
  }
]

Last updated