List the workspace's templates
GET
/v1/templates
#!/usr/bin/env bashset -euo pipefailAPI=https://api.speccapture.comAUTH="Authorization: Bearer $SPECCAPTURE_API_KEY"
templateList=$(curl -sS --fail-with-body "$API/v1/templates" \ -H "$AUTH") || { echo "$templateList" >&2; exit 1; }jq -r '"A job naming no template is delivered with \(.defaultTemplateId)"' <<<"$templateList"
jq -r '.templates[] as $template | "\($template.templateId) \($template.name), version \($template.version)"' <<<"$templateList"using System.Text.Json;
using HttpClient http = new() { BaseAddress = new Uri("https://api.speccapture.com") };http.DefaultRequestHeaders.Authorization = new("Bearer", Environment.GetEnvironmentVariable("SPECCAPTURE_API_KEY"));
JsonElement templateList = await Json(await Call(HttpMethod.Get, "/v1/templates"));Console.WriteLine($"A job naming no template is delivered with {templateList.GetProperty("defaultTemplateId")}");
foreach (JsonElement template in templateList.GetProperty("templates").EnumerateArray()) { Console.WriteLine($"{template.GetProperty("templateId")} {template.GetProperty("name")}, version {template.GetProperty("version")}");}
// Sends a request; stops with the problem's code and detail if the API refuses it.async Task<HttpResponseMessage> Call(HttpMethod method, string path, HttpContent? body = null, string? idempotencyKey = null) { using HttpRequestMessage request = new(method, path) { Content = body }; if (idempotencyKey is not null) request.Headers.Add("Idempotency-Key", idempotencyKey); HttpResponseMessage response = await http.SendAsync(request); if (!response.IsSuccessStatusCode) { JsonElement problem = await Json(response); string? detail = (problem.TryGetProperty("detail", out JsonElement text) ? text : problem.GetProperty("title")).GetString(); Console.Error.WriteLine($"{(int)response.StatusCode} {problem.GetProperty("code")}: {detail}"); Environment.Exit(1); } return response;}
// Reads an answer as JSON.static async Task<JsonElement> Json(HttpResponseMessage response) => JsonDocument.Parse(await response.Content.ReadAsStringAsync()).RootElement;import osimport sys
import requests
API = "https://api.speccapture.com"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['SPECCAPTURE_API_KEY']}"
def call(method, path, **kwargs): """Send a request; stop with the problem's code and detail if the API refuses it.""" response = session.request(method, API + path, **kwargs) if not response.ok: problem = response.json() sys.exit(f"{response.status_code} {problem['code']}: {problem.get('detail', problem['title'])}") return response
template_list = call("GET", "/v1/templates").json()print(f"A job naming no template is delivered with {template_list['defaultTemplateId']}")
for template in template_list["templates"]: print(f"{template['templateId']} {template['name']}, version {template['version']}")const API = "https://api.speccapture.com";const headers = { Authorization: `Bearer ${process.env.SPECCAPTURE_API_KEY}` };
const templateList = await call("GET", "/v1/templates").then((response) => response.json());console.log(`A job naming no template is delivered with ${templateList.defaultTemplateId}`);
for (const template of templateList.templates) { console.log(`${template.templateId} ${template.name}, version ${template.version}`);}
// Sends a request; stops with the problem's code and detail if the API refuses it.async function call(method, path, init = {}) { const response = await fetch(API + path, { ...init, method, headers: { ...headers, ...init.headers } }); if (!response.ok) { const problem = await response.json(); console.error(`${response.status} ${problem.code}: ${problem.detail ?? problem.title}`); process.exit(1); } return response;}The standard template (templateId drawing: every field, table and note SpecCapture reads, under its standard names) comes first and is always there; then each template the workspace made in the dashboard, by name, with its newest version. defaultTemplateId is what POST /v1/extractions uses when it names no templateId.
Authorizations
Section titled “Authorizations”Responses
Section titled “Responses”OK
Media typeapplication/json
object
defaultTemplateId
required
string
templates
required
Array<object>
object
templateId
required
string
name
required
string
version
required
integer format: int32
isDefault
required
boolean
definedBy
required
string
updatedAt
required
null | string format: date-time
url
required
string