Nairi APIAutomationsScheduled jobsRun now

Run now

Fire a scheduled job once, right now, without waiting for its next tick. The run posts to the job's channel like a scheduled one and shows up in its runs history as manual.

Runs the job once, now. The schedule itself is untouched: the next tick still fires when it was going to.

POST /api/public/v1/scheduled-jobs/{id}/run

No request body. Requires an API key with the automations:write scope.

What happens

  1. Nairi starts a conversation for the job's prompt, on the job's agent (or the channel's default agent), and posts into the channel exactly as a scheduled tick would.
  2. The response is 202 Accepted with the job_id of the conversation it started. The agent's work continues after the response.
  3. The run appears in Runs with trigger: "manual" and triggered_by set to {"type": "api_key", "id": "pak_…"}, the API key that fired it.

A disabled job can be run this way too; is_enabled only governs the schedule.

Example

curl -X POST https://api.nairi.ai/api/public/v1/scheduled-jobs/SCHEDULED_JOB_ID/run \
  -H "Authorization: Bearer $NAIRI_API_KEY"
const res = await fetch(
  `https://api.nairi.ai/api/public/v1/scheduled-jobs/${scheduledJobId}/run`,
  {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.NAIRI_API_KEY}` },
  },
);
const data = (await res.json()) as { job_id: string };
require "net/http"
require "json"
require "uri"

uri = URI("https://api.nairi.ai/api/public/v1/scheduled-jobs/#{scheduled_job_id}/run")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['NAIRI_API_KEY']}"

res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
data = JSON.parse(res.body)
import os
import requests

res = requests.post(
    f"https://api.nairi.ai/api/public/v1/scheduled-jobs/{scheduled_job_id}/run",
    headers={"Authorization": f"Bearer {os.environ['NAIRI_API_KEY']}"},
)
data = res.json()
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	scheduledJobID := os.Getenv("SCHEDULED_JOB_ID")
	req, _ := http.NewRequest(
		"POST",
		"https://api.nairi.ai/api/public/v1/scheduled-jobs/"+scheduledJobID+"/run",
		nil,
	)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("NAIRI_API_KEY"))
	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	raw, _ := io.ReadAll(res.Body)
	var data map[string]any
	json.Unmarshal(raw, &data)
	fmt.Println(data)
}

Response: 202 Accepted

{
  "job_id": "job_01KRK1V46BXS73CSNK2VR35NPJ"
}

Errors

StatusBodyWhen
404{"error":"scheduled job not found"}No scheduled job with that id in your organization.
409{"error":"…"}The job points at a channel or integration that no longer exists. The message says which; fix the job with Update and try again.
400{"error":"scheduled job ID must be a valid ULID"}The id is malformed.
403The API key does not have the automations:write scope.

On this page