curl --request GET \
--url https://www.getsurfaced.ai/api/v1/briefs/{id}/run \
--header 'Authorization: Bearer <token>' \
--header 'X-Workspace-Id: <x-workspace-id>'import requests
url = "https://www.getsurfaced.ai/api/v1/briefs/{id}/run"
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"Authorization": "Bearer <token>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'X-Workspace-Id': '<x-workspace-id>', Authorization: 'Bearer <token>'}
};
fetch('https://www.getsurfaced.ai/api/v1/briefs/{id}/run', 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://www.getsurfaced.ai/api/v1/briefs/{id}/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"X-Workspace-Id: <x-workspace-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.getsurfaced.ai/api/v1/briefs/{id}/run"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Workspace-Id", "<x-workspace-id>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.getsurfaced.ai/api/v1/briefs/{id}/run")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.getsurfaced.ai/api/v1/briefs/{id}/run")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": {
"briefId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"runId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "not_started",
"paused": true,
"executionMode": "<string>",
"counts": {
"total": 1,
"queued": 1,
"running": 1,
"succeeded": 1,
"failed": 1,
"cancelled": 1
},
"createdAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"latestActivityAt": "2023-11-07T05:31:56Z",
"items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "queued",
"articleId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"marketRef": "<string>",
"language": "<string>",
"locale": "<string>",
"progress": "<string>",
"errorMessage": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
],
"plan": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 1,
"inputHash": "<string>",
"createdAt": "<string>",
"approvedAt": "<string>",
"runId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"instructions": "<string>",
"keyword": "<string>",
"contentPurpose": "<string>",
"wordCount": {
"min": 123,
"target": 123,
"max": 123
},
"requiredSections": [
"<string>"
],
"targets": [
{
"locale": "<string>",
"market": "<string>",
"language": "<string>"
}
]
}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}Get a Brief's Run
A Brief has one current Run, which writes one Article per market and language. This returns the Run’s own state (not_started until it is run) and item counts, one items entry per target with its writing state (queued, writing, checking, didnt_finish, dropped or written, the same as the Brief’s run.targets; finishing is reserved and not produced yet), the articleId it saved (null until then) and any errorMessage, and the latest saved plan when the Brief’s execution mode asks for approval first. Poll this (or GET /jobs/{id}) while an item is queued, writing, checking or finishing. A didnt_finish item whose writing failed can be written again with POST /briefs/{id}/run/retry once its own writing has stopped, whatever the Run’s state; one whose saved Article did not pass its check is changed in the app. A dropped item (a market someone stopped) is resumed only by a retry with includeDropped: true. runId is null before the first start. A Brief in another workspace is a 404.
curl --request GET \
--url https://www.getsurfaced.ai/api/v1/briefs/{id}/run \
--header 'Authorization: Bearer <token>' \
--header 'X-Workspace-Id: <x-workspace-id>'import requests
url = "https://www.getsurfaced.ai/api/v1/briefs/{id}/run"
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"Authorization": "Bearer <token>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'X-Workspace-Id': '<x-workspace-id>', Authorization: 'Bearer <token>'}
};
fetch('https://www.getsurfaced.ai/api/v1/briefs/{id}/run', 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://www.getsurfaced.ai/api/v1/briefs/{id}/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"X-Workspace-Id: <x-workspace-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.getsurfaced.ai/api/v1/briefs/{id}/run"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Workspace-Id", "<x-workspace-id>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.getsurfaced.ai/api/v1/briefs/{id}/run")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.getsurfaced.ai/api/v1/briefs/{id}/run")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": {
"briefId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"runId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "not_started",
"paused": true,
"executionMode": "<string>",
"counts": {
"total": 1,
"queued": 1,
"running": 1,
"succeeded": 1,
"failed": 1,
"cancelled": 1
},
"createdAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"latestActivityAt": "2023-11-07T05:31:56Z",
"items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "queued",
"articleId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"marketRef": "<string>",
"language": "<string>",
"locale": "<string>",
"progress": "<string>",
"errorMessage": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
],
"plan": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 1,
"inputHash": "<string>",
"createdAt": "<string>",
"approvedAt": "<string>",
"runId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"instructions": "<string>",
"keyword": "<string>",
"contentPurpose": "<string>",
"wordCount": {
"min": 123,
"target": 123,
"max": 123
},
"requiredSections": [
"<string>"
],
"targets": [
{
"locale": "<string>",
"market": "<string>",
"language": "<string>"
}
]
}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"details": {}
}
}Authorizations
API key (sk_live_...) created at https://www.getsurfaced.ai/app/settings/account/api-keys