curl --request POST \
--url https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requestIdempotencyKey": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"modelId": "<string>"
}
'import requests
url = "https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft"
payload = {
"requestIdempotencyKey": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"modelId": "<string>"
}
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({
requestIdempotencyKey: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
modelId: '<string>'
})
};
fetch('https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/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://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft",
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([
'requestIdempotencyKey' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'modelId' => '<string>'
]),
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://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft"
payload := strings.NewReader("{\n \"requestIdempotencyKey\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"modelId\": \"<string>\"\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://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requestIdempotencyKey\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"modelId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft")
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 \"requestIdempotencyKey\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"modelId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"runId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued"
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}Start an action content draft
Starts a content-draft run for the action with the same checks as Generate draft in the app: the Page Drafter for a create action, the Section Editor for a refresh action. A refusal carries its reason: 409 for not_content_action, read_only, brief_not_ready, brief_outdated (the brief is not in the current brief format; regenerate it), no_target_page, page_locked, draft_kind_changed (the action now takes the other kind than the draftKind sent), or evidence_unavailable (the evidence of an Agent Picks Action cannot be read; run a new Agent Picks test to refresh it); 403 for forbidden or unavailable (content drafts are off). 409 without a reason means a draft is already being written for this action, or the requestIdempotencyKey was already used for a different request. The API key must have been created by a member of the project with project management permission; otherwise 403. A retry with the same requestIdempotencyKey returns the run that key started as it stands, without rechecking the action, which may have changed since. A retry for another action, draftKind or modelId (an omitted modelId means the model the draft read marks as default) is a 409. A dispatch that fails during the request returns 500 and starts no run. The run uses agent credits; a draft is never published by DevTune. This endpoint has a stricter rate limit than read endpoints. Requires the agents.run scope.
curl --request POST \
--url https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requestIdempotencyKey": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"modelId": "<string>"
}
'import requests
url = "https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft"
payload = {
"requestIdempotencyKey": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"modelId": "<string>"
}
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({
requestIdempotencyKey: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
modelId: '<string>'
})
};
fetch('https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/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://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft",
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([
'requestIdempotencyKey' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'modelId' => '<string>'
]),
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://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft"
payload := strings.NewReader("{\n \"requestIdempotencyKey\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"modelId\": \"<string>\"\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://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requestIdempotencyKey\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"modelId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://devtune.ai/api/v2/projects/{projectId}/actions/{actionId}/draft")
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 \"requestIdempotencyKey\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"modelId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"runId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued"
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}{
"error": "<string>",
"message": "<string>",
"status": 123,
"reason": "<string>",
"details": {
"retryable": true,
"retryAfterSeconds": 2
}
}