curl --request POST \
--url https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates \
--header 'API-KEY: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My Template",
"reference_text": "Template content...",
"default": false
}
'import requests
url = "https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates"
payload = {
"name": "My Template",
"reference_text": "Template content...",
"default": False
}
headers = {
"API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'My Template', reference_text: 'Template content...', default: false})
};
fetch('https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates', 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://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates",
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([
'name' => 'My Template',
'reference_text' => 'Template content...',
'default' => false
]),
CURLOPT_HTTPHEADER => [
"API-KEY: <api-key>",
"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://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates"
payload := strings.NewReader("{\n \"name\": \"My Template\",\n \"reference_text\": \"Template content...\",\n \"default\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("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://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates")
.header("API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My Template\",\n \"reference_text\": \"Template content...\",\n \"default\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My Template\",\n \"reference_text\": \"Template content...\",\n \"default\": false\n}"
response = http.request(request)
puts response.read_body{
"inserted_at": "2024-04-12T15:23:45Z",
"default": false,
"id": 123,
"name": "My Custom Template",
"reference_text": "Template content...",
"updated_at": "2024-06-01T09:17:33Z"
}{
"error": {
"details": [
{
"field": "keywords",
"reason": "required"
}
],
"reason": "validation_error"
}
}{
"error": {
"details": [],
"reason": "unauthorized"
}
}{
"error": {
"details": [],
"reason": "permission_denied"
}
}{
"error": {
"details": [],
"reason": "not_found"
}
}{
"error": {
"details": [
{
"allowed": [
"application/json"
],
"field": "accept",
"reason": "unsupported"
}
],
"message": "Accept must be one of: application/json",
"reason": "not_acceptable"
}
}{
"error": {
"details": [],
"message": "Set Content-Type: application/json.",
"reason": "unsupported_media_type"
}
}{
"error": {
"details": [],
"message": "The request was understood but could not be processed.",
"reason": "unprocessable_entity"
}
}{
"error": {
"details": [
{
"retry_after": 30
}
],
"reason": "rate_limit_exceeded"
}
}Create content template
Creates a custom content template for the workspace.
Rate limit: 10 requests/sec
curl --request POST \
--url https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates \
--header 'API-KEY: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My Template",
"reference_text": "Template content...",
"default": false
}
'import requests
url = "https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates"
payload = {
"name": "My Template",
"reference_text": "Template content...",
"default": False
}
headers = {
"API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'My Template', reference_text: 'Template content...', default: false})
};
fetch('https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates', 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://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates",
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([
'name' => 'My Template',
'reference_text' => 'Template content...',
'default' => false
]),
CURLOPT_HTTPHEADER => [
"API-KEY: <api-key>",
"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://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates"
payload := strings.NewReader("{\n \"name\": \"My Template\",\n \"reference_text\": \"Template content...\",\n \"default\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("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://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates")
.header("API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My Template\",\n \"reference_text\": \"Template content...\",\n \"default\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.surferseo.com/api/v2/workspaces/{workspace_id}/content_templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My Template\",\n \"reference_text\": \"Template content...\",\n \"default\": false\n}"
response = http.request(request)
puts response.read_body{
"inserted_at": "2024-04-12T15:23:45Z",
"default": false,
"id": 123,
"name": "My Custom Template",
"reference_text": "Template content...",
"updated_at": "2024-06-01T09:17:33Z"
}{
"error": {
"details": [
{
"field": "keywords",
"reason": "required"
}
],
"reason": "validation_error"
}
}{
"error": {
"details": [],
"reason": "unauthorized"
}
}{
"error": {
"details": [],
"reason": "permission_denied"
}
}{
"error": {
"details": [],
"reason": "not_found"
}
}{
"error": {
"details": [
{
"allowed": [
"application/json"
],
"field": "accept",
"reason": "unsupported"
}
],
"message": "Accept must be one of: application/json",
"reason": "not_acceptable"
}
}{
"error": {
"details": [],
"message": "Set Content-Type: application/json.",
"reason": "unsupported_media_type"
}
}{
"error": {
"details": [],
"message": "The request was understood but could not be processed.",
"reason": "unprocessable_entity"
}
}{
"error": {
"details": [
{
"retry_after": 30
}
],
"reason": "rate_limit_exceeded"
}
}Authorizations
Headers
Client-generated key for safely retrying create requests. Reusing the same key for the same path answers with the original status code and the resource as it is now; reusing it for a different path returns 422. Keys expire after 24 hours.
Path Parameters
x >= 1123
Body
Content template params
100"My Template"
Reference content (UTF-8). 1–25,000 characters; must contain at least 200 words.
Stored and returned verbatim — no sanitization or normalization. Markdown is the recommended format; predefined Surfer templates use Markdown, and the in-app editor parses this field as Markdown.
The 200-word minimum is counted by a tokenizer over the raw string, so markup characters may or may not contribute to the count.
25000"Template content..."
Response
Created content template
"2024-04-12T15:23:45Z"
false
x >= 1123
"My Custom Template"
Stored verbatim; Markdown recommended.
"Template content..."
"2024-06-01T09:17:33Z"
Was this page helpful?