Skip to main content
Version: Next

REST API Job Lifecycle Cookbook

Overview

This guide supplements the REST API v2 reference with practical recipes for managing the complete job lifecycle: submission, monitoring, stopping, cancelling, savepoint, and recovery. It also covers authentication, performance considerations, and common errors.


1. Prerequisites

Enable the REST API in seatunnel.yaml:

seatunnel:
engine:
http:
enable-http: true
port: 8080
enable-dynamic-port: true
port-range: 100

All examples below use http://<master>:8080. Replace with your actual master host and port.


2. Job Submission

2.1 Submit a job from a config file (JSON body)

curl -X POST http://<master>:8080/submit-job \
-H "Content-Type: application/json" \
-d @job.json

Minimal job.json structure:

{
"env": {
"job.name": "my-cdc-job",
"job.mode": "STREAMING",
"checkpoint.interval": 30000
},
"source": [
{
"plugin_name": "MySQL-CDC",
"plugin_output": "mysql_cdc_result",
"base-url": "jdbc:mysql://localhost:3306/mydb",
"username": "cdc_user",
"password": "password",
"database-names": ["mydb"],
"table-names": ["mydb.orders"],
"startup.mode": "initial",
"server-id": "5400-5404"
}
],
"transform": [],
"sink": [
{
"plugin_name": "Console",
"plugin_input": ["mysql_cdc_result"]
}
]
}

2.2 Submit a job with multiple transforms (JSON format)

{
"env": {
"job.name": "etl-with-transforms",
"job.mode": "BATCH"
},
"source": [
{
"plugin_name": "FakeSource",
"plugin_output": "fake",
"row.num": 100,
"schema": {
"fields": {
"id": "int",
"name": "string",
"amount": "double"
}
}
}
],
"transform": [
{
"plugin_name": "FieldMapper",
"plugin_input": ["fake"],
"plugin_output": "after_field_map",
"field_mapper": {
"id": "user_id",
"name": "user_name"
}
},
{
"plugin_name": "Filter",
"plugin_input": ["after_field_map"],
"plugin_output": "filtered",
"fields": ["user_id", "user_name", "amount"]
}
],
"sink": [
{
"plugin_name": "Console",
"plugin_input": ["filtered"]
}
]
}

2.3 Submission response

A successful submission returns:

{
"jobId": "733584788375093248",
"jobName": "my-cdc-job"
}

Save the jobId for all subsequent lifecycle operations.


3. Job Status Query

3.1 Query a single running job

curl http://<master>:8080/job-info/<jobId>

Response fields:

FieldDescription
jobIdUnique job identifier
jobNameHuman-readable job name
jobStatusRUNNING, FINISHED, FAILED, CANCELLED
envOptionsEnv configuration applied
createTimeJob creation timestamp
jobDagDAG structure
metricsSource/sink throughput counters

3.2 Query all running jobs

curl "http://<master>:8080/running-jobs?page=1&rows=10"

3.3 Query finished jobs

curl "http://<master>:8080/finished-jobs/FINISHED?page=1&rows=10"

Use the state path parameter to filter finished jobs, for example FINISHED, FAILED, CANCELED, or SAVEPOINT_DONE.

3.4 Query job metrics only

curl http://<master>:8080/job-info/<jobId>

Key metric fields:

MetricMeaning
SourceReceivedCountTotal rows read from source
SinkWriteCountTotal rows written to sink
SourceReceivedQPSCurrent read throughput (rows/sec)
SinkWriteQPSCurrent write throughput (rows/sec)

4. Querying Job Logs

# Get the last N lines of a running job's log
curl "http://<master>:8080/logs/<jobId>"

For large deployments where log files are on individual workers, use the worker's REST port directly, or configure centralized logging (see Logging).


5. Stop, Cancel, and Savepoint Semantics

Semantics comparison

OperationWhat happensState preservedCan resume
stop (graceful)Waits for in-flight data to flushCheckpoint at stop pointYes, via --restore
stop-with-savepointGraceful stop + explicit savepoint writtenFull savepointYes, via --restore
cancel (force kill)Immediate terminationNo new state writtenOnly from last checkpoint

