Template Endpoints
Create Template
Create a new template from an existing environment
POST
/
api
/
platform
/
templates
Create Template
curl --request POST \
--url https://api.example.com/api/platform/templates \
--header 'Content-Type: application/json' \
--data '
{
"environmentId": "<string>",
"service": "<string>",
"name": "<string>",
"description": "<string>",
"visibility": "<string>"
}
'import requests
url = "https://api.example.com/api/platform/templates"
payload = {
"environmentId": "<string>",
"service": "<string>",
"name": "<string>",
"description": "<string>",
"visibility": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
environmentId: '<string>',
service: '<string>',
name: '<string>',
description: '<string>',
visibility: '<string>'
})
};
fetch('https://api.example.com/api/platform/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://api.example.com/api/platform/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([
'environmentId' => '<string>',
'service' => '<string>',
'name' => '<string>',
'description' => '<string>',
'visibility' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/api/platform/templates"
payload := strings.NewReader("{\n \"environmentId\": \"<string>\",\n \"service\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"visibility\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/platform/templates")
.header("Content-Type", "application/json")
.body("{\n \"environmentId\": \"<string>\",\n \"service\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"visibility\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/platform/templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"environmentId\": \"<string>\",\n \"service\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"visibility\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"templateId": "<string>",
"name": "<string>",
"location": "<string>"
}Request
POST /api/platform/templates
Body Parameters
Environment ID to create template from
Service type:
"slack" or "linear"Template name (must be unique, lowercase, no spaces)
Template description
"public" or "private"Example Request
curl -X POST https://api.agentdiff.dev/api/platform/templates \
-H "X-API-Key: ad_live_sk_..." \
-H "Content-Type: application/json" \
-d '{
"environmentId": "abc123def456",
"service": "slack",
"name": "my_custom_template",
"description": "Custom workspace with extra channels",
"visibility": "private"
}'
Response
New template identifier
Template name
Schema location
Example Response
{
"templateId": "template-789",
"name": "my_custom_template",
"location": "my_custom_template",
"service": "slack",
"visibility": "private"
}
Use Case
Create custom templates with specific seed data:- Create environment from base template
- Make API calls to add/modify data
- Save as new template
- Use new template for tests
# 1. Start with base template
env = client.init_env(
templateService="slack",
templateName="slack_default",
impersonateUserId="U01AGENBOT9"
)
# 2. Add custom data
import requests
requests.post(f"{env.environmentUrl}/conversations.create", json={
"name": "my-custom-channel"
})
# 3. Save as template
template = client.create_template_from_environment(
environmentId=env.environmentId,
service="slack",
name="my_workspace",
description="Workspace with custom channel",
visibility="private"
)
# 4. Use in future tests
env2 = client.init_env(
templateService="slack",
templateName="my_workspace",
impersonateUserId="U01AGENBOT9"
)
Errors
| Error | Status | Description |
|---|---|---|
environment_not_found | 404 | Environment doesn’t exist |
template_name_exists | 400 | Template name already taken |
invalid_template_name | 400 | Invalid characters in name |
SDK Usage
template = client.create_template_from_environment(
environmentId=env.environmentId,
service="slack",
name="my_custom_template",
description="Custom workspace",
visibility="private"
)
print(f"Created template: {template.templateId}")
const template = await client.createTemplateFromEnvironment({
environmentId: env.environmentId,
service: 'slack',
name: 'my_custom_template',
description: 'Custom workspace',
visibility: 'private'
});
console.log(`Created template: ${template.templateId}`);
⌘I
Create Template
curl --request POST \
--url https://api.example.com/api/platform/templates \
--header 'Content-Type: application/json' \
--data '
{
"environmentId": "<string>",
"service": "<string>",
"name": "<string>",
"description": "<string>",
"visibility": "<string>"
}
'import requests
url = "https://api.example.com/api/platform/templates"
payload = {
"environmentId": "<string>",
"service": "<string>",
"name": "<string>",
"description": "<string>",
"visibility": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
environmentId: '<string>',
service: '<string>',
name: '<string>',
description: '<string>',
visibility: '<string>'
})
};
fetch('https://api.example.com/api/platform/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://api.example.com/api/platform/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([
'environmentId' => '<string>',
'service' => '<string>',
'name' => '<string>',
'description' => '<string>',
'visibility' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/api/platform/templates"
payload := strings.NewReader("{\n \"environmentId\": \"<string>\",\n \"service\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"visibility\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/platform/templates")
.header("Content-Type", "application/json")
.body("{\n \"environmentId\": \"<string>\",\n \"service\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"visibility\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/platform/templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"environmentId\": \"<string>\",\n \"service\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"visibility\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"templateId": "<string>",
"name": "<string>",
"location": "<string>"
}