Content Templates
Create reusable post templates with variables and platform-specific overrides.
Overview
Content templates let you save reusable post content that can be applied when creating new posts. Unlike saving full post state, templates store just the content with optional platform overrides and variable placeholders — so they never break when accounts are reconnected.
Templates are organization-shared definitions. Creating, updating, or deleting one requires an all-workspace API key; workspace_id is not accepted on create or update.
Legacy templates created before this organization-shared contract can retain a workspace scope. Applying one to a post still requires the calling API key to have access to that workspace; organization-shared templates remain available to every non-empty workspace grant.
How It Works
- Create a template with your post content, optional platform overrides, and tags
- Apply the template when creating posts via the dashboard or API
- Variables like
{{date}}or{{account_name}}are resolved at post creation time
# Create a template
curl -X POST https://api.relayapi.dev/v1/content-templates \
-H "Authorization: Bearer $RELAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Weekly Product Update",
"description": "Use for Monday product announcements",
"content": "This week in {{product_name}}:\n\n{{highlights}}\n\nTry it now: {{url}}",
"platform_overrides": {
"twitter": "{{product_name}} update: {{highlights}} {{url}}"
},
"tags": ["weekly", "product"]
}'Template Variables
Variables use {{variable_name}} syntax in your template content. Built-in variables:
| Variable | Description |
|---|---|
{{date}} | Current date (ISO format) |
{{account_name}} | Display name of the social account |
Pass custom values in template_variables when creating the post. RelayAPI substitutes them in both the base content and every platform override. Missing custom values remain as placeholders; {{account_name}} must resolve to one shared account label across the selected targets or be supplied explicitly.
Platform Overrides
A single template can have different content per platform. When a post targets multiple platforms, the override for that platform is used instead of the base content.
{
"content": "Excited to announce our new feature! Here's everything you need to know about what we've been building...",
"platform_overrides": {
"twitter": "New feature alert! Check out what we've built",
"linkedin": "I'm thrilled to share that our team has shipped a new feature. Here's a deep dive into what it does and why we built it..."
}
}If no override exists for a platform, the base content is used.
Request-level target_options.<target>.content takes precedence over a stored template override, and an explicit top-level content skips the template content and its overrides entirely.
Filtering by Tags
Tags help organize templates. Filter by tag when listing:
# List templates tagged "promo"
curl "https://api.relayapi.dev/v1/content-templates?tag=promo" \
-H "Authorization: Bearer $RELAY_API_KEY"SDK Usage
import Relay from "@relayapi/sdk";
const client = new Relay({ apiKey: "rlay_live_..." });
// Create a template
const template = await client.contentTemplates.create({
name: "Product Launch",
content: "Check out {{product_name}}! {{description}}",
platform_overrides: {
twitter: "{{product_name}} is live! {{description}}",
},
tags: ["launch", "product"],
});
// List templates
const { data } = await client.contentTemplates.list({ limit: 20 });
// Get a specific template
const tmpl = await client.contentTemplates.get("tmpl_abc123");
// Update a template
await client.contentTemplates.update("tmpl_abc123", {
name: "Updated Launch Template",
});
// Delete a template
await client.contentTemplates.delete("tmpl_abc123");API Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /v1/content-templates | Create a template |
GET | /v1/content-templates | List templates (paginated) |
GET | /v1/content-templates/:id | Get template details |
PATCH | /v1/content-templates/:id | Update a template |
DELETE | /v1/content-templates/:id | Delete a template |
Found something wrong? Help us improve this page.