Save a Scheduled Function draft
curl --request PATCH \
--url https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"code": "<string>"
}
'import requests
url = "https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft"
payload = { "code": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>'})
};
fetch('https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft', 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.getnexor.ai/api/public/scheduled-functions/{id}/draft",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.getnexor.ai/api/public/scheduled-functions/{id}/draft"
payload := strings.NewReader("{\n \"code\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.patch("https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"function": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"cron_expression": "<string>",
"timezone": "<string>",
"run_count": 123,
"is_active": true,
"lookup_config": {
"leads": {
"include": true,
"query": {
"filters": [
{
"column": "id",
"op": "eq",
"value": "<unknown>"
}
],
"order": [
{
"column": "id",
"ascending": false
}
],
"limit": 2
},
"filters": {
"search": "<string>",
"workflowId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"statusId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"campaignId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"activeFilter": "active",
"assignedTo": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"olderThan": {
"value": 1,
"unit": "hours"
},
"newerThan": {
"value": 1,
"unit": "hours"
},
"dateFrom": "2023-11-07T05:31:56Z",
"dateTo": "2023-11-07T05:31:56Z",
"sortBy": "created_at",
"sortDir": "asc"
},
"limit": 2
},
"agents": {
"include": false
},
"hosts": {
"include": false
}
},
"max_leads_per_cycle": 250,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"next_run_at": "2023-11-07T05:31:56Z",
"last_run_at": "2023-11-07T05:31:56Z",
"last_run_status": "<string>",
"has_draft": true,
"draft_updated_at": "2023-11-07T05:31:56Z",
"deploy_error": "<string>",
"published_version": 123,
"code": "<string>",
"code_draft": "<string>",
"draft_hash": "<string>"
},
"draft_hash": "<string>"
}{
"error": "Invalid input",
"message": "code must be a string"
}{
"error": "Invalid API key",
"message": "The provided API key is not valid"
}{
"error": "Forbidden",
"message": "This API key is missing the required scope: workflows:write"
}{
"error": "Not found",
"message": "Scheduled Function not found"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "Internal server error",
"message": "Failed to save draft"
}Save a Scheduled Function draft
Save new code as the draft of a Scheduled Function without changing what production runs. Returns the draft_hash that publishing requires.
PATCH
/
scheduled-functions
/
{id}
/
draft
Save a Scheduled Function draft
curl --request PATCH \
--url https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"code": "<string>"
}
'import requests
url = "https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft"
payload = { "code": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>'})
};
fetch('https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft', 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.getnexor.ai/api/public/scheduled-functions/{id}/draft",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.getnexor.ai/api/public/scheduled-functions/{id}/draft"
payload := strings.NewReader("{\n \"code\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.patch("https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/scheduled-functions/{id}/draft")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"function": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"cron_expression": "<string>",
"timezone": "<string>",
"run_count": 123,
"is_active": true,
"lookup_config": {
"leads": {
"include": true,
"query": {
"filters": [
{
"column": "id",
"op": "eq",
"value": "<unknown>"
}
],
"order": [
{
"column": "id",
"ascending": false
}
],
"limit": 2
},
"filters": {
"search": "<string>",
"workflowId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"statusId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"campaignId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"activeFilter": "active",
"assignedTo": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"olderThan": {
"value": 1,
"unit": "hours"
},
"newerThan": {
"value": 1,
"unit": "hours"
},
"dateFrom": "2023-11-07T05:31:56Z",
"dateTo": "2023-11-07T05:31:56Z",
"sortBy": "created_at",
"sortDir": "asc"
},
"limit": 2
},
"agents": {
"include": false
},
"hosts": {
"include": false
}
},
"max_leads_per_cycle": 250,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"next_run_at": "2023-11-07T05:31:56Z",
"last_run_at": "2023-11-07T05:31:56Z",
"last_run_status": "<string>",
"has_draft": true,
"draft_updated_at": "2023-11-07T05:31:56Z",
"deploy_error": "<string>",
"published_version": 123,
"code": "<string>",
"code_draft": "<string>",
"draft_hash": "<string>"
},
"draft_hash": "<string>"
}{
"error": "Invalid input",
"message": "code must be a string"
}{
"error": "Invalid API key",
"message": "The provided API key is not valid"
}{
"error": "Forbidden",
"message": "This API key is missing the required scope: workflows:write"
}{
"error": "Not found",
"message": "Scheduled Function not found"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "Internal server error",
"message": "Failed to save draft"
}Save new code for a Scheduled Function without changing what production runs. The published code keeps running on its schedule until you publish the draft.
How the draft works
- Each function has one draft, shared by the dashboard, the API, and the MCP. Each save replaces it.
- Only the code is drafted. The name, description, schedule, timezone, lookup scope, lead cap, and
is_activechange immediately with Update. - Saving code identical to the published code leaves no draft, and
draft_hashcomes backnull. - Keep the
draft_hashfrom the response: Publish requires it.
Sending
code to Update still publishes it immediately. Use this endpoint when the change should be tested first.Next steps
- Test the draft.
- Review the requests it would have sent and the previewed lead changes.
- Publish it with that
draft_hashasexpected_draft_hash.
Authorizations
API key for authentication. Keys are prefixed with nxr_live_.
Path Parameters
Scheduled Function id.
Body
application/json
The complete code of the draft. It replaces the previous draft.
Last modified on October 6, 2026
⌘I