5.1 Graceful stop (no savepoint)

curl -X POST "http://<master>:8080/stop-job" \
-H "Content-Type: application/json" \
-d '{"jobId": "733584788375093248", "isStopWithSavePoint": false}'

5.2 Stop with savepoint

curl -X POST "http://<master>:8080/stop-job" \
-H "Content-Type: application/json" \
-d '{"jobId": "733584788375093248", "isStopWithSavePoint": true}'

The savepoint path is printed in the job log and returned in the job final state:

curl http://<master>:8080/job-info/733584788375093248 | \
python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('savepointPath', 'N/A'))"

5.3 Cancel (force)

curl -X POST "http://<master>:8080/stop-job" \
-H "Content-Type: application/json" \
-d '{"jobId": "733584788375093248", "isStopWithSavePoint": false, "force": true}'

6. Job Recovery and Restart

6.1 Restart from the latest checkpoint

Submit the job again with the jobId parameter to restore from the last successful checkpoint:

curl -X POST http://<master>:8080/submit-job \
-H "Content-Type: application/json" \
-d '{
"env": {
"job.id": "733584788375093248",
"job.name": "my-cdc-job",
"job.mode": "STREAMING",
"checkpoint.interval": 30000
},
"source": [ ... ],
"sink": [ ... ]
}'

Providing the same job.id instructs the engine to restore state from the existing checkpoint directory for that job.

6.2 Restart from a specific savepoint path

curl -X POST http://<master>:8080/submit-job \
-H "Content-Type: application/json" \
-d '{
"env": {
"job.name": "my-cdc-job-restored",
"job.mode": "STREAMING",
"checkpoint.interval": 30000,
"restore.mode": "savepoint",
"savepoint.path": "/seatunnel/checkpoint/savepoint/733584788375093248/1748595600000"
},
"source": [ ... ],
"sink": [ ... ]
}'

7. Authentication and Authorization

When basic authentication is enabled (see Security), all REST API calls must include the configured username and password.

Basic auth example

curl -u admin:password "http://<master>:8080/running-jobs?page=1&rows=10"

8. REST API Performance Considerations

job-info slowness with many finished jobs

When finished-job-state IMap grows large (thousands of entries), the /running-jobs and /finished-jobs/:state endpoints may become slow because they scan all entries.

Mitigations:

  1. Reduce history-job-expire-minutes to shorten the retention window
  2. Avoid polling finished-jobs endpoints at high frequency; cache the result in your monitoring layer
  3. For dashboards, query specific jobId directly instead of listing all jobs

Concurrent submission rate

The REST API processes submissions synchronously in the Hazelcast executor pool. For bulk submission scenarios (importing hundreds of jobs), throttle submissions to 10–20 per second to avoid overwhelming the master node.

Dynamic port allocation

If enable-dynamic-port: true, different master nodes may use different ports. Use the REST API overview endpoint to inspect the active cluster state from a reachable master:

# Inspect the cluster state from a reachable master
curl http://<master>:8080/overview | \
python3 -c "import sys,json; print(json.load(sys.stdin))"

9. Common Errors and Troubleshooting

ErrorCauseFix
HTTP 404 on any endpointREST API not enabled or wrong portSet enable-http: true and check port
Connection refusedMaster not started or firewall blocking portVerify master process is running; check firewall
jobId not found in job-infoJob has already finished or was never startedQuery /finished-jobs/:state with the expected final state
Submit returns 400 Bad RequestMalformed JSON or missing required fieldsValidate JSON; check plugin_name spelling
Job already exists with same job.idSubmitting duplicate job.id without stopping firstCancel or stop the existing job, then resubmit
Unauthorized 401Basic authentication is enabled but no credentials were providedInclude -u user:pass
Savepoint path not foundSavepoint was deleted or path is wrongCheck checkpoint storage and provide correct path

See Also