Skip to main content
POST
/
jobs
/
{job_id}
/
reschedule
Reschedule a job
curl --request POST \
  --url https://api-dev.narrative.io/jobs/{job_id}/reschedule \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "force": true
}'
import requests

url = "https://api-dev.narrative.io/jobs/{job_id}/reschedule"

payload = { "force": True }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({force: true})
};

fetch('https://api-dev.narrative.io/jobs/{job_id}/reschedule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/jobs/{job_id}/reschedule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'force' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api-dev.narrative.io/jobs/{job_id}/reschedule"

payload := strings.NewReader("{\n \"force\": true\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/jobs/{job_id}/reschedule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"force\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api-dev.narrative.io/jobs/{job_id}/reschedule")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"force\": true\n}"

response = http.request(request)
puts response.read_body
{
  "job": {
    "job_id": "2a5b9ad7-dc8f-47bb-8e62-843a38f8054c",
    "data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
    "request_source": {
      "type": "api_user",
      "company_id": 1,
      "user_id": 407
    },
    "state": "completed",
    "type": "materialize-view",
    "input": {
      "nql": "CREATE MATERIALIZED VIEW \"test_stats\" AS SELECT \"value\" FROM \"company_data\".\"10674\"",
      "dataset_id": 10736,
      "stats_enabled": true,
      "compiled_select": "SELECT\n  `ds_10674`.`value`\nFROM\n  narrative.datasets.ds_10674 `ds_10674`"
    },
    "executor": "job-executor-98e1f48e-bf54-4f11-bbd1-73c445120266",
    "idempotency_key": "10736:29329c64e7b8a4eda86aaabe04872b832ab456b5543d0c259c812525391f158c:669a5f8e4f373c2f907700decde47511aac6470f5698e2b856fb07f09160e5f2",
    "result": {
      "dataset_id": 10736,
      "snapshot_id": 1724919539450264600,
      "recalculation_id": "abf9a2ec-426b-4751-bd16-fcb435061925"
    },
    "created_at": "2023-10-31T11:19:13.400498",
    "updated_at": "2023-10-31T11:25:08.327209",
    "ended_at": "2023-10-31T11:25:08.327194"
  }
}
{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}
{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

job_id
string<uuid>
required

Unique identifier for a job.

Body

application/json

Optional body for rescheduling a job. May be omitted entirely — an empty body keeps the default behavior, where rescheduling is a no-op for jobs already in a terminal state (completed, cancelled, failed).

force
boolean
default:false

When true, reschedule the job even if it is in a terminal state, resetting it to pending and clearing its executor so the operator re-dispatches it onto a fresh cluster. Use this to re-run a job that already finished. When omitted or false, terminal jobs are left untouched.

Response

OK

Result of rescheduling a job — what happened, plus the job's current state afterwards.

outcome
enum<string>
required

What a reschedule call did.

  • rescheduled — the job was put back on the queue (reset to pending, executor cleared).
  • skipped_terminal — the job was left untouched because it was already in a terminal state and force was not set.
Available options:
rescheduled,
skipped_terminal
job
object
required
Example:
{
"job_id": "2a5b9ad7-dc8f-47bb-8e62-843a38f8054c",
"data_plane_id": "f79cbdae-4848-47ca-95e8-69588364d185",
"request_source": {
"type": "api_user",
"company_id": 1,
"user_id": 407
},
"state": "completed",
"type": "materialize-view",
"input": {
"nql": "CREATE MATERIALIZED VIEW \"test_stats\" AS SELECT \"value\" FROM \"company_data\".\"10674\"",
"dataset_id": 10736,
"stats_enabled": true,
"compiled_select": "SELECT\n `ds_10674`.`value`\nFROM\n narrative.datasets.ds_10674 `ds_10674`"
},
"executor": "job-executor-98e1f48e-bf54-4f11-bbd1-73c445120266",
"idempotency_key": "10736:29329c64e7b8a4eda86aaabe04872b832ab456b5543d0c259c812525391f158c:669a5f8e4f373c2f907700decde47511aac6470f5698e2b856fb07f09160e5f2",
"result": {
"dataset_id": 10736,
"snapshot_id": 1724919539450264600,
"recalculation_id": "abf9a2ec-426b-4751-bd16-fcb435061925"
},
"created_at": "2023-10-31T11:19:13.400498",
"updated_at": "2023-10-31T11:25:08.327209",
"ended_at": "2023-10-31T11:25:08.327194"
}