# 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.

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

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

## What happens [#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](/api/scheduled-jobs/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 [#example]

<Tabs items="[&#x22;bash&#x22;, &#x22;TypeScript&#x22;, &#x22;Ruby&#x22;, &#x22;Python&#x22;, &#x22;Go&#x22;]">
  <Tab value="bash">
    ```bash
    curl -X POST https://api.nairi.ai/api/public/v1/scheduled-jobs/SCHEDULED_JOB_ID/run \
      -H "Authorization: Bearer $NAIRI_API_KEY"
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    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 };
    ```
  </Tab>

  <Tab value="Ruby">
    ```ruby
    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)
    ```
  </Tab>

  <Tab value="Python">
    ```python
    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()
    ```
  </Tab>

  <Tab value="Go">
    ```go
    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)
    }
    ```
  </Tab>
</Tabs>

## Response: `202 Accepted` [#response-202-accepted]

```json
{
  "job_id": "job_01KRK1V46BXS73CSNK2VR35NPJ"
}
```

## Errors [#errors]

| Status | Body                                                | When                                                                                                                                                           |
| ------ | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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](/api/scheduled-jobs/update) and try again. |
| `400`  | `{"error":"scheduled job ID must be a valid ULID"}` | The id is malformed.                                                                                                                                           |
| `403`  |                                                     | The API key does not have the `automations:write` scope.                                                                                                       |
