Publish a Scheduled Function draft
curl --request POST \
--url https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"expected_draft_hash": "<string>"
}
'import requests
url = "https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish"
payload = { "expected_draft_hash": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({expected_draft_hash: '<string>'})
};
fetch('https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish', 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}/publish",
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([
'expected_draft_hash' => '<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}/publish"
payload := strings.NewReader("{\n \"expected_draft_hash\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"expected_draft_hash\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_draft_hash\": \"<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>"
},
"version": {
"version_number": 2,
"source": "panel",
"published_by": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"published_at": "2023-11-07T05:31:56Z"
}
}Publish a Scheduled Function draft
Make the draft of a Scheduled Function the published code and record a new version. Requires the draft_hash you reviewed and returns 409 if the draft changed.
POST
/
scheduled-functions
/
{id}
/
publish
Publish a Scheduled Function draft
curl --request POST \
--url https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"expected_draft_hash": "<string>"
}
'import requests
url = "https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish"
payload = { "expected_draft_hash": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({expected_draft_hash: '<string>'})
};
fetch('https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish', 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}/publish",
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([
'expected_draft_hash' => '<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}/publish"
payload := strings.NewReader("{\n \"expected_draft_hash\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"expected_draft_hash\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/scheduled-functions/{id}/publish")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_draft_hash\": \"<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>"
},
"version": {
"version_number": 2,
"source": "panel",
"published_by": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"published_at": "2023-11-07T05:31:56Z"
}
}Make the draft of a Scheduled Function the published code. Production runs it from its next execution, and it is recorded as a new version that you can restore later.
Before you publish
- Test the draft and review what would have been sent.
- Read the
draft_hashof the draft you tested, from the draft response or from Get. - Send it as
expected_draft_hash.
What can happen
| Response | Meaning |
|---|---|
200 | Published. version.version_number is the new version. |
404 draft_not_found | There is no draft. Someone may have published or discarded it. |
409 draft_changed_since_preview | The draft changed after you read it. Nothing was published. Read it again, test it, and publish its current draft_hash, which the response includes. |
503 DEPLOYMENT_NOT_CURRENT | The new version could not be deployed. Nothing was published and the draft is kept. Retry in a moment. |
Good to know
- Executions already in progress finish on the previous version.
- Publishing does not turn on a paused function. A paused function is deployed when it is turned on or run.
- No test is required by the API, but the dashboard warns when the draft was not tested or its last test failed.
Authorizations
API key for authentication. Keys are prefixed with nxr_live_.
Path Parameters
Scheduled Function id.
Body
application/json
The draft_hash of the draft you reviewed, from the draft response or GET of the function.
Last modified on October 6, 2026
⌘